Skip to content

Commit 9d59f39

Browse files
committed
using mathieudutour for releases on release workflow
1 parent 09fc4dc commit 9d59f39

File tree

1 file changed

+14
-66
lines changed

1 file changed

+14
-66
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,75 +8,23 @@ on:
88
jobs:
99
release:
1010
runs-on: ubuntu-latest
11-
11+
permissions:
12+
contents: write # Added permission to allow pushing the tag
1213
steps:
1314
- name: Checkout repository
1415
uses: actions/checkout@v3
1516

16-
- name: Set up Git
17-
run: |
18-
git config --global user.name "${{ secrets.GIT_USER_NAME }}"
19-
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
20-
21-
- name: Determine version strategy
22-
id: determine_version
23-
run: |
24-
# Check if there are any tags
25-
tag_count=$(git tag -l | wc -l)
26-
if [ "$tag_count" -eq 0 ]; then
27-
# No tags, start with initial version
28-
major=0
29-
minor=1
30-
patch=0
31-
new_tag="v$major.$minor.$patch"
32-
else
33-
# Tags exist, use existing strategy
34-
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
35-
echo "Latest tag: $latest_tag"
36-
37-
IFS='.' read -r -a parts <<< "${latest_tag//v/}"
38-
major=${parts[0]}
39-
minor=${parts[1]}
40-
patch=${parts[2]}
41-
42-
# Increment the patch version
43-
new_patch=$((patch + 1))
44-
new_tag="v$major.$minor.$new_patch"
45-
fi
46-
47-
echo "New tag: $new_tag"
48-
echo "new_tag=$new_tag" >> $GITHUB_ENV
49-
50-
- name: Check if tag exists and increment if necessary
51-
id: tag_check
52-
run: |
53-
while git rev-parse "refs/tags/${{ env.new_tag }}" >/dev/null 2>&1; do
54-
echo "Tag ${{ env.new_tag }} already exists."
55-
56-
IFS='.' read -r -a parts <<< "${new_tag//v/}"
57-
major=${parts[0]}
58-
minor=${parts[1]}
59-
patch=${parts[2]}
60-
new_patch=$((patch + 1))
61-
new_tag="v$major.$minor.$new_patch"
62-
echo "New incremented tag: $new_tag"
63-
done
64-
65-
echo "Final new tag: $new_tag"
66-
echo "new_tag=$new_tag" >> $GITHUB_ENV
67-
68-
- name: Create new tag
69-
run: |
70-
git tag "${{ env.new_tag }}"
71-
git push origin "${{ env.new_tag }}"
17+
- name: Bump version and tag
18+
id: tag_version
19+
uses: mathieudutour/github-tag-action@v6.1 # More robust tag/release action
20+
with:
21+
github_token: ${{ secrets.GITHUB_TOKEN }}
22+
default_bump: patch # Start with patch, customizable with inputs
7223

73-
- name: Create GitHub release
74-
uses: actions/create-release@v1
75-
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Create GitHub Release
25+
uses: softprops/action-gh-release@v1 # Alternative release action
7726
with:
78-
tag_name: ${{ env.new_tag }}
79-
release_name: ${{ env.new_tag }}
80-
body: "Automated release for tag ${{ env.new_tag }}"
81-
draft: false
82-
prerelease: false
27+
body: Automated release for tag ${{ steps.tag_version.outputs.new_tag }}
28+
files: | # Optionally attach release artifacts (e.g., binaries)
29+
path/to/your/artifacts/*
30+
prerelease: ${{ steps.tag_version.outputs.tag == 'pre' }}

0 commit comments

Comments
 (0)