Skip to content

Commit 10cfc2f

Browse files
authored
feat: major version updater (#55)
Updates the major version to point to the latest published tag with the same major tag Example: v2.2.0 exists v2 is currently pointed to v2.2.0 release happens v2.3.0 is created this action will point v2 at the new v2.3.0 Signed-off-by: jmeridth <[email protected]>
1 parent 4c759cb commit 10cfc2f

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: "Major Version Updater"
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag_name:
7+
required: true
8+
type: string
9+
permissions:
10+
contents: read
11+
jobs:
12+
major_version_updater:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- uses: actions/[email protected]
18+
with:
19+
fetch-tags: true
20+
ref: ${{ inputs.tag_name }}
21+
- name: version
22+
id: version
23+
env:
24+
TAG_NAME: ${{ inputs.tag_name }}
25+
run: |
26+
tag=${TAG_NAME/refs\/tags\//}
27+
version=${tag#v}
28+
major=${version%%.*}
29+
{ echo "tag=${tag}"; echo "version=${version}"; echo "major=${major}"; } >> "$GITHUB_OUTPUT"
30+
- name: force update major tag
31+
run: |
32+
git tag -f v${{ steps.version.outputs.major }} ${{ steps.version.outputs.tag }}
33+
git push -f origin v${{ steps.version.outputs.major }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: "Test Major Version Updater"
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
TAG_NAME:
9+
description: "Tag name that the major tag will point to (e.g. v1.2.3)"
10+
required: true
11+
permissions:
12+
contents: read
13+
jobs:
14+
labeler:
15+
permissions:
16+
contents: write
17+
uses: ./.github/workflows/major-version-updater.yaml
18+
with:
19+
tag_name: ${{ github.event.inputs.TAG_NAME || github.ref}}

0 commit comments

Comments
 (0)