Skip to content

Commit 038147a

Browse files
authored
Automate shorthand major version tag updating (#28)
1 parent ee5ffc7 commit 038147a

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/publish-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ jobs:
2121
with:
2222
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
2323
- uses: ./
24+
id: publish-release
2425
env:
2526
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Update shorthand major version tag
28+
run: ./scripts/update-major-version-tag.sh ${{ steps.publish-release.outputs.release-version }}

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ inputs:
66
default: 'release/'
77
required: true
88

9+
outputs:
10+
release-version:
11+
description: 'The version of the release'
12+
value: ${{ steps.get-release-version.outputs.RELEASE_VERSION }}
13+
914
runs:
1015
using: 'composite'
1116
steps:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
set -e
5+
set -o pipefail
6+
7+
RELEASE_VERSION="${1}"
8+
9+
if [[ -z $RELEASE_VERSION ]]; then
10+
echo "Error: No release version specified."
11+
exit 1
12+
fi
13+
14+
MAJOR_VERSION_TAG="v${RELEASE_VERSION/\.*/}"
15+
16+
git config user.name github-actions
17+
git config user.email github-actions@github.com
18+
19+
if git show-ref --tags "$MAJOR_VERSION_TAG" --quiet; then
20+
echo "Tag ${MAJOR_VERSION_TAG} exists, attempting to delete it."
21+
git tag --delete "$MAJOR_VERSION_TAG"
22+
git push --delete origin "$MAJOR_VERSION_TAG"
23+
else
24+
echo "Tag ${MAJOR_VERSION_TAG} does not exist, creating it from scratch."
25+
fi
26+
27+
git tag "$MAJOR_VERSION_TAG" HEAD
28+
git push --tags
29+
echo "Updated shorthand major version tag."
30+
31+
echo "::set-output name=MAJOR_VERSION_TAG::$MAJOR_VERSION_TAG"

0 commit comments

Comments
 (0)