generated from solvaholic/template
-
Notifications
You must be signed in to change notification settings - Fork 19
51 lines (45 loc) · 1.48 KB
/
update-major.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Update major tag
on:
# Run when a release tag is pushed
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
# When a release tag is pushed, update the matching short
# version tag, for example v2
update-tags:
runs-on: ubuntu-20.04
steps:
# Check out this repository at the same ref that triggered
# this workflow run
- uses: actions/checkout@v2
- name: Configure Git client
run: |
_user="${{ github.repository_owner }}"
_email="${_user}@users.noreply.github.com"
git config user.name "${_user}"
git config user.email "${_email}"
# Update short version tag, for example v2
- name: Update major version tag
id: roll-tag
run: |
# Set up variables.
_tag="${INPUT_TAG:-${GITHUB_REF#refs/tags/}}" # v2.2.0
_major="${_tag%%.*}" # v2
_msg="Release ${_tag}"
_curr="$(GITHUB_TOKEN=${{ github.token }} \
gh api /repos/:owner/:repo/releases/latest | \
jq -r .tag_name)"
# If tag pushed is not for latest release, exit early
if [ "$_tag" != "$_curr" ]; then
echo "SKIP: Tag pushed ($_tag) is not for latest release."
exit 0
fi
# Update _major tag
git tag -fa "${_major}" -m "${_msg}"
# Push _major tag
git push --force origin "${_major}"