Skip to content
Merged
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
16 changes: 14 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
Expand All @@ -21,6 +22,7 @@ jobs:
run: |
PKG_NAME=$(node -p "require('./package.json').name")
PKG_VERSION=$(node -p "require('./package.json').version")
echo "version=${PKG_VERSION}" >> "$GITHUB_OUTPUT"
if npm view "${PKG_NAME}@${PKG_VERSION}" version 2>/dev/null; then
echo "published=true" >> "$GITHUB_OUTPUT"
else
Expand All @@ -34,10 +36,20 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Ensure git tag exists
if: steps.check.outputs.published == 'false'
run: |
TAG="v${{ steps.check.outputs.version }}"
if ! git rev-parse "${TAG}" >/dev/null 2>&1; then
git tag "${TAG}"
git push origin "${TAG}"
fi

- name: Create GitHub Release
if: steps.check.outputs.published == 'false'
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
gh release create "v${PKG_VERSION}" --generate-notes --title "v${PKG_VERSION}"
TAG="v${{ steps.check.outputs.version }}"
# --verify-tag ensures the tag exists before creating the release
gh release create "${TAG}" --generate-notes --title "${TAG}" --verify-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/unreleased-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Unreleased Changes Check
on:
push:
branches: [main]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }

- name: Check for unreleased source changes
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
TAG="v${PKG_VERSION}"

# If the tag doesn't exist yet, this is the release commit itself — skip
if ! git rev-parse "${TAG}" >/dev/null 2>&1; then
echo "Tag ${TAG} not found — this push likely IS the release. Skipping."
exit 0
fi

# Count source-file commits since the last release tag
UNRELEASED=$(git log "${TAG}..HEAD" --oneline -- 'src/' | wc -l | tr -d ' ')

if [ "$UNRELEASED" -gt 0 ]; then
echo "::warning::${UNRELEASED} source commits on main since ${TAG} — version has not been bumped."
echo ""
echo "Unreleased commits:"
git log "${TAG}..HEAD" --oneline -- 'src/'
echo ""
echo "Run: bump package.json version, update CHANGELOG.md, push to trigger publish."
else
echo "No unreleased source changes since ${TAG}."
fi
Loading