diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 89df385..98c9a13 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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"