-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (45 loc) · 1.48 KB
/
staging-create-tag.yaml
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
56
57
name: Create Staging Tag
on:
push:
branches:
- staging
jobs:
increment-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: 0
- name: Set up Git
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
- name: Get the latest staging tag
id: get_latest_tag
run: |
latest_tag=$(git tag --list --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-staging$' | head -n 1)
echo "Latest Tag: $latest_tag"
echo "::set-output name=latest_tag::$latest_tag"
- name: Increment the tag
id: increment_tag
run: |
latest_tag=${{ steps.get_latest_tag.outputs.latest_tag }}
if [ -z "$latest_tag" ]; then
echo "No matching tags found. test"
exit 1
fi
# Extract the major, minor, patch versions
IFS='.-' read -r major minor patch _ <<< "$latest_tag"
# Increment the patch version
patch=$((patch + 1))
# Construct the new tag
new_tag="$major.$minor.$patch-staging"
echo "New Tag: $new_tag"
echo "::set-output name=new_tag::$new_tag"
- name: Create and push new tag
run: |
new_tag=${{ steps.increment_tag.outputs.new_tag }}
git tag "$new_tag"
git push origin "$new_tag"