Skip to content

Commit

Permalink
Add Actions workflow to automatically create release tags (#1439)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
dschuff authored Aug 23, 2024
1 parent f010ca9 commit d09b3c3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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`)
}

0 comments on commit d09b3c3

Please sign in to comment.