Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #104 from font/release
Browse files Browse the repository at this point in the history
Add GitHub Actions workflow to automate releases
  • Loading branch information
font authored Jan 13, 2021
2 parents 581eeee + 5de2c57 commit db4fe37
Show file tree
Hide file tree
Showing 4 changed files with 1,125 additions and 5 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ jobs:
pull: true
push: true
tags: |
${{ env.WORKFLOW_IMG }}:latest
${{ env.WORKFLOW_IMG }}:master
- name: Build and Push Bundle Image
run: |
make bundle-build VERSION=master
docker tag ${WORKFLOW_BUNDLE_IMG}:master ${WORKFLOW_BUNDLE_IMG}:latest
make docker-push IMG=${WORKFLOW_BUNDLE_IMG}:master
make docker-push IMG=${WORKFLOW_BUNDLE_IMG}:latest
- name: Set Up Go to Install OPM
uses: actions/setup-go@v2
Expand All @@ -61,6 +58,4 @@ jobs:
- name: Build and Push Bundle Index Image
run: |
make bundle-index-build VERSION=master
docker tag ${WORKFLOW_BUNDLE_INDEX_IMG}:master ${WORKFLOW_BUNDLE_INDEX_IMG}:latest
make docker-push IMG=${WORKFLOW_BUNDLE_INDEX_IMG}:master
make docker-push IMG=${WORKFLOW_BUNDLE_INDEX_IMG}:latest
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Create Release

on:
push:
tags:
- 'v*' # tags matching v*, i.e. v0.0.1, v1.0.0-rc.0

jobs:
build:
name: Create Release
runs-on: ubuntu-18.04
strategy:
matrix:
go: [ '1.15' ]
steps:
- name: Set Up Environment Variables
env:
REPO: quay.io/${{ secrets.QUAY_ACCOUNT_NAME }}
IMG: gatekeeper-operator
run: |
echo "REPO=${REPO}" >> ${GITHUB_ENV}
RELEASE_VERSION=${{ github.ref }}
# Removes the 'refs/tags/' portion of the string i.e. 'refs/tags/v0.0.1' to 'v0.0.1'
echo "RELEASE_VERSION=${RELEASE_VERSION##*/}" >> ${GITHUB_ENV}
RELEASE_IMG="${REPO}/${IMG}"
echo "RELEASE_IMG=${RELEASE_IMG}" >> ${GITHUB_ENV}
echo "RELEASE_BUNDLE_IMG=${RELEASE_IMG}-bundle" >> ${GITHUB_ENV}
echo "RELEASE_BUNDLE_INDEX_IMG=${RELEASE_IMG}-bundle-index" >> ${GITHUB_ENV}
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
with:
driver-opts: image=moby/buildkit:v0.8-beta
- uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
pull: true
push: true
tags: |
${{ env.RELEASE_IMG }}:${{ env.RELEASE_VERSION }}
${{ env.RELEASE_IMG }}:latest
- name: Build and Push Bundle Image
run: |
make bundle-build VERSION=${RELEASE_VERSION}
docker tag ${RELEASE_BUNDLE_IMG}:${RELEASE_VERSION} ${RELEASE_BUNDLE_IMG}:latest
make docker-push IMG=${RELEASE_BUNDLE_IMG}:${RELEASE_VERSION}
make docker-push IMG=${RELEASE_BUNDLE_IMG}:latest
- name: Set Up Go to Install OPM
uses: actions/setup-go@v2
id: go
with:
go-version: ${{ matrix.go }}

- name: Build and Push Bundle Index Image
run: |
make bundle-index-build VERSION=${RELEASE_VERSION}
docker tag ${RELEASE_BUNDLE_INDEX_IMG}:${RELEASE_VERSION} ${RELEASE_BUNDLE_INDEX_IMG}:latest
make docker-push IMG=${RELEASE_BUNDLE_INDEX_IMG}:${RELEASE_VERSION}
make docker-push IMG=${RELEASE_BUNDLE_INDEX_IMG}:latest
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions.
with:
tag_name: ${{ github.ref }}
release_name: Gatekeeper Operator ${{ github.ref }}
body: |
To install the Gatekeeper Operator:
```
kubectl apply -f https://raw.githubusercontent.com/${{ github.repository }}/${{ env.RELEASE_VERSION }}/deploy/gatekeeper-operator.yaml
```
draft: false
prerelease: false
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,11 @@ deploy-ci: deploy-ci-namespace deploy
deploy-ci-namespace: install
kubectl create namespace --dry-run=client -o yaml $(NAMESPACE) | kubectl apply -f-
sed -i 's/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g' config/manager/manager.yaml

.PHONY: release
release: manifests kustomize
cd config/default && $(KUSTOMIZE) edit set namespace $(NAMESPACE)
cd $(RBAC_DIR) && $(KUSTOMIZE) edit set namespace $(NAMESPACE)
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
{ $(KUSTOMIZE) build config/default ; echo "---" ; $(KUSTOMIZE) build $(RBAC_DIR) ; } > deploy/gatekeeper-operator.yaml

Loading

0 comments on commit db4fe37

Please sign in to comment.