Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,50 @@ permissions:

jobs:
build:
name: Build dist and update tags
name: Build dist and finalize release
runs-on: ubuntu-latest
env:
TAG: ${{ github.event.release.tag_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.0
with:
ref: ${{ github.event.release.tag_name }}
- name: Build dist
uses: miguelcolmenares/npm-auto-build@8c22581033b30b631ff66f6c1b72fa3bdc2ea312 # v2.1.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
node-version: '24'
build-only: 'true'
- name: Commit dist to release tag
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run build

- name: Commit dist on top of the tag
run: |
git config user.name "github-actions[bot]"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -f dist/
git commit -m "build: compile dist for ${{ github.event.release.tag_name }}"
git push origin HEAD:refs/tags/${{ github.event.release.tag_name }} --force
git commit -m "build: compile dist for ${TAG}"
git push origin HEAD:refs/tags/${TAG} --force

- name: Recreate release pointing at dist commit
run: |
meta=$(gh release view "$TAG" --json name,body,isPrerelease)
name=$(echo "$meta" | jq -r '.name')
body=$(echo "$meta" | jq -r '.body')
prerelease=$(echo "$meta" | jq -r '.isPrerelease')

flags=()
[ "$prerelease" = "true" ] && flags+=(--prerelease)

gh release delete "$TAG" --yes --cleanup-tag=false
gh release create "$TAG" \
--title "$name" \
--notes "$body" \
--verify-tag \
"${flags[@]}"

- name: Update major version tag
run: |
TAG="${{ github.event.release.tag_name }}"
MAJOR=$(echo "$TAG" | grep -oE '^v[0-9]+')
if [ -n "$MAJOR" ]; then
git tag -f "$MAJOR"
Expand Down
Loading