Skip to content

Fix module resolution for node bundling (#3) #2

Fix module resolution for node bundling (#3)

Fix module resolution for node bundling (#3) #2

Workflow file for this run

name: Auto Tag on Version Change
on:
push:
branches: [main]
paths:
- 'package.json'
permissions:
contents: write
jobs:
auto-tag:
name: Create Tag on Version Change
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2 # Need previous commit to compare
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Get current version from package.json
id: current-version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=v$VERSION" >> $GITHUB_OUTPUT
echo "Current version: v$VERSION"
- name: Get previous version from package.json
id: previous-version
run: |
PREV_VERSION=$(git show HEAD~1:package.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8')).version" 2>/dev/null || echo "0.0.0")
echo "previous=v$PREV_VERSION" >> $GITHUB_OUTPUT
echo "Previous version: v$PREV_VERSION"
- name: Check if version changed
id: version-changed
run: |
if [ "${{ steps.current-version.outputs.version }}" != "${{ steps.previous-version.outputs.previous }}" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "Version changed from ${{ steps.previous-version.outputs.previous }} to ${{ steps.current-version.outputs.version }}"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "Version unchanged: ${{ steps.current-version.outputs.version }}"
fi
- name: Check if tag already exists
id: tag-exists
if: steps.version-changed.outputs.changed == 'true'
run: |
if git rev-parse "${{ steps.current-version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag ${{ steps.current-version.outputs.version }} already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag ${{ steps.current-version.outputs.version }} does not exist"
fi
- name: Create and push tag
if: steps.version-changed.outputs.changed == 'true' && steps.tag-exists.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
TAG_NAME="${{ steps.current-version.outputs.version }}"
git tag -a "$TAG_NAME" -m "chore: release $TAG_NAME
Auto-generated tag from package.json version bump
Commit: ${{ github.sha }}
Triggered by: ${{ github.actor }}"
if git push origin "$TAG_NAME"; then
echo "✅ Successfully created and pushed tag: $TAG_NAME"
echo "🚀 Release workflow will be triggered automatically"
else
echo "❌ Failed to push tag: $TAG_NAME"
exit 1
fi
- name: Tag creation summary
run: |
echo "## 🏷️ Auto-Tag Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| **Current Version** | \`${{ steps.current-version.outputs.version }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| **Previous Version** | \`${{ steps.previous-version.outputs.previous }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| **Version Changed** | ${{ steps.version-changed.outputs.changed }} |" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.version-changed.outputs.changed }}" == "true" ]; then
echo "| **Tag Exists** | ${{ steps.tag-exists.outputs.exists }} |" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.tag-exists.outputs.exists }}" == "false" ]; then
echo "| **Action** | ✅ Created tag \`${{ steps.current-version.outputs.version }}\` |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🚀 Next Steps" >> $GITHUB_STEP_SUMMARY
echo "- Release workflow will be triggered automatically" >> $GITHUB_STEP_SUMMARY
echo "- Monitor the [Release & Publish workflow](../actions/workflows/release.yml)" >> $GITHUB_STEP_SUMMARY
else
echo "| **Action** | ⏭️ Skipped (tag already exists) |" >> $GITHUB_STEP_SUMMARY
fi
else
echo "| **Action** | ⏭️ Skipped (no version change) |" >> $GITHUB_STEP_SUMMARY
fi