Skip to content

Commit 2f70c00

Browse files
ci: also move minor version tag on release (e.g. v3.1.0 updates v3 and v3.1)
Co-Authored-By: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
1 parent f3c875b commit 2f70c00

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,40 @@ on:
55
types: [published]
66

77
jobs:
8-
tag-major:
8+
tag-aliases:
99
runs-on: ubuntu-latest
1010
permissions:
1111
contents: write
1212
steps:
1313
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1414

15-
- name: Move major version tag
15+
- name: Move major and minor version tags
1616
if: ${{ !github.event.release.prerelease }}
1717
env:
1818
GH_TOKEN: ${{ github.token }}
1919
run: |
2020
VERSION="${{ github.event.release.tag_name }}"
2121
22-
# Only move the major tag if this is the latest release for the repo
22+
# Only move tags if this is the latest release for the repo
2323
LATEST=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName)
2424
if [ "$LATEST" != "$VERSION" ]; then
2525
echo "Skipping: $VERSION is not the latest release (latest is $LATEST)"
2626
exit 0
2727
fi
2828
29-
MAJOR="v$(echo "$VERSION" | sed 's/^v//' | cut -d. -f1)"
29+
STRIPPED="$(echo "$VERSION" | sed 's/^v//')"
30+
PARTS="$(echo "$STRIPPED" | tr '.' '\n' | wc -l)"
31+
MAJOR="v$(echo "$STRIPPED" | cut -d. -f1)"
32+
33+
# Always move the major tag (e.g. v3)
34+
echo "Updating major tag: $MAJOR"
3035
git tag -f "$MAJOR"
3136
git push origin "refs/tags/$MAJOR" --force
37+
38+
# Move the minor tag only if version has 3+ parts (e.g. v3.1.0 → v3.1)
39+
if [ "$PARTS" -ge 3 ]; then
40+
MINOR="v$(echo "$STRIPPED" | cut -d. -f1).$(echo "$STRIPPED" | cut -d. -f2)"
41+
echo "Updating minor tag: $MINOR"
42+
git tag -f "$MINOR"
43+
git push origin "refs/tags/$MINOR" --force
44+
fi

0 commit comments

Comments
 (0)