Skip to content

Commit e6190ab

Browse files
authored
Fix: workflow (again)? (#67)
fix: workflow (again)?
1 parent bfd32b7 commit e6190ab

1 file changed

Lines changed: 27 additions & 18 deletions

File tree

.github/workflows/main.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19+
# Checkout full history
1920
- name: Checkout repository
2021
uses: actions/checkout@v4
2122
with:
2223
fetch-depth: 0
2324

24-
# Ensure merge came from development
25+
# Ensure the merge came from development
2526
- name: Ensure merge came from development
2627
id: check_merge
2728
run: |
@@ -33,51 +34,59 @@ jobs:
3334
echo "merged=false" >> $GITHUB_OUTPUT
3435
fi
3536
37+
# Stop workflow if not a development merge
3638
- name: Stop if not a development merge
3739
if: steps.check_merge.outputs.merged != 'true'
3840
run: |
3941
echo "Not a development merge. Skipping."
4042
exit 0
4143
44+
# Setup Node
4245
- name: Setup Node
4346
uses: actions/setup-node@v4
4447
with:
4548
node-version: 22
4649

47-
# Build / format / lint
48-
- run: npm install
50+
# Build / format / lint
51+
- run: npm ci
4952
- run: npm run format
5053
- run: npm run lint
5154
- run: npm run build
5255

53-
# Detect bump type from commit message
56+
# Detect version bump type from commit title or body
5457
- name: Detect version bump type
5558
id: bump_type
5659
run: |
57-
COMMIT_MSG=$(git log -1 --pretty=%B)
60+
COMMIT_TITLE=$(git log -1 --pretty=%s)
61+
COMMIT_BODY=$(git log -1 --pretty=%B)
62+
COMMIT_MSG="$COMMIT_TITLE"$'\n'"$COMMIT_BODY"
63+
5864
if echo "$COMMIT_MSG" | grep -qi "^refactor:"; then
59-
echo "type=major" >> $GITHUB_OUTPUT
65+
BUMP_TYPE="major"
6066
elif echo "$COMMIT_MSG" | grep -qi "^feat:"; then
61-
echo "type=minor" >> $GITHUB_OUTPUT
67+
BUMP_TYPE="minor"
6268
elif echo "$COMMIT_MSG" | grep -qi "^fix:"; then
63-
echo "type=patch" >> $GITHUB_OUTPUT
69+
BUMP_TYPE="patch"
6470
else
65-
echo "type=patch" >> $GITHUB_OUTPUT
71+
BUMP_TYPE="patch"
6672
fi
6773
68-
# ✅ Bump version locally and create a tag (do NOT commit to master)
69-
- name: Bump version and create tag
74+
echo "type=$BUMP_TYPE" >> $GITHUB_OUTPUT
75+
76+
# Bump version locally without committing (avoids dirty working dir errors)
77+
- name: Bump version locally
7078
id: version
7179
run: |
72-
# bump version locally and create tag
73-
NEW_VERSION=$(npm version ${{ steps.bump_type.outputs.type }} -m "release: %s")
80+
NEW_VERSION=$(npm version ${{ steps.bump_type.outputs.type }} --no-git-tag-version)
7481
echo "version=${NEW_VERSION#v}" >> $GITHUB_OUTPUT
7582
76-
# ✅ Push tag only (safe for protected branch)
77-
- name: Push tag
78-
run: git push origin --tags
83+
# Create and push tag only (safe for protected branch)
84+
- name: Create and push tag
85+
run: |
86+
git tag v${{ steps.version.outputs.version }}
87+
git push origin v${{ steps.version.outputs.version }}
7988
80-
# Create GitHub Release
89+
# Create GitHub Release
8190
- name: Create GitHub Release
8291
uses: softprops/action-gh-release@v2
8392
with:
@@ -86,6 +95,6 @@ jobs:
8695
env:
8796
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8897

89-
# Publish to npm
98+
# Publish to npm
9099
- name: Publish to npm
91100
run: npm publish --provenance --access public

0 commit comments

Comments
 (0)