Skip to content

Commit

Permalink
ci: add release workflow and versioned docker builds
Browse files Browse the repository at this point in the history
chore: run build on all tags
  • Loading branch information
ChristophBe committed Oct 18, 2024
1 parent 1c88c9f commit a754af9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 3 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Create and publish a Docker image

on:
workflow_run:
Expand All @@ -8,12 +8,21 @@ on:
- completed
branches:
- main
push:
tags:
- '**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: accenture/federated-catalogue-viewer

IMAGE_TAG: ''
jobs:
generate-next-release-version:
if: ${{ github.ref_type == 'branch' }}
uses: ./.github/workflows/semantic-release.yaml
with:
dry-run: true

build-and-push-image:
runs-on: ubuntu-latest

Expand All @@ -31,6 +40,15 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Determine Image Tag
if: ${{ github.ref_type == 'branch' }}
run: |
echo \"IMAGE_TAG=${{env.NEXT_RELEASE_VERSION}}-pre-release-$(git rev-parse --short ${{ github.sha }})\" >> $GITHUB_ENV
- name: Determine Image Tag
if: ${{ github.ref_type == 'tag' }}
run: |
echo \"IMAGE_TAG=${{github.ref_name}}\" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -44,4 +62,6 @@ jobs:
platforms: linux/amd64,linux/arm64
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
7 changes: 7 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Release

on: workflow_dispatch

jobs:
create-release:
uses: ./.github/workflows/semantic-release.yaml
38 changes: 38 additions & 0 deletions .github/workflows/semantic-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Create Release
on:
workflow_call:
inputs:
dry-run:
default: false
type: boolean

permissions:
contents: read

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

- name: Install Dependencies
run: npm install @semantic-release/exec conventional-changelog-conventionalcommits -D

- name: Determine next Version
id: determine-next-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release --dry-run ${{ inputs.dry-run }}
31 changes: 31 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{ "breaking": true, "release": "major" },
{ "revert": true, "release": "patch" },
{ "type": "build", "release": "patch" },
{ "type": "docs", "release": "patch" },
{ "type": "feat", "release": "minor" },
{ "type": "fix", "release": "patch" },
{ "type": "perf", "release": "patch" },
{ "type": "data", "release": "patch" },
{ "type": "explore", "release": "patch" },
{ "type": "result", "release": "patch" },
{ "type": "refactor", "release": "patch" }
]
}
],
[
"@semantic-release/exec",
{
"verifyReleaseCmd": "echo \"NEXT_RELEASE_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
}
],
"@semantic-release/github"
],
"branches": ["main"]
}

0 comments on commit a754af9

Please sign in to comment.