Skip to content
Open
Show file tree
Hide file tree
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
20 changes: 2 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: Publish Package

on:
workflow_run:
workflows:
- "Manual release"
types:
- completed
# optionally also respond to manual release events (fallback)
release:
types: [published]

Expand All @@ -16,10 +10,7 @@ permissions:

jobs:
publish:
# Only run when the release workflow completed successfully and produced a tag starting with "v"
if: >-
${{ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
(github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v')) }}
if: startsWith(github.event.release.tag_name, 'v')
runs-on: ubuntu-latest

steps:
Expand All @@ -30,14 +21,7 @@ jobs:
- name: Resolve tag to publish
id: tag
run: |
# Prefer the release tag if available; otherwise try to read from workflow_run head_branch/ref
if [ "${{ github.event_name }}" = "release" ]; then
echo "tag=${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
else
# for a workflow_run we can try to use the ref from the completed run (head_branch/head_sha)
# adjust logic here to extract the correct tag if your release.yml sets outputs or artifacts
echo "tag=${GITHUB_REF#refs/tags/}" >>"$GITHUB_OUTPUT" || true
fi
echo "tag=${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"

- name: Setup Node.js
uses: actions/setup-node@v6
Expand Down
33 changes: 31 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:

jobs:
release:
name: Run commit-and-tag-version and push to main
name: Run commit-and-tag-version, push to main, and create GitHub release
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -44,4 +44,33 @@ jobs:
# After the tool creates the new version commit and tag locally, push commit and tags to main.
# Ensure we push HEAD to main in case the workflow is running from a different ref.
echo "Pushing commit and tags to main..."
git push origin HEAD:main --follow-tags
git push origin HEAD:main --follow-tags

- name: Resolve release tag and notes
id: release
run: |
tag="v$(node -p "JSON.parse(require('fs').readFileSync('package.json', 'utf8')).version")"
version="${tag#v}"

awk -v version="$version" '
$0 ~ "^## \\[" version "\\]" { in_section=1; next }
in_section && $0 ~ "^## \\[" { exit }
in_section { print }
' CHANGELOG.md > RELEASE_NOTES.md

if [ ! -s RELEASE_NOTES.md ]; then
printf 'Release %s\n' "$tag" > RELEASE_NOTES.md
fi

echo "tag=$tag" >>"$GITHUB_OUTPUT"

- name: Create or update GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.release.outputs.tag }}
run: |
if gh release view "$TAG" >/dev/null 2>&1; then
gh release edit "$TAG" --title "$TAG" --notes-file RELEASE_NOTES.md
else
gh release create "$TAG" --title "$TAG" --notes-file RELEASE_NOTES.md
fi
Loading