From b1187332fb8b2a9686780599d6a1961dc1624ade Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 22 Dec 2024 16:17:07 +0100 Subject: [PATCH] Ensure `latest` and `stable` tags are updated on `push` to `main` --- .github/workflows/release_tag.yml | 36 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release_tag.yml b/.github/workflows/release_tag.yml index 6dce8f0..b4b7bc4 100644 --- a/.github/workflows/release_tag.yml +++ b/.github/workflows/release_tag.yml @@ -1,40 +1,36 @@ # This GitHub Actions workflow updates the "stable" and "latest" Git tags -# to point to the tag associated with a newly published release. It performs -# the following steps: -# 1. Checks out the repository code with full history. -# 2. Configures Git with a generic user for the action. +# to point to the latest commit on the main branch whenever code is merged. +# It performs the following steps: +# 1. Checks out the repository code with full history +# 2. Configures Git with a generic user for the action # 3. Moves and forcibly pushes the "stable" and "latest" tags to align with -# the tag of the newly published release. -# This ensures that "stable" and "latest" always point to the most recent release. +# the latest main branch commit --- name: Update Tags -# yamllint disable-line rule:truthy -on: - release: - types: [published] +on: # yamllint disable-line rule:truthy + push: + branches: + - main jobs: update-tags: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@main + uses: actions/checkout@v4 with: - fetch-depth: '0' + fetch-depth: 0 - name: Set up Git run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - - name: Move and push stable tag + - name: Move and push tags run: | - git tag -f stable ${{ github.event.release.tag_name }} - git push -f origin stable - - - name: Move and push latest tag - run: | - git tag -f latest ${{ github.event.release.tag_name }} - git push -f origin latest + echo "Creating/updating stable and latest tags pointing to latest main commit" + git tag -fa stable -m "Update stable tag to latest main" + git tag -fa latest -m "Update latest tag to latest main" + git push origin stable latest --force ...