Skip to content

Commit d09b3c3

Browse files
authored
Add Actions workflow to automatically create release tags (#1439)
For commits created by the new create-release.yml workflow, we can add the corresponding release tag. This only runs for changes to the tag JSON file (and the workflow itself) and only acts on changes created by the automation (so that it won't interfere if we want to do things manually).
1 parent f010ca9 commit d09b3c3

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

.github/workflows/tag-release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# When a release commit created by create-release.yml is landed, create the
2+
# corresponding tag.
3+
name: Create release tag
4+
5+
on:
6+
push:
7+
paths: [ emscripten-releases-tags.json, .github/workflows/tag-release.yml ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
tag-release:
12+
# Only activate for commits created by the create-release.yml workflow.
13+
# The assumption is that when manual changes happen, we want to handle
14+
# tagging manually too.
15+
if: github.event.head_commit.author.username == 'github-actions[bot]'
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Match message and create tag
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const message = `${{ github.event.head_commit.message }}`
23+
const regex = /Release ([0-9]+.[0-9]+.[0-9]+)/
24+
const match = message.match(regex)
25+
if (match) {
26+
const release = match[1]
27+
console.log(`Matched release ${release}`)
28+
await github.rest.git.createRef({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
ref: `refs/tags/${release}`,
32+
sha: context.sha
33+
})
34+
} else {
35+
console.log(`Commit message: ${message} did not match pattern`)
36+
}

0 commit comments

Comments
 (0)