Skip to content

Commit ef74eae

Browse files
chore: add checks
Signed-off-by: Joris Mancini <[email protected]>
1 parent 919a7aa commit ef74eae

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/workflows/patch.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ jobs:
2929
fetch-depth: 0
3030
token: ${{ steps.app-token.outputs.token }}
3131

32+
- name: Extract tag versions
33+
run: |
34+
regex="^v([0-9]+).([0-9]+)$"
35+
if [[ ${{ github.event.inputs.releaseVersion }} =~ $regex ]]
36+
then
37+
echo Release version matches vX.X format
38+
else
39+
echo ERROR: release version should match the format vX.X
40+
exit 1
41+
fi
42+
43+
- name: Check if release already exists
44+
run: |
45+
if git ls-remote --quiet --exit-code origin refs/heads/release/${{ github.event.inputs.releaseVersion }} >/dev/null 2>&1
46+
then
47+
echo "Release ${{ github.event.inputs.releaseVersion }} already exists, patch will be perfomed"
48+
else
49+
echo "Release ${{ github.event.inputs.releaseVersion }} doesn't exist, patch cannot be performed"
50+
exit 1
51+
fi
52+
3253
- name: Checkout on existing release branch
3354
run: |
3455
git checkout release/${{ github.event.inputs.releaseVersion }}

.github/workflows/release.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,25 @@ jobs:
3434

3535
- name: Extract tag versions
3636
run: |
37-
regex="v([0-9]+).([0-9]+)"
37+
regex="^v([0-9]+).([0-9]+)$"
3838
if [[ ${{ github.event.inputs.releaseVersion }} =~ $regex ]]
3939
then
4040
echo "GITHUB_MAJOR_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
4141
echo "GITHUB_MINOR_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
4242
echo "GITHUB_SHORT_VERSION=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0" >> $GITHUB_ENV
43+
else
44+
echo ERROR: release version should match the format vX.X
45+
exit 1
46+
fi
47+
48+
- name: Check if release already exists
49+
run: |
50+
if git ls-remote --quiet --exit-code origin refs/heads/release/${{ github.event.inputs.releaseVersion }} >/dev/null 2>&1
51+
then
52+
echo "ERROR: Release ${{ github.event.inputs.releaseVersion }} already exists"
53+
exit 1
54+
else
55+
echo "Release ${{ github.event.inputs.releaseVersion }} doesn't exist, it will be performed"
4356
fi
4457
4558
- name: Checkout with new branch

0 commit comments

Comments
 (0)