Skip to content

Commit c7d4140

Browse files
committed
fix: test new version bump method.
1 parent ff2ae0b commit c7d4140

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

.github/workflows/tag-version.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ on:
99
jobs:
1010
tag-version:
1111
runs-on: ubuntu-latest
12-
12+
permissions:
13+
contents: write # This allows pushing tags and commits
1314
steps:
1415
- name: Checkout code
1516
uses: actions/checkout@v4
1617
with:
18+
# Fetch all history and tags
1719
fetch-depth: 0
20+
persist-credentials: true
1821
token: ${{ secrets.GITHUB_TOKEN }}
1922

2023
- name: Get latest version from tags
@@ -45,9 +48,20 @@ jobs:
4548
MINOR="${VERSION_PARTS[1]}"
4649
PATCH="${VERSION_PARTS[2]}"
4750
48-
# Increment patch version
49-
NEW_PATCH=$((PATCH + 1))
50-
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
51+
# Check recent commits for version bump indicators
52+
if git log --oneline -10 | grep -q "\[major\]"; then
53+
echo "Major version bump detected"
54+
NEW_MAJOR=$((MAJOR + 1))
55+
NEW_VERSION="$NEW_MAJOR.0.0"
56+
elif git log --oneline -10 | grep -q "\[minor\]"; then
57+
echo "Minor version bump detected"
58+
NEW_MINOR=$((MINOR + 1))
59+
NEW_VERSION="$MAJOR.$NEW_MINOR.0"
60+
else
61+
echo "Patch version bump (default)"
62+
NEW_PATCH=$((PATCH + 1))
63+
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
64+
fi
5165
5266
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
5367
echo "New version: $NEW_VERSION"
@@ -58,24 +72,23 @@ jobs:
5872
npm version $NEW_VERSION --no-git-tag-version
5973
echo "Updated package.json to version $NEW_VERSION"
6074
61-
- name: Configure Git
75+
- name: Version bump and push tag
6276
run: |
63-
git config --local user.email "[email protected]"
64-
git config --local user.name "GitHub Action"
77+
# Configure git user
78+
git config --global user.name "GitHub Actions Bot"
79+
git config --global user.email "[email protected]"
6580
66-
- name: Commit and push changes
67-
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
run: |
81+
# Commit version changes
7082
git add package.json package-lock.json
7183
git commit -m "Bump version to ${{ steps.new-version.outputs.new_version }} [skip ci]" || echo "No changes to commit"
72-
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git main
7384
74-
- name: Create and push tag
75-
run: |
76-
NEW_VERSION="${{ steps.new-version.outputs.new_version }}"
77-
git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION"
78-
git push origin "v$NEW_VERSION"
85+
# Create and push tag
86+
git tag -a "v${{ steps.new-version.outputs.new_version }}" -m "Release version ${{ steps.new-version.outputs.new_version }}"
87+
88+
# Push changes and tag back to the repository
89+
git push --follow-tags
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7992

8093
- name: Create Release
8194
uses: actions/create-release@v1

0 commit comments

Comments
 (0)