-
Notifications
You must be signed in to change notification settings - Fork 191
41 lines (36 loc) · 1.28 KB
/
create-tag.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
name: Create release tag
on: workflow_dispatch
permissions:
contents: write
jobs:
tag:
name: Create tag
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Run tests
run: |
tag=$(bash scripts/generate-release-tag)
echo "generated-tag=$tag" >> $GITHUB_OUTPUT
id: generate_tag
- uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = '${{ steps.generate_tag.outputs.generated-tag }}'
const branch = '${{ github.ref_name }}'
try {
const resp = await github.rest.git.getRef({...context.repo, ref: `tags/${tag}`});
return core.setFailed(`the tag ${tag} already exists on ${resp.data.object.type} ${resp.data.object.sha}`);
} catch(err) {
if(err.status !== 404){
throw err;
}
}
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tag}`,
sha: context.sha
})