Skip to content

Commit c2587e2

Browse files
authored
Update auto_release.yml
1 parent 545d353 commit c2587e2

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

.github/workflows/auto_release.yml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,43 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616
with:
17-
fetch-depth: 0 # Needed to fetch all tags
17+
fetch-depth: 0
1818

1919
- name: Get PR labels
2020
id: labels
2121
run: |
22-
echo "LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
22+
LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
2323
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
24-
| jq -r '.[].name' | tr '\n' ' ')" >> $GITHUB_OUTPUT
24+
| jq -r '.[].name' | tr '\n' ' ')
25+
echo "labels=$LABELS" >> $GITHUB_OUTPUT
2526
2627
- name: Determine bump type
2728
id: bump
2829
run: |
29-
LABELS="${{ steps.labels.outputs.LABELS }}"
30+
LABELS="${{ steps.labels.outputs.labels }}"
3031
if [[ "$LABELS" == *"feature"* ]]; then
31-
echo "BUMP=X" >> $GITHUB_OUTPUT
32+
echo "bump=X" >> $GITHUB_OUTPUT
3233
elif [[ "$LABELS" == *"bug"* ]]; then
33-
echo "BUMP=Y" >> $GITHUB_OUTPUT
34+
echo "bump=Y" >> $GITHUB_OUTPUT
3435
else
35-
echo "BUMP=Z" >> $GITHUB_OUTPUT
36+
echo "bump=Z" >> $GITHUB_OUTPUT
3637
fi
3738
38-
- name: 'Get Previous tag'
39+
- name: Get previous tag
3940
id: current_version
40-
uses: "WyriHaximus/github-action-get-previous-tag@v1"
41+
uses: WyriHaximus/github-action-get-previous-tag@v1
4142

4243
- name: Bump version
4344
id: bump_version
4445
run: |
45-
IFS='.' read -r X Y Z <<< "${{ steps.current_version.outputs.version }}"
46-
bump="${{ steps.bump.outputs.BUMP }}"
46+
VERSION="${{ steps.current_version.outputs.tag }}"
47+
VERSION="${VERSION#v}" # Remove leading 'v' if exists
48+
IFS='.' read -r X Y Z <<< "$VERSION"
49+
BUMP="${{ steps.bump.outputs.bump }}"
4750
48-
if [[ "$bump" == "X" ]]; then
51+
if [[ "$BUMP" == "X" ]]; then
4952
X=$((X + 1)); Y=0; Z=0
50-
elif [[ "$bump" == "Y" ]]; then
53+
elif [[ "$BUMP" == "Y" ]]; then
5154
Y=$((Y + 1)); Z=0
5255
else
5356
Z=$((Z + 1))
@@ -57,18 +60,16 @@ jobs:
5760
fi
5861
fi
5962
60-
new_version="$X.$Y.$Z"
61-
echo "new_version=$new_version" >> $GITHUB_OUTPUT
62-
echo "Bumped to $new_version"
63+
NEW_VERSION="v$X.$Y.$Z"
64+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
65+
echo "Bumped to $NEW_VERSION"
6366
64-
- name: Create Git tag and push
67+
- name: "Create release"
6568
run: |
66-
git config user.name "github-actions"
67-
git config user.email "[email protected]"
68-
git tag ${{ steps.bump_version.outputs.new_version }}
69-
git push origin ${{ steps.bump_version.outputs.new_version }}
69+
echo "$base_branch"
7070
71-
- name: Create GitHub Release
72-
uses: softprops/action-gh-release@v2
73-
with:
74-
tag_name: ${{ steps.bump_version.outputs.new_version }}
71+
gh release create ${{ steps.bump_version.outputs.new_version }} \
72+
--title ${{ steps.bump_version.outputs.new_version }} \
73+
--target ${{ steps.bump_version.outputs.new_version }}
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)