From 17d97e13c01246092bc702d7e81d15b88eae9192 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Fri, 17 Jul 2020 22:34:11 +0300 Subject: [PATCH] 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. --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4e87f2..23c8256 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,13 @@ jobs: steps: - id: calver if: ${{ !github.event.client_payload.version }} - run: echo "::set-output name=version::$(date +'%y.%-m.0')" + run: | + DATE_PART=$(date +'%y.%-m') + PATCH_VERSION=0 + while curl -sf -o /dev/null "https://api.github.com/repos/$GITHUB_REPOSITORY/git/ref/tags/$DATE_PART.$PATCH_VERSION"; do + (( PATCH_VERSION++ )) + done + echo "::set-output name=version::"$DATE_PART.$PATCH_VERSION"" - uses: actions/checkout@v2 - uses: getsentry/craft@master if: ${{ !github.event.client_payload.skip_prepare }}