Skip to content

chore: add apexgantt as devDependency and regenerate lock file with r… #5

chore: add apexgantt as devDependency and regenerate lock file with r…

chore: add apexgantt as devDependency and regenerate lock file with r… #5

Workflow file for this run

name: Publish to npm
on:
push:
branches:
- main
permissions:
id-token: write
contents: write
jobs:
publish:
runs-on: ubuntu-latest
if: startsWith(github.event.head_commit.message, 'release:')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check commit message and extract version
id: check
run: |
MSG="${{ github.event.head_commit.message }}"
if echo "$MSG" | grep -qE '^release: [0-9]+\.[0-9]+\.[0-9]+'; then
VERSION=$(echo "$MSG" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+[^ ]*' | head -1)
echo "version=$VERSION" >> $GITHUB_OUTPUT
if echo "$VERSION" | grep -qE '[-]'; then
echo "tag=next" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
fi
else
echo "❌ Commit message must match 'release: X.Y.Z'"
exit 1
fi
- name: Verify package.json version matches commit message
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
MSG_VERSION="${{ steps.check.outputs.version }}"
if [ "$PKG_VERSION" != "$MSG_VERSION" ]; then
echo "❌ package.json version ($PKG_VERSION) does not match commit message version ($MSG_VERSION)"
exit 1
fi
echo "✅ Version $PKG_VERSION confirmed"
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install -g npm@latest
- run: npm install
- run: npm run build
- name: Publish to npm
run: npm publish --provenance --tag ${{ steps.check.outputs.tag }}
- name: Create git tag
run: |
TAG="v${{ steps.check.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
else
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ steps.check.outputs.version }}"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists, skipping"
else
gh release create "$TAG" --generate-notes --title "$TAG"
fi