Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add major tag updater #50

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/UpdateFloatingTag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Update major version tag'

on:
release:
types: [created, published]

jobs:
# updates the floating tag alias for the major version.
release:
runs-on: 'ubuntu-latest'
steps:
- name: Parse higher semantic versions
id: semver
shell: bash
run: |
TAG="${{ github.ref_name }}"
MINOR="${TAG%.*}"
MAJOR="${MINOR%.*}"
echo "::set-output name=major::$(echo $MAJOR)"
echo "::set-output name=minor::$(echo $MINOR)"
- name: 'Update major version tag'
uses: 'actions/github-script@v5'
with:
script: |-
const sha = '${{ github.sha }}'
const major = '${{ steps.semver.outputs.major }}';
// Try to update the ref first. If that fails, it probably does not
// exist yet, and we should create it.
try {
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `tags/${major}`,
sha: sha,
force: true,
});
core.info(`Updated ${major} to ${sha}`);
} catch(err) {
core.warning(`Failed to create ${major}: ${err}`);
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${major}`,
sha: sha,
});
core.info(`Created ${major} at ${sha}`);
}