Skip to content

Commit c4a9d97

Browse files
authored
chore: add release build workflow and update test pattern (#16)
1 parent 880ac00 commit c4a9d97

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Publish release-build branch
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
concurrency:
8+
group: release-build
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 22
28+
cache: npm
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build
34+
run: npm run build
35+
36+
- name: Prepare artifacts
37+
id: prep
38+
shell: bash
39+
env:
40+
ART_DIR: ${{ runner.temp }}/release-build
41+
run: |
42+
set -euo pipefail
43+
44+
SHORT_SHA="$(git rev-parse --short HEAD)"
45+
46+
rm -rf "$ART_DIR"
47+
mkdir -p "$ART_DIR"
48+
49+
cp -R dist "$ART_DIR/"
50+
51+
node -e "
52+
const fs = require('fs');
53+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
54+
delete pkg.scripts;
55+
delete pkg.devDependencies;
56+
fs.writeFileSync(process.env.ART_DIR + '/package.json', JSON.stringify(pkg, null, 2));
57+
"
58+
59+
[ -f README.md ] && cp README.md "$ART_DIR/" || true
60+
[ -f LICENSE ] && cp LICENSE "$ART_DIR/" || true
61+
[ -f CHANGELOG.md ] && cp CHANGELOG.md "$ART_DIR/" || true
62+
63+
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
64+
echo "art_dir=$ART_DIR" >> "$GITHUB_OUTPUT"
65+
66+
- name: Publish to release-build branch
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
ART_DIR: ${{ steps.prep.outputs.art_dir }}
70+
SHORT_SHA: ${{ steps.prep.outputs.short_sha }}
71+
shell: bash
72+
run: |
73+
set -euo pipefail
74+
75+
cd "$ART_DIR"
76+
git init
77+
git config user.name "github-actions[bot]"
78+
git config user.email "github-actions[bot]@users.noreply.github.com"
79+
git add .
80+
git commit -m "chore: release build for ${SHORT_SHA}"
81+
82+
git branch -M release-build
83+
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
84+
git push --force origin release-build

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@
2929
"scripts": {
3030
"clean": "rm -rf dist",
3131
"build": "npm run clean && tsc -p tsconfig.build.json",
32-
"test": "node --test --experimental-strip-types --experimental-test-coverage src/**/*.test.*",
32+
"test": "node --test --experimental-strip-types --experimental-test-coverage src/*.test.*",
3333
"lint": "oxlint",
3434
"lint:fix": "oxlint --fix --fix-suggestions",
3535
"format:check": "prettier --check .",
3636
"format:write": "prettier --write .",
3737
"type-check": "tsc --noEmit",
38-
"download-schemas": "node scripts/sbom-schema-downloader.js",
39-
"prepare": "npm run build"
38+
"download-schemas": "node scripts/sbom-schema-downloader.js"
4039
},
4140
"dependencies": {
4241
"@cyclonedx/cyclonedx-library": "^8.5.0",

0 commit comments

Comments
 (0)