Skip to content

Commit 6e50fd2

Browse files
Fix workflow again
1 parent 37c7a97 commit 6e50fd2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

.github/workflows/release-on-version-bump.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ jobs:
1515
runs-on: ubuntu-latest
1616
outputs:
1717
new_version: ${{ steps.extract.outputs.new_version }}
18-
last_commit_version: ${{ steps.extract.outputs.last_commit_version }}
18+
last_tag: ${{ steps.extract.outputs.last_tag }}
1919
prev_version: ${{ steps.extract.outputs.prev_version }}
2020
changelog: ${{ steps.extract.outputs.changelog }}
2121

2222
steps:
2323
- uses: actions/checkout@v4
24+
with:
25+
fetch-tags: true
2426

2527
- name: Extract versions
2628
id: version
@@ -35,17 +37,17 @@ jobs:
3537
line3=$(echo "${versions[2]}" | cut -d: -f1 || echo "\$")
3638
3739
new_version=$(echo "${versions[0]}" | sed -E 's/^.*##[[:space:]]*\[?([0-9]+\.[0-9]+\.[0-9]+)\]?.*/\1/')
38-
last_commit_version=$(echo "${versions[1]}" | sed -E 's/^.*##[[:space:]]*\[?([0-9]+\.[0-9]+\.[0-9]+)\]?.*/\1/')
39-
prev_version=$(git show ${{ steps.prev.outputs.sha }}:package.json | jq -r .version)
40+
prev_version=$(echo "${versions[1]}" | sed -E 's/^.*##[[:space:]]*\[?([0-9]+\.[0-9]+\.[0-9]+)\]?.*/\1/')
41+
last_tag=$(git tags | sort -V | tail -n 1)
4042
4143
changelog=$(sed -n "$line1,$((line2 - 1))p" CHANGELOG.md | tail -n +2)
4244
43-
echo "new_version=$new_version" | tee "$GITHUB_OUTPUT"
44-
echo "last_commit_version=$last_commit_version" | tee "$GITHUB_OUTPUT"
45-
echo "prev_version=$prev_version" | tee "$GITHUB_OUTPUT"
46-
echo "changelog<<EOF" | tee "$GITHUB_OUTPUT"
47-
echo "$changelog" | tee "$GITHUB_OUTPUT"
48-
echo "EOF" | tee "$GITHUB_OUTPUT"
45+
echo "new_version=$new_version" | tee --append "$GITHUB_OUTPUT"
46+
echo "last_tag=$last_tag" | tee --append "$GITHUB_OUTPUT"
47+
echo "prev_version=$prev_version" | tee --append "$GITHUB_OUTPUT"
48+
echo "changelog<<EOF" | tee --append "$GITHUB_OUTPUT"
49+
echo "$changelog" | tee --append "$GITHUB_OUTPUT"
50+
echo "EOF" | tee --append "$GITHUB_OUTPUT"
4951
5052
- name: Verify version matches package.json and package-lock.json
5153
run: |
@@ -71,7 +73,7 @@ jobs:
7173
echo "✅ Versions match"
7274
7375
- name: Create tag and release
74-
if: ${{ steps.version.outputs.new_version != steps.version.outputs.last_commit_version || github.event.inputs.force == 'true' }}
76+
if: steps.version.outputs.new_version != steps.version.outputs.last_tag || github.event.inputs.force == 'true'
7577
uses: softprops/action-gh-release@v1
7678
with:
7779
tag_name: v${{ steps.version.outputs.new_version }}

0 commit comments

Comments
 (0)