-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (61 loc) · 2.29 KB
/
Copy pathrelease.yml
File metadata and controls
68 lines (61 loc) · 2.29 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
name: Release
on:
push:
branches:
- main
- 'release/**'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Build bundle (smoke test)
run: |
npm ci
npm run package
- name: Release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
BRANCH="${GITHUB_REF_NAME}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Version source of truth = latest stable tag vX.Y.Z (pushed manually).
# Used for BOTH production and beta — the branch only selects the channel.
STABLE="$(git tag --list 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)"
if [ -z "$STABLE" ]; then
echo "::error::No stable vX.Y.Z tag found. Push the release tag (e.g. v0.5.0) first."
exit 1
fi
echo "Latest stable tag: $STABLE"
if [ "$BRANCH" = "main" ]; then
if gh release view "$STABLE" >/dev/null 2>&1; then
echo "Release $STABLE already exists — nothing to do."
exit 0
fi
echo "Production release: $STABLE"
gh release create "$STABLE" --title "$STABLE" --generate-notes --latest
MAJOR="${STABLE%%.*}"
git tag -f "$MAJOR" "$STABLE"
git push origin -f "refs/tags/$MAJOR"
echo "Moved major alias $MAJOR -> $STABLE"
elif [[ "$BRANCH" == release/* ]]; then
# Beta of the latest stable tag; auto-increment N from existing beta tags.
LAST="$(git tag --list "${STABLE}-beta.*" | sed -E 's/.*-beta\.([0-9]+)$/\1/' | sort -n | tail -1)"
N=$(( ${LAST:-0} + 1 ))
TAG="${STABLE}-beta.${N}"
echo "Beta release: $TAG (base $STABLE)"
git tag "$TAG"
git push origin "refs/tags/$TAG"
gh release create "$TAG" --title "$TAG" --generate-notes --prerelease
else
echo "Branch '$BRANCH' is not configured for release — skipping."
fi