Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@
"scripts": {
"clean": "rm -rf dist",
"build": "npm run clean && tsc -p tsconfig.build.json",
"test": "node --test --experimental-strip-types --experimental-test-coverage src/**/*.test.*",
"test": "node --test --experimental-strip-types --experimental-test-coverage src/*.test.*",
"lint": "oxlint",
"lint:fix": "oxlint --fix --fix-suggestions",
"format:check": "prettier --check .",
"format:write": "prettier --write .",
"type-check": "tsc --noEmit",
"download-schemas": "node scripts/sbom-schema-downloader.js",
"prepare": "npm run build"
"download-schemas": "node scripts/sbom-schema-downloader.js"
},
"dependencies": {
"@cyclonedx/cyclonedx-library": "^8.5.0",
Expand Down