-
Notifications
You must be signed in to change notification settings - Fork 61
74 lines (59 loc) · 1.87 KB
/
release-on-main.yml
File metadata and controls
74 lines (59 loc) · 1.87 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: Release on main
on:
push:
branches:
- main
permissions:
contents: write
jobs:
tag-release:
name: Tag release
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.tag.outputs.release_tag }}
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Bump patch version and push tag
id: tag
run: |
set -euo pipefail
max_attempts=5
for attempt in $(seq 1 "$max_attempts"); do
git fetch --force --tags origin
latest=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)
[ -z "$latest" ] && latest="v0.0.0"
version="${latest#v}"
major="${version%%.*}"
rest="${version#*.}"
minor="${rest%%.*}"
patch="${rest#*.}"
release_tag="v${major}.${minor}.$((patch + 1))"
echo "Attempt ${attempt}/${max_attempts}: bumping ${latest} -> ${release_tag}"
if git tag "$release_tag" && git push origin "$release_tag"; then
echo "release_tag=${release_tag}" >> "$GITHUB_OUTPUT"
exit 0
fi
git tag -d "$release_tag" >/dev/null 2>&1 || true
sleep "$attempt"
done
echo "Could not push a unique release tag after ${max_attempts} attempts." >&2
exit 1
publish-docker-images:
name: Publish Docker images
needs: tag-release
uses: ./.github/workflows/publish-docker-images.yml
with:
tag: ${{ needs.tag-release.outputs.release_tag }}
secrets: inherit
deploy-staging:
name: Deploy staging
needs:
- tag-release
- publish-docker-images
uses: ./.github/workflows/deploy-staging.yml
with:
tag: ${{ needs.tag-release.outputs.release_tag }}
secrets: inherit