chore: Release v0.0.1-alpha.8 (#246) #2
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: Tag on SemVer Commit | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
create_tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Extract SemVer using Node.js | |
id: extract_semver | |
run: | | |
node -e ' | |
const execSync = require("child_process").execSync; | |
const fs = require("fs"); | |
const commitMessage = execSync("git log -1 --pretty=%B").toString("utf-8"); | |
const semverRegex = /chore: Release (v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-.]+)?)/; | |
const match = commitMessage.match(semverRegex); | |
if (match) { | |
fs.appendFileSync(process.env.GITHUB_ENV, `tag_version=${match[1]}\n`); | |
} else { | |
console.log("No SemVer found in commit body."); | |
process.exit(0); | |
} | |
' | |
- name: Create a new tag | |
if: ${{ env.tag_version }} | |
run: | | |
git tag ${{ env.tag_version }} | |
git push origin ${{ env.tag_version }} | |
- name: Trigger Build Workflow | |
if: ${{ env.tag_version }} | |
run: | | |
curl -X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches \ | |
-d '{"ref":"main", "inputs": {"tag_version": "${{ env.tag_version }}"}}' |