From 7762104d5eda34dec1ee6f722547340feb3944c5 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 25 Aug 2023 14:38:52 +1000 Subject: [PATCH] ci: enable automatic semantic versioning using Conventional Commits The version bumps can be controlled using https://www.conventionalcommits.org commit messages. --- .github/workflows/autoversion.yml | 14 ++++++++++++++ .github/workflows/ci.yml | 7 ++++--- .github/workflows/release.yml | 4 +++- bin/.svu-1.11.0.pkg | 1 + bin/svu | 1 + scripts/autoversion | 12 ++++++++++++ 6 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/autoversion.yml create mode 120000 bin/.svu-1.11.0.pkg create mode 120000 bin/svu create mode 100755 scripts/autoversion diff --git a/.github/workflows/autoversion.yml b/.github/workflows/autoversion.yml new file mode 100644 index 0000000000..f0fbf5330c --- /dev/null +++ b/.github/workflows/autoversion.yml @@ -0,0 +1,14 @@ +on: + workflow_call: +jobs: + semver-tag: + name: Conventional Commits Auto-version + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + - name: Auto-version + id: autoversion + run: scripts/autoversion \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 301e882bcf..9630d93170 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,8 +104,8 @@ jobs: name: Integration Tests if: github.ref == 'refs/heads/main' uses: ./.github/workflows/integration.yml - release: - name: Release + autoversion: + name: Auto Version if: github.ref == 'refs/heads/main' needs: - kotlin-runtime @@ -114,4 +114,5 @@ jobs: - lint - console - integration - uses: ./.github/workflows/release.yml + - sql + uses: ./.github/workflows/autoversion.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02d7e7071b..5ef75de7cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,7 @@ on: - workflow_call: + push: + tags: + - v** name: Build Docker Images jobs: build-runner: diff --git a/bin/.svu-1.11.0.pkg b/bin/.svu-1.11.0.pkg new file mode 120000 index 0000000000..383f4511d4 --- /dev/null +++ b/bin/.svu-1.11.0.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/bin/svu b/bin/svu new file mode 120000 index 0000000000..b97a81573e --- /dev/null +++ b/bin/svu @@ -0,0 +1 @@ +.svu-1.11.0.pkg \ No newline at end of file diff --git a/scripts/autoversion b/scripts/autoversion new file mode 100755 index 0000000000..a997cb7f10 --- /dev/null +++ b/scripts/autoversion @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail + +old_version="$(svu current)" +new_version="$(svu next)" + +test "${old_version}" = "${new_version}" && { echo "No version change"; exit 0; } + +gh api -H "Accept: application/vnd.github.v3+json" \ + "/repos/{owner}/{repo}/git/refs" \ + -f ref="refs/tags/${new_version}" \ + -f sha="$(git rev-parse HEAD)"