v0.2.2 #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Major Tag | |
on: | |
release: | |
types: [published] | |
permissions: | |
contents: write | |
jobs: | |
create-major-tag: | |
name: major tag creation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get major version | |
id: version | |
run: | | |
MAJOR=$(echo ${{ github.ref_name }} | cut -d'.' -f1 | cut -c2-) | |
echo "major=$MAJOR" >> $GITHUB_OUTPUT | |
- name: Delete existing tag | |
continue-on-error: true | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
await github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `tags/v${{ steps.version.outputs.major }}`, | |
}); | |
- name: Create tag | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const newTag = "v${{ steps.version.outputs.major }}"; | |
const createdTag = await github.rest.git.createTag({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag: newTag, | |
message: "Moving pointer to ${{ github.ref_name }}", | |
object: "${{ github.sha }}", | |
type: "commit", | |
}); | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${newTag}`, | |
sha: createdTag.data.sha | |
}); |