Skip to content

Add Actions workflow to automatically create release tags (#1439) #1

Add Actions workflow to automatically create release tags (#1439)

Add Actions workflow to automatically create release tags (#1439) #1

Workflow file for this run

# When a release commit created by create-release.yml is landed, create the
# corresponding tag.
name: Create release tag
on:
push:
paths: [ emscripten-releases-tags.json, .github/workflows/tag-release.yml ]
workflow_dispatch:
jobs:
tag-release:
# Only activate for commits created by the create-release.yml workflow.
# The assumption is that when manual changes happen, we want to handle
# tagging manually too.
if: github.event.head_commit.author.username == 'github-actions[bot]'
runs-on: ubuntu-latest
steps:
- name: Match message and create tag
uses: actions/github-script@v7
with:
script: |
const message = `${{ github.event.head_commit.message }}`
const regex = /Release ([0-9]+.[0-9]+.[0-9]+)/
const match = message.match(regex)
if (match) {
const release = match[1]
console.log(`Matched release ${release}`)
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${release}`,
sha: context.sha
})
} else {
console.log(`Commit message: ${message} did not match pattern`)
}