-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (58 loc) · 1.63 KB
/
tag.yml
File metadata and controls
66 lines (58 loc) · 1.63 KB
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
58
59
60
61
62
63
64
65
66
name: Create Release Tag
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Get latest tag
id: latest
run: |
tag=$(git tag -l 'v*' --sort=-v:refname | head -n1)
echo "tag=${tag:-v0.0.0}" >> "$GITHUB_OUTPUT"
- name: Compute next version
id: next
env:
CURRENT_TAG: ${{ steps.latest.outputs.tag }}
BUMP_TYPE: ${{ inputs.bump }}
run: |
version="${CURRENT_TAG#v}"
IFS='.' read -r major minor patch <<< "$version"
case "$BUMP_TYPE" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
esac
echo "version=v${major}.${minor}.${patch}" >> "$GITHUB_OUTPUT"
- name: Create and push tag
env:
NEW_VERSION: ${{ steps.next.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$NEW_VERSION" -m "Release $NEW_VERSION"
git push origin "$NEW_VERSION"