Skip to content

Commit

Permalink
feat: auto-version via CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Aug 25, 2023
1 parent 7762104 commit 48fb2e0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autofmt.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: autofmt
on:
push:
branches:
- main
pull_request:
name: Auto-format
jobs:
format:
# Check if the PR is not from a fork
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/autoversion.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
on:
workflow_call:
name: Auto-version
jobs:
semver-tag:
name: Conventional Commits Auto-version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Auto-version
id: autoversion
run: scripts/autoversion
run: scripts/autoversion
env:
GH_TOKEN: ${{ secrets.FTL_AUTOVERSION_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
uses: ./.github/workflows/integration.yml
autoversion:
name: Auto Version
secrets: inherit
if: github.ref == 'refs/heads/main'
needs:
- kotlin-runtime
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
tags:
- v**
- 'v[0-9]+.[0-9]+.[0-9]+'
name: Build Docker Images
jobs:
build-runner:
Expand Down Expand Up @@ -74,7 +74,8 @@ jobs:
- name: Push
if: github.ref == 'refs/heads/main'
run: |
docker tag ghcr.io/tbd54566975/ftl-runner:latest ghcr.io/tbd54566975/ftl-runner:$GITHUB_SHA
version=$(git describe --tags --abbrev=0)
docker tag ghcr.io/tbd54566975/ftl-runner:latest ghcr.io/tbd54566975/ftl-runner:$GITHUB_SHA ghcr.io/tbd54566975/ftl-runner:$version
docker push -a ghcr.io/tbd54566975/ftl-runner
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:$GITHUB_SHA
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:$GITHUB_SHA ghcr.io/tbd54566975/ftl-controller:$version
docker push -a ghcr.io/tbd54566975/ftl-controller
4 changes: 4 additions & 0 deletions scripts/autoversion
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ set -euo pipefail
old_version="$(svu current)"
new_version="$(svu next)"

test -z "$GH_TOKEN" && { echo "GH_TOKEN is not set"; exit 1; }

test "${old_version}" = "${new_version}" && { echo "No version change"; exit 0; }

echo "Version updating from ${old_version} to ${new_version}"

gh api -H "Accept: application/vnd.github.v3+json" \
"/repos/{owner}/{repo}/git/refs" \
-f ref="refs/tags/${new_version}" \
Expand Down

0 comments on commit 48fb2e0

Please sign in to comment.