-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (37 loc) · 1.22 KB
/
tag.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
# Tags on commit to main branch
# - Checks out the repository.
# - Determines the latest tag in the repository.
# - Creates a new tag from the latest tag, and increments patch version by 1.
# - Pushes the new tag to the remote repository.
name: Tag on Merge
on:
push:
branches:
- main
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine latest tag
id: latest_tag
run: |
latest_tag=$(git describe --tags --abbrev=0)
echo "::set-output name=tag::$latest_tag"
- name: Determine incremented tag
id: incremented_tag
run: |
IFS='.' read -r -a version_parts <<< "${{ steps.latest_tag.outputs.tag }}"
major="${version_parts[0]}"
minor="${version_parts[1]}"
patch="${version_parts[2]}"
patch=$((patch + 1))
incremented_tag="${major}.${minor}.${patch}"
echo "::set-output name=tag::$incremented_tag"
- name: Create and push tag
run: |
git tag "${{ steps.incremented_tag.outputs.tag }}"
git push origin "${{ steps.incremented_tag.outputs.tag }}"