Skip to content

Flip "Unreleased" to "3.1.0" in docs/CHANGELOG.md #6

Flip "Unreleased" to "3.1.0" in docs/CHANGELOG.md

Flip "Unreleased" to "3.1.0" in docs/CHANGELOG.md #6

Workflow file for this run

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}"