Skip to content

Commit

Permalink
feat: add semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
henninge committed Jan 5, 2022
1 parent 95a99a7 commit b4c542b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
37 changes: 25 additions & 12 deletions .github/workflows/buildpush.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,37 @@
# separate terms of service, privacy policy, and support
# documentation.

name: Create and publish a Docker image
name: Build and release the controller image

on:
push:
branches: ['release']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE: ghcr.io/${{ github.repository }}

jobs:
build-and-push-image:
build-and-release:
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
contents: write
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: setup node
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/

- name: setup release tools
run: npm install -g semantic-release@15 @semantic-release/exec

- name: Install make
run: sudo apt-get install -y make

- name: Log in to the Container registry
uses: docker/login-action@v1
Expand All @@ -31,9 +42,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Checkout repository
uses: actions/checkout@v2

- name: Push and release image
run: npx semantic-release
env:
IMAGE: ${{ env.IMAGE }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Test

on:
push:
branches:
branches-ignore:
- 'release'
tags-ignore:
- '*'
pull_request: {}

Expand Down
15 changes: 15 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"branch": "release",
"plugins": [
"@semantic-release/commit-analyzer",
["@semantic-release/release-notes-generator", {
"writerOpts": {
"headerPartial": "# {{version}}\nImage: `ghcr.io/inovex/aws-auth-controller:{{version}}`"
}
}],
["@semantic-release/exec", {
"publishCmd": "make release version=${nextRelease.version}"
}],
"@semantic-release/github"
]
}
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
version ?= test
IMAGE ?= controller
IMG ?= ${IMAGE}:${version}
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"

Expand Down Expand Up @@ -60,12 +62,16 @@ build: generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

docker-build: test ## Build docker image with the manager.
docker-build: ## Build docker image with the manager.
docker build -t ${IMG} .

docker-push: ## Push docker image with the manager.
docker push ${IMG}

##@ Release

release: docker-build docker-push

##@ Deployment

install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
Expand Down

0 comments on commit b4c542b

Please sign in to comment.