name: Release on: push: tags: ["v*"] jobs: release: name: Create Release runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v2 with: bun-version: latest - uses: actions/setup-node@v4 with: node-version: 20 registry-url: https://registry.npmjs.org - name: Install dependencies run: bun install --frozen-lockfile - name: Run tests run: bun test - name: Typecheck run: bun run typecheck - name: Build run: bun run build - name: Publish to npm run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Extract changelog id: changelog run: | VERSION="${GITHUB_REF_NAME#v}" # Extract the section for this version from CHANGELOG.md NOTES=$(awk "/^## \[${VERSION}\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md) # Write to file for gh release NOTES_FILE="${RUNNER_TEMP}/release-notes.md" echo "$NOTES" > "$NOTES_FILE" - name: Create GitHub Release run: | NOTES_FILE="${RUNNER_TEMP}/release-notes.md" if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then gh release edit "$GITHUB_REF_NAME" \ --title "$GITHUB_REF_NAME" \ --notes-file "$NOTES_FILE" else gh release create "$GITHUB_REF_NAME" \ --title "$GITHUB_REF_NAME" \ --notes-file "$NOTES_FILE" fi env: GH_TOKEN: ${{ github.token }}