dsebastien_obsidian-graph-e.../.github/workflows/release.yml
Sebastien 0bbebd63dd ci(release): bump action-gh-release to v3 and make attestation non-blocking
action-gh-release@v3 runs on Node 24 (GitHub deprecates Node 20 actions
on 2026-06-16). Mark the attestation step continue-on-error so a Sigstore
Rekor timeout can no longer skip publishing the release.
2026-06-09 11:00:48 +02:00

137 lines
5.1 KiB
YAML

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.2.3)'
required: true
type: string
push:
tags:
- '*.*.*'
permissions:
contents: write
id-token: write
attestations: write
jobs:
release:
runs-on: ubuntu-slim
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Setup Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Determine version and branch
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
BRANCH="${{ github.ref_name }}"
else
# Triggered by tag push
VERSION="${{ github.ref_name }}"
# Find the branch that contains this tag
BRANCH=$(git branch -r --contains ${{ github.ref }} | grep -v HEAD | head -1 | sed 's/.*\///')
if [ -z "$BRANCH" ]; then
BRANCH="main"
fi
fi
# Strip 'v' prefix if present (for backwards compatibility)
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Tag WITHOUT 'v' prefix per Obsidian plugin spec
echo "tag=$VERSION" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
echo "Target branch: $BRANCH"
- name: Checkout branch (when triggered by tag)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
git checkout ${{ steps.version.outputs.branch }}
git pull origin ${{ steps.version.outputs.branch }}
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Update package.json version
run: bun run release:update-version ${{ steps.version.outputs.version }}
- name: Update manifest and versions.json
run: |
export npm_package_version=${{ steps.version.outputs.version }}
bun run release:version-bump
- name: Build for production
run: bun run build
- name: Generate changelog
run: bun run release:changelog
- name: Log changelog
run: |
echo "=== Changelog for ${{ steps.version.outputs.version }} ==="
head -100 CHANGELOG.md
- name: Format code
run: bun run format
- name: Commit release changes
run: |
git add package.json versions.json manifest.json CHANGELOG.md docs/release-notes.md
git commit -m "chore(release): ${{ steps.version.outputs.version }}" || echo "No changes to commit"
git push origin HEAD:${{ steps.version.outputs.branch }}
- name: Create and push tag (manual trigger only)
if: github.event_name == 'workflow_dispatch'
run: |
git tag -a ${{ steps.version.outputs.tag }} -m "Release ${{ steps.version.outputs.version }}"
git push origin ${{ steps.version.outputs.tag }}
- name: Extract changelog for release notes
id: changelog
run: |
# Extract the latest version section from CHANGELOG.md
NOTES=$(awk '/^## \[?[0-9]/{if(p) exit; p=1} p' CHANGELOG.md)
# Handle multi-line output
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Generate artifact attestations
uses: actions/attest-build-provenance@v3
continue-on-error: true
with:
subject-path: |
dist/main.js
dist/manifest.json
dist/styles.css
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.version }}
body: ${{ steps.changelog.outputs.notes }}
files: |
dist/main.js
dist/manifest.json
dist/styles.css
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}