Skip to content

Commit c4ca558

Browse files
committed
Add github action for updating major tag
1 parent f556541 commit c4ca558

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Update Major Version Tag
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'The full version tag to process (e.g., v13.1.0)'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
update-major-tag:
16+
name: Update Major Version Tag
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Get tag name
27+
id: get-tag
28+
run: |
29+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
30+
TAG="${{ inputs.tag }}"
31+
else
32+
TAG="${GITHUB_REF#refs/tags/}"
33+
fi
34+
echo "tag=$TAG" >> $GITHUB_OUTPUT
35+
# Extract major version (e.g., v13 from v13.1.0)
36+
MAJOR_TAG=$(echo "$TAG" | sed -E 's/^(v[0-9]+)\..*/\1/')
37+
echo "major_tag=$MAJOR_TAG" >> $GITHUB_OUTPUT
38+
39+
- name: Update major version tag
40+
run: |
41+
TAG="${{ steps.get-tag.outputs.tag }}"
42+
MAJOR_TAG="${{ steps.get-tag.outputs.major_tag }}"
43+
44+
echo "Processing tag: $TAG"
45+
echo "Major version tag: $MAJOR_TAG"
46+
47+
# Configure git
48+
git config user.name "github-actions[bot]"
49+
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
# Get the commit SHA for the pushed tag
52+
COMMIT_SHA=$(git rev-list -n 1 "$TAG")
53+
echo "Commit SHA: $COMMIT_SHA"
54+
55+
# Delete the major tag locally if it exists
56+
git tag -d "$MAJOR_TAG" 2>/dev/null || true
57+
58+
# Create/update the major version tag pointing to the same commit
59+
git tag "$MAJOR_TAG" "$COMMIT_SHA"
60+
61+
# Force push the major version tag to origin
62+
git push origin "$MAJOR_TAG" --force
63+
64+
echo "Successfully updated $MAJOR_TAG to point to $TAG ($COMMIT_SHA)"

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ jobs:
105105
106106
For more application cases please check [Smoke Test Workflow file](https://github.com/DeLaGuardo/setup-clojure/blob/main/.github/workflows/smoke-tests.yml)
107107
108+
# Versioning
109+
110+
You can reference this action using either:
111+
112+
- **Full version** (e.g., `DeLaGuardo/[email protected]`) - pins to a specific release
113+
- **Major version** (e.g., `DeLaGuardo/setup-clojure@v13`) - automatically receives all minor and patch updates within that major version
114+
115+
Using the major version tag is recommended for most users, as it ensures you receive bug fixes and new features without breaking changes.
116+
108117
# License
109118

110119
The scripts and documentation in this project are released under the [MIT License](LICENSE)

0 commit comments

Comments
 (0)