add release action

This commit is contained in:
nrslib 2026-02-05 17:43:15 +09:00
parent 0d36b08f96
commit 14d30b1895
2 changed files with 39 additions and 1 deletions

28
.github/workflows/auto-tag.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Auto Tag on Release PR Merge
on:
pull_request:
types: [closed]
branches: [main]
jobs:
tag:
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.title, 'Release v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract version from PR title
id: version
run: |
VERSION=$(echo "${{ github.event.pull_request.title }}" | sed 's/^Release //')
echo "tag=$VERSION" >> "$GITHUB_OUTPUT"
- name: Create and push tag
run: |
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"

View File

@ -19,6 +19,16 @@ jobs:
- run: npm ci
- run: npm run build
- run: npm test
- run: npm publish
- name: Determine npm tag
id: npm-tag
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
if echo "$VERSION" | grep -qE '(alpha|beta|rc|next)'; then
echo "tag=next" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi
- run: npm publish --tag ${{ steps.npm-tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}