Ensure latest and stable tags are updated on push to main

This commit is contained in:
Edward Firmo
2024-12-22 16:17:07 +01:00
parent 669cc2f2c2
commit b1187332fb

View File

@@ -1,40 +1,36 @@
# This GitHub Actions workflow updates the "stable" and "latest" Git tags # This GitHub Actions workflow updates the "stable" and "latest" Git tags
# to point to the tag associated with a newly published release. It performs # to point to the latest commit on the main branch whenever code is merged.
# the following steps: # It performs the following steps:
# 1. Checks out the repository code with full history. # 1. Checks out the repository code with full history
# 2. Configures Git with a generic user for the action. # 2. Configures Git with a generic user for the action
# 3. Moves and forcibly pushes the "stable" and "latest" tags to align with # 3. Moves and forcibly pushes the "stable" and "latest" tags to align with
# the tag of the newly published release. # the latest main branch commit
# This ensures that "stable" and "latest" always point to the most recent release.
--- ---
name: Update Tags name: Update Tags
# yamllint disable-line rule:truthy on: # yamllint disable-line rule:truthy
on: push:
release: branches:
types: [published] - main
jobs: jobs:
update-tags: update-tags:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@main uses: actions/checkout@v4
with: with:
fetch-depth: '0' fetch-depth: 0
- name: Set up Git - name: Set up Git
run: | run: |
git config --local user.email "action@github.com" git config --local user.email "action@github.com"
git config --local user.name "GitHub Action" git config --local user.name "GitHub Action"
- name: Move and push stable tag - name: Move and push tags
run: | run: |
git tag -f stable ${{ github.event.release.tag_name }} echo "Creating/updating stable and latest tags pointing to latest main commit"
git push -f origin stable git tag -fa stable -m "Update stable tag to latest main"
git tag -fa latest -m "Update latest tag to latest main"
- name: Move and push latest tag git push origin stable latest --force
run: |
git tag -f latest ${{ github.event.release.tag_name }}
git push -f origin latest
... ...