-
Notifications
You must be signed in to change notification settings - Fork 5
74 lines (61 loc) · 1.88 KB
/
create-release-tag.yml
File metadata and controls
74 lines (61 loc) · 1.88 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
67
68
69
70
71
72
73
74
name: Create Release Tag
on:
workflow_dispatch:
inputs:
release_ref:
description: Git ref to tag
required: true
default: main
permissions:
contents: write
env:
git_user_name: localstack[bot]
git_user_email: localstack-bot@users.noreply.github.com
concurrency:
group: create-release-tag
cancel-in-progress: false
jobs:
create-tag:
name: Create next CalVer tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.release_ref }}
fetch-depth: 0
- name: Configure Git user
env:
GIT_USER_NAME: ${{ env.git_user_name }}
GIT_USER_EMAIL: ${{ env.git_user_email }}
run: |
git config user.name "${GIT_USER_NAME}"
git config user.email "${GIT_USER_EMAIL}"
- name: Fetch tags
run: git fetch --tags --force
- name: Compute next CalVer tag
id: next_tag
run: |
set -euo pipefail
year="$(date -u +%Y)"
month="$(date -u +%-m)"
prefix="${year}.${month}."
latest="$(git tag --list "${prefix}*" --sort=-v:refname | grep -E "^${year}\.${month}\.[0-9]+$" | head -n 1 || true)"
if [[ -z "${latest}" ]]; then
patch=0
else
patch="$(( ${latest##*.} + 1 ))"
fi
tag="${year}.${month}.${patch}"
if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
echo "Tag ${tag} already exists"
exit 1
fi
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
- name: Create and push tag
run: |
tag="${{ steps.next_tag.outputs.tag }}"
git tag -a "${tag}" -m "Release ${tag}"
git push origin "${tag}"
- name: Print created tag
run: echo "Created tag ${{ steps.next_tag.outputs.tag }}"