Skip to content

Commit 17d97e1

Browse files
committed
ci(release): Smarter and safer auto version setting
If the release action is run without an explicit version in the same calendar month more than once, all of them will try to release the same version where the patch version is set to 0. This is never the intended action: if we are making a new release in the same month where an old one exists, it is 100% a patch release. This PR automatically implements patch version increment based on existing versions.
1 parent 094d8e3 commit 17d97e1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ jobs:
1414
steps:
1515
- id: calver
1616
if: ${{ !github.event.client_payload.version }}
17-
run: echo "::set-output name=version::$(date +'%y.%-m.0')"
17+
run: |
18+
DATE_PART=$(date +'%y.%-m')
19+
PATCH_VERSION=0
20+
while curl -sf -o /dev/null "https://api.github.com/repos/$GITHUB_REPOSITORY/git/ref/tags/$DATE_PART.$PATCH_VERSION"; do
21+
(( PATCH_VERSION++ ))
22+
done
23+
echo "::set-output name=version::"$DATE_PART.$PATCH_VERSION""
1824
- uses: actions/checkout@v2
1925
- uses: getsentry/craft@master
2026
if: ${{ !github.event.client_payload.skip_prepare }}

0 commit comments

Comments
 (0)