Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Initial implementation with Rekor chart (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Block <[email protected]>
  • Loading branch information
sabre1041 committed Aug 29, 2021
1 parent 5acfbd1 commit edac28e
Show file tree
Hide file tree
Showing 63 changed files with 2,921 additions and 1 deletion.
62 changes: 62 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: pull request
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: build
steps:
- name: set repo name
shell: bash
run: |
echo "REPOSITORY_NAME=$(basename $GITHUB_REPOSITORY)" >> $GITHUB_ENV
- name: Check out code
uses: actions/checkout@v2

- name: Download operator sdk
shell: bash
env:
RELEASE_VERSION: v1.9.0
run: |
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk_linux_amd64
chmod +x operator-sdk_linux_amd64
mkdir ${HOME}/bin
mv operator-sdk_linux_amd64 ${HOME}/bin/operator-sdk
echo "${HOME}/bin" >> $GITHUB_PATH
- name: build bundle
shell: bash
run: make bundle IMG=quay.io/${{ github.repository_owner }}/$(basename $GITHUB_REPOSITORY):0.0.1 VERSION=0.0.1 DEFAULT_CHANNEL=alpha

- name: verify bundle
shell: bash
run: operator-sdk bundle validate ./bundle --select-optional name=operatorhub

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: "Build Operator Image"
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le
push: false
tags: "ghcr.io/${{ github.repository_owner }}/${{ env.REPOSITORY_NAME }}:v0.0.1"

- name: "Build Bundle Image"
uses: docker/build-push-action@v2
with:
context: .
file: ./bundle.Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le
push: false
tags: "ghcr.io/${{ github.repository_owner }}/${{ env.REPOSITORY_NAME }}-bundle:0.0.1"
160 changes: 160 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: push
on:
push:
branches:
- main
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
name: build
steps:
- name: set repo name
shell: bash
run: |
echo "REPOSITORY_NAME=$(basename $GITHUB_REPOSITORY)" >> $GITHUB_ENV
- name: Check out code
uses: actions/checkout@v2

- name: Download operator sdk
shell: bash
env:
RELEASE_VERSION: v1.9.0
run: |
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk_linux_amd64
chmod +x operator-sdk_linux_amd64
mkdir ${HOME}/bin
mv operator-sdk_linux_amd64 ${HOME}/bin/operator-sdk
echo "${HOME}/bin" >> $GITHUB_PATH
- name: Get the version for tags
id: get_version1
if: "startsWith(github.ref, 'refs/tags')"
shell: bash
run: |
echo "OPERATOR_IMAGE_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "BUNDLE_IMAGE_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
export TAG=${GITHUB_REF/refs\/tags\//}
echo "BUNDLE_VERSION=${TAG:1}" >> $GITHUB_ENV
export SEMVER_COMPLIANT=$(echo ${TAG:1} | egrep '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')
if [ -z "$SEMVER_COMPLIANT" ]; then echo "invalid semver tag ${GITHUB_REF/refs\/tags\//}"; exit 1; fi
- name: Get the version for merge
id: get_version2
if: "! startsWith(github.ref, 'refs/tags')"
shell: bash
run: |
echo "OPERATOR_IMAGE_TAG=latest" >> $GITHUB_ENV
echo "BUNDLE_IMAGE_TAG=v0.0.1" >> $GITHUB_ENV
echo "BUNDLE_VERSION=0.0.1" >> $GITHUB_ENV
- name: build bundle
shell: bash
run: |
make bundle IMG=ghcr.io/${{ github.repository_owner }}/$(basename $GITHUB_REPOSITORY):${OPERATOR_IMAGE_TAG} VERSION=${BUNDLE_VERSION} DEFAULT_CHANNEL=alpha
- name: verify bundle
shell: bash
run: operator-sdk bundle validate ./bundle --select-optional name=operatorhub

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin

- name: "Build and Push Operator Image"
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le
push: true
tags: "ghcr.io/${{ github.repository_owner }}/${{ env.REPOSITORY_NAME }}:${{ env.OPERATOR_IMAGE_TAG }}"

- name: "Build and Push Bundle Image"
uses: docker/build-push-action@v2
with:
context: .
file: ./bundle.Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le
push: true
tags: "ghcr.io/${{ github.repository_owner }}/${{ env.REPOSITORY_NAME }}-bundle:${{ env.BUNDLE_IMAGE_TAG }}"

- name: "Verify bundle image"
shell: bash
run: operator-sdk bundle validate ghcr.io/${{ github.repository_owner }}/$(basename $GITHUB_REPOSITORY)-bundle:${BUNDLE_IMAGE_TAG} --select-optional name=operatorhub

- name: process bundle for disconnected support
uses: redhat-cop/github-actions/disconnected-csv@master
with:
CSV_FILE: bundle/manifests/${{ env.REPOSITORY_NAME }}.clusterserviceversion.yaml
TAGS_TO_DIGESTS: ${OPERATOR_IMAGE_TAG}

- name: Archive the bundle
if: "startsWith(github.ref, 'refs/tags')"
run: tar czvf ${{ env.REPOSITORY_NAME }}-bundle-${{ env.BUNDLE_IMAGE_TAG }}.tar.gz bundle

- name: Upload bundle archive
uses: actions/upload-artifact@v2
with:
name: bundle-archive
path: ${{ env.REPOSITORY_NAME }}-bundle-${{ env.BUNDLE_IMAGE_TAG }}.tar.gz

release-github:
name: GitHub Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags')"
needs: ["build"]
steps:
- name: set repo name
shell: bash
run: |
echo "REPOSITORY_NAME=$(basename $GITHUB_REPOSITORY)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2

- run: |
git fetch --prune --unshallow
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV

- name: Generate Changelog
run: |
LATEST_TAG=$(git tag --sort=creatordate | sed '$!d')
PREVIOUS_TAG=$(git tag --sort=creatordate | sed 'x;$!d')
if [ -z "${PREVIOUS_TAG}" ]; then
REV_RANGE=${LATEST_TAG}
else
REV_RANGE=${PREVIOUS_TAG}..${LATEST_TAG}
fi
git log --pretty=format:"- %s %H (%aN)" --no-merges ${REV_RANGE} > ${VERSION}-CHANGELOG.txt
cat ${VERSION}-CHANGELOG.txt
- name: Download bundle archive
uses: actions/download-artifact@v2
with:
name: bundle-archive

- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: ${{ env.VERSION }}-CHANGELOG.txt
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload bundle to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.REPOSITORY_NAME }}-bundle-${{ env.VERSION }}.tar.gz
tag: ${{ github.ref }}
overwrite: true
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OSX
.DS_Store

#EnvTest
testbin/*

#Bundle
bundle
bundle.Dockerfile

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Build the manager binary
FROM quay.io/operator-framework/helm-operator:v1.9.0

ENV HOME=/opt/helm
COPY watches.yaml ${HOME}/watches.yaml
COPY helm-charts ${HOME}/helm-charts
WORKDIR ${HOME}
Loading

0 comments on commit edac28e

Please sign in to comment.