forked from jbergstroem/hadolint-gh-action
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (48 loc) · 1.68 KB
/
pre-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Rolling release
on:
push:
tags:
- "v*.*.*"
permissions: write-all
jobs:
automate-tagging:
name: "Perform rolling release"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Configure git"
run: |
git config user.name github-actions
git config user.email [email protected]
- name: "Decompose tag into components"
run: |
if [[ ${{ github.ref_name }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Split the tag into its components
IFS='.' read -ra PARTS <<< "${{ github.ref_name }}"
echo "X=${PARTS[0]}" >> $GITHUB_ENV
echo "Y=${PARTS[1]}" >> $GITHUB_ENV
echo "Z=${PARTS[2]}" >> $GITHUB_ENV
else
echo "Invalid tag format. Expected vX.Y.Z but got ${{ github.ref_name }}"
exit 1
fi
- name: "Verify tag was created in the proper release branch"
run: |
# Remove leading "v" from env.X
X_NO_V="${X:1}"
# Check if the tag was created in the proper branch
if [[ ${{ github.event.base_ref }} != "refs/heads/release/${X_NO_V}.${{ env.Y }}" ]]; then
echo "Tag ${{ github.ref_name }} was created in the wrong branch. Expected branch name release/${X_NO_V}.${{ env.Y }}"
exit 1
fi
- name: "Remove old tags"
run: |
git push --delete origin ${{ env.X }}
git push --delete origin ${{ env.X }}.${{ env.Y }}
- name: "Create new tags"
run: |
git tag ${{ env.X }}.${{ env.Y }}
git tag ${{ env.X }}
git push origin ${{ env.X }}.${{ env.Y }}
git push origin ${{ env.X }}