-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (66 loc) · 2.18 KB
/
release-build.yml
File metadata and controls
84 lines (66 loc) · 2.18 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
name: Publish release-build branch
on:
push:
branches: [main]
concurrency:
group: release-build
cancel-in-progress: true
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Prepare artifacts
id: prep
shell: bash
env:
ART_DIR: ${{ runner.temp }}/release-build
run: |
set -euo pipefail
SHORT_SHA="$(git rev-parse --short HEAD)"
rm -rf "$ART_DIR"
mkdir -p "$ART_DIR"
cp -R dist "$ART_DIR/"
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
delete pkg.scripts;
delete pkg.devDependencies;
fs.writeFileSync(process.env.ART_DIR + '/package.json', JSON.stringify(pkg, null, 2));
"
[ -f README.md ] && cp README.md "$ART_DIR/" || true
[ -f LICENSE ] && cp LICENSE "$ART_DIR/" || true
[ -f CHANGELOG.md ] && cp CHANGELOG.md "$ART_DIR/" || true
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
echo "art_dir=$ART_DIR" >> "$GITHUB_OUTPUT"
- name: Publish to release-build branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ART_DIR: ${{ steps.prep.outputs.art_dir }}
SHORT_SHA: ${{ steps.prep.outputs.short_sha }}
shell: bash
run: |
set -euo pipefail
cd "$ART_DIR"
git init
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: release build for ${SHORT_SHA}"
git branch -M release-build
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push --force origin release-build