Repository navigation
73 lines (62 loc) · 2.04 KB
/
Copy pathalpha.yml
File metadata and controls
73 lines (62 loc) · 2.04 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
name: Alpha
on:
push:
branches:
- master
concurrency:
group: alpha-release
cancel-in-progress: false
permissions:
contents: read
jobs:
tag:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
outputs:
alpha_tag: ${{ steps.version.outputs.alpha_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute next alpha version
id: version
run: |
set -euo pipefail
# Latest stable tag (strict semver, no pre-release suffix).
latest="$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)"
if [ -z "$latest" ]; then
echo "no stable tag found; starting from v0.0.0" >&2
latest="v0.0.0"
fi
base="${latest#v}"
major="${base%%.*}"
rest="${base#*.}"
minor="${rest%%.*}"
patch="${rest#*.}"
next="v${major}.${minor}.$((patch + 1))"
# Alpha counter: number of existing alpha tags for the next version + 1.
count="$(git tag -l "${next}-alpha-*" | wc -l | tr -d ' ')"
alpha="${next}-alpha-$((count + 1))"
echo "latest stable: $latest"
echo "next alpha: $alpha"
echo "alpha_tag=$alpha" >> "$GITHUB_OUTPUT"
- name: Create and push alpha tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.alpha_tag }}" -m "${{ steps.version.outputs.alpha_tag }}: automated alpha release from master"
git push origin "${{ steps.version.outputs.alpha_tag }}"
pipeline:
needs: tag
permissions:
contents: write
packages: write
id-token: write
uses: ./.github/workflows/_release-pipeline.yml
with:
tag: ${{ needs.tag.outputs.alpha_tag }}