-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (89 loc) · 3.25 KB
/
release.yaml
File metadata and controls
101 lines (89 loc) · 3.25 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Release
# Triggered by pushing a semver tag (e.g. v2.1.3, v2.1.3-beta.1).
# 1. Builds dist/ locally.
# 2. Creates a GitHub Release with auto-generated notes,
# marked as prerelease if the tag has a "-suffix".
# 3. Force-pushes dist/ onto the tag.
# 4. For stable releases only, also updates the rolling major/minor refs
# (v2.1.3 -> v2 and v2.1).
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
notify-start:
runs-on: ubuntu-latest
steps:
- uses: kosli-dev/reusable-actions/slack-release-notify@main
with:
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel-id: ${{ vars.SLACK_CHANNEL_ID }}
stage: start
release:
runs-on: ubuntu-latest
steps:
- name: Detect prerelease
id: meta
run: echo "prerelease=${{ contains(github.ref_name, '-') }}" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Install deps and build
run: npm ci && npm run build
- name: Create GitHub Release with auto-generated notes
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
prerelease: ${{ steps.meta.outputs.prerelease }}
# Stable releases: build-and-tag-action pushes dist/ to the tag
# AND updates the rolling v<major> and v<major>.<minor> refs.
- name: Build and tag (stable releases)
if: steps.meta.outputs.prerelease == 'false'
uses: JasonEtco/build-and-tag-action@v2
with:
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ github.token }}
# Prereleases: only push dist/ to the tag, don't touch major/minor refs.
- name: Push dist/ to tag (prereleases)
if: steps.meta.outputs.prerelease == 'true'
env:
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -f dist/
git commit -m "build: dist for ${TAG}"
git tag -f "${TAG}"
git push origin -f "refs/tags/${TAG}"
notify-finish:
needs: [notify-start, release]
if: always() && needs.notify-start.result == 'success'
runs-on: ubuntu-latest
permissions:
actions: read # ← needed to fetch run_started_at for duration
contents: read # ← needed to read release notes via `gh release view`
steps:
- name: Determine status
id: status
run: |
if [[ "${{ !contains(join(needs.*.result, ','), 'failure') && !contains(join(needs.*.result, ','), 'cancelled') }}" == "true" ]]; then
echo "value=success" >> "$GITHUB_OUTPUT"
else
echo "value=failure" >> "$GITHUB_OUTPUT"
fi
- uses: kosli-dev/reusable-actions/slack-release-notify@main
with:
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel-id: ${{ vars.SLACK_CHANNEL_ID }}
stage: finish
status: ${{ steps.status.outputs.value }}