-
-
Notifications
You must be signed in to change notification settings - Fork 3
executable file
·185 lines (163 loc) · 6.62 KB
/
Copy pathrelease.yml
File metadata and controls
executable file
·185 lines (163 loc) · 6.62 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
name: Release
on:
push:
tags:
- 'Stellar-*'
permissions:
contents: write
env:
RELEASE_TAG_PREFIX: Stellar
NODE_VERSION: 24
VERCEL_NODE_RUNTIME: nodejs24.x
jobs:
validate-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Get tag name
id: tag
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Validate tag format
run: |
TAG="${{ steps.tag.outputs.TAG_NAME }}"
if [[ ! "$TAG" =~ ^${RELEASE_TAG_PREFIX}-v[0-9]+\.[0-9]+$ ]]; then
echo "Invalid tag format: $TAG (expected ${RELEASE_TAG_PREFIX}-v<major>.<minor>)"
exit 1
fi
- name: Validate tag matches package version
shell: bash
run: |
set -euo pipefail
TAG="${{ steps.tag.outputs.TAG_NAME }}"
TAG_VERSION="${TAG#"${RELEASE_TAG_PREFIX}-v"}"
PACKAGE_SHORT="$(node -e "const [m='0',n='0']=require('./package.json').version.split('.');console.log(m+'.'+n)")"
if [ "$TAG_VERSION" != "$PACKAGE_SHORT" ]; then
echo "Tag $TAG does not match package.json v${PACKAGE_SHORT}"
exit 1
fi
release:
needs: validate-tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Get tag name
id: tag
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Resolve Bun version
id: bun-version
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').packageManager?.match(/^bun@(.+)$/)?.[1] || ''")"
if [ -z "$version" ]; then
echo "package.json packageManager must be bun@<version>" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ steps.bun-version.outputs.version }}
- name: Install dependencies (frozen)
run: bun install --frozen-lockfile
- name: Build static project
shell: bash
run: |
set -euo pipefail
cp svelte.config.js svelte.config.js.vercel
had_layout_ts=0
if [ -f src/routes/+layout.ts ]; then
had_layout_ts=1
cp src/routes/+layout.ts src/routes/+layout.ts.vercel
fi
cleanup() {
cp svelte.config.js.vercel svelte.config.js
rm -f svelte.config.js.vercel
if [ "$had_layout_ts" -eq 1 ]; then
mv src/routes/+layout.ts.vercel src/routes/+layout.ts
else
rm -f src/routes/+layout.ts
fi
}
trap cleanup EXIT
cp svelte.config.static.js svelte.config.js
printf 'export const prerender = true;\n' > src/routes/+layout.ts
bun run build
- name: Generate changelog
id: changelog
run: |
PREVIOUS_TAG=$(git tag --sort=-creatordate | grep -v "^${{ steps.tag.outputs.TAG_NAME }}$" | head -n 1)
if [ -z "$PREVIOUS_TAG" ]; then
FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD)
COMMITS=$(git log "${FIRST_COMMIT}..HEAD" --pretty=format:"- %s (%h)" --no-merges)
else
COMMITS=$(git log "${PREVIOUS_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges)
fi
{
echo "CHANGELOG<<EOF"
echo "$COMMITS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create source archive
run: |
TAG="${{ steps.tag.outputs.TAG_NAME }}"
STAGE="release-source"
rm -rf "$STAGE" && mkdir -p "$STAGE"
cp -r src "$STAGE/" && cp -r static "$STAGE/" && cp -r scripts "$STAGE/"
cp -r .github "$STAGE/" && cp -r docs "$STAGE/" 2>/dev/null || true
cp package.json "$STAGE/" && cp bun.lock "$STAGE/" 2>/dev/null || true
cp svelte.config.js "$STAGE/" 2>/dev/null || true
cp svelte.config.static.js "$STAGE/" 2>/dev/null || true
cp vite.config.ts "$STAGE/" 2>/dev/null || true
cp tsconfig.json "$STAGE/" 2>/dev/null || true
cp vitest.config.ts "$STAGE/" 2>/dev/null || true
cp postcss.config.js "$STAGE/" 2>/dev/null || true
cp eslint.config.js "$STAGE/" 2>/dev/null || true
cp vercel.json "$STAGE/" 2>/dev/null || true
cp verify.sh "$STAGE/" 2>/dev/null || true
cp README.md "$STAGE/" 2>/dev/null || true
cp LICENSE "$STAGE/" && cp SECURITY.md "$STAGE/" 2>/dev/null || true
cd "$STAGE" && zip -r "../bmi-stellar-source-${TAG}.zip" . && cd ..
sha256sum "bmi-stellar-source-${TAG}.zip" > "bmi-stellar-source-${TAG}.zip.sha256"
rm -rf "$STAGE"
- name: Create build archive
run: |
TAG="${{ steps.tag.outputs.TAG_NAME }}"
STAGE="release-build"
rm -rf "$STAGE" && mkdir -p "$STAGE"
cp -r build "$STAGE/" && cp package.json "$STAGE/" && cp LICENSE "$STAGE/"
cp README.md "$STAGE/" 2>/dev/null || true
cp -r docs "$STAGE/" 2>/dev/null || true
cd "$STAGE" && zip -r "../bmi-stellar-build-${TAG}.zip" . && cd ..
sha256sum "bmi-stellar-build-${TAG}.zip" > "bmi-stellar-build-${TAG}.zip.sha256"
rm -rf "$STAGE"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2.6.2
with:
name: ${{ steps.tag.outputs.TAG_NAME }}
body: |
## What's Changed
${{ steps.changelog.outputs.CHANGELOG }}
---
**Artifacts:** [source](${{ github.server_url }}/${{ github.repository }}/releases/download/${{ steps.tag.outputs.TAG_NAME }}/bmi-stellar-source-${{ steps.tag.outputs.TAG_NAME }}.zip) · [build](${{ github.server_url }}/${{ github.repository }}/releases/download/${{ steps.tag.outputs.TAG_NAME }}/bmi-stellar-build-${{ steps.tag.outputs.TAG_NAME }}.zip)
files: |
bmi-stellar-source-${{ steps.tag.outputs.TAG_NAME }}.zip
bmi-stellar-source-${{ steps.tag.outputs.TAG_NAME }}.zip.sha256
bmi-stellar-build-${{ steps.tag.outputs.TAG_NAME }}.zip
bmi-stellar-build-${{ steps.tag.outputs.TAG_NAME }}.zip.sha256
draft: false
prerelease: false