Skip to content

Release

Release #18

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
increment:
description: "Version bump (patch, minor, major)"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
NODE_VERSION: 24
PNPM_VERSION: 10.23.0
jobs:
release:
runs-on: blacksmith-16vcpu-ubuntu-2404
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
check-latest: true
cache: pnpm
- run: git config user.name "github-actions[bot]"
- run: git config user.email "github-actions[bot]@users.noreply.github.com"
- run: pnpm install --frozen-lockfile
- name: Validate package metadata for trusted publishing
run: |
node - <<'NODE'
const { readFileSync } = require("node:fs");
const pkg = JSON.parse(readFileSync("package.json", "utf8"));
const expectedAuthor = "OpenClaw Team <dev@openclaw.ai>";
const expectedRepoUrl = "https://github.com/openclaw/acpx";
const normalizeRepoUrl = (value) =>
String(value ?? "")
.trim()
.replace(/^git\+/, "")
.replace(/\.git$/i, "")
.replace(/\/+$/, "");
const actualRepoUrl = normalizeRepoUrl(pkg?.repository?.url);
const expectedRepoUrlNormalized = normalizeRepoUrl(expectedRepoUrl);
const errors = [];
if (actualRepoUrl !== expectedRepoUrlNormalized) {
errors.push(
`package.json repository.url must resolve to ${expectedRepoUrlNormalized}; found ${actualRepoUrl || "<missing>"}`
);
}
if ((pkg?.author ?? "") !== expectedAuthor) {
errors.push(
`package.json author must be exactly "${expectedAuthor}"; found "${pkg?.author ?? ""}"`
);
}
if (errors.length > 0) {
for (const err of errors) {
console.error(err);
}
process.exit(1);
}
console.log("Package metadata validated.");
NODE
- run: pnpm run lint
- run: pnpm run typecheck
- run: pnpm run build
# Sync the working tree to the currently published version, then let
# release-it perform the requested bump from that baseline.
- name: Bump version from npm registry
run: |
LATEST=$(npm view acpx version 2>/dev/null || echo "0.0.0")
echo "Latest on npm: $LATEST"
TARGET=$(node - "$LATEST" "${{ inputs.increment }}" <<'NODE'
const [version, increment] = process.argv.slice(2);
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
if (!match) {
throw new Error(`Unsupported semver: ${version}`);
}
const [major, minor, patch] = match.slice(1).map(Number);
if (increment === "patch") {
console.log(`${major}.${minor}.${patch + 1}`);
process.exit(0);
}
if (increment === "minor") {
console.log(`${major}.${minor + 1}.0`);
process.exit(0);
}
if (increment === "major") {
console.log(`${major + 1}.0.0`);
process.exit(0);
}
throw new Error(`Unsupported increment: ${increment}`);
NODE
)
npm version --no-git-tag-version "$LATEST" --allow-same-version
echo "VERSION=$TARGET" >> "$GITHUB_ENV"
echo "Releasing: $TARGET"
- name: Release
run: |
pnpm exec release-it "$VERSION" --ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: "true"