Skip to content

2.1.7

2.1.7 #10

Workflow file for this run

name: Tag Major Version
on:
push:
tags: [v*.*.*]
permissions:
contents: write
jobs:
update-major-version-tag:
name: Update major version tag
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Get major version
id: major-version
run: |
VERSION=${GITHUB_REF#refs/tags/}
MAJOR=${VERSION%%.*}
echo "sha=$(git rev-list -n 1 $VERSION)" >> $GITHUB_OUTPUT
echo "major=$MAJOR" >> $GITHUB_OUTPUT
- name: Find major tag
id: major-tag
uses: actions/github-script@v7
with:
result-encoding: string
script: |
try {
await github.rest.git.getRef({
...context.repo,
ref: "tags/${{ steps.major-version.outputs.major }}"
});
return "1";
}
catch (err) {
if (err.status === 404)
return "0";
throw err;
}
- name: Create major version tag
if: steps.major-tag.outputs.result == '0'
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
...context.repo,
ref: "refs/tags/${{ steps.major-version.outputs.major }}",
sha: "${{ steps.major-version.outputs.sha }}"
})
- name: Move major version tag
if: steps.major-tag.outputs.result == '1'
uses: actions/github-script@v7
with:
script: |
github.rest.git.updateRef({
...context.repo,
ref: "tags/${{ steps.major-version.outputs.major }}",
sha: "${{ steps.major-version.outputs.sha }}",
force: true
})