diff --git a/.github/workflows/autofmt.yml b/.github/workflows/autofmt.yml index dda137aa3e..3c92c3dc4e 100644 --- a/.github/workflows/autofmt.yml +++ b/.github/workflows/autofmt.yml @@ -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 diff --git a/.github/workflows/autoversion.yml b/.github/workflows/autoversion.yml index f0fbf5330c..f66c151e0a 100644 --- a/.github/workflows/autoversion.yml +++ b/.github/workflows/autoversion.yml @@ -1,5 +1,6 @@ on: workflow_call: +name: Auto-version jobs: semver-tag: name: Conventional Commits Auto-version @@ -7,8 +8,12 @@ jobs: 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 \ No newline at end of file + run: scripts/autoversion + env: + GH_TOKEN: ${{ secrets.FTL_AUTOVERSION_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9630d93170..94c53e80ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ef75de7cc..8601bc050b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ on: push: tags: - - v** + - 'v[0-9]+.[0-9]+.[0-9]+' name: Build Docker Images jobs: build-runner: @@ -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 diff --git a/scripts/autoversion b/scripts/autoversion index a997cb7f10..bf8384f699 100755 --- a/scripts/autoversion +++ b/scripts/autoversion @@ -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}" \