mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-07 01:21:37 +00:00
Move npm publishing from the local release script to the tag-triggered Release workflow, authenticated with npm Trusted Publishing (OIDC) so no npm token is needed. Local `release-all` now only bumps versions, updates the lockfile, commits, tags, and pushes. - Add cli/scripts/publish-npm.ts: publish platform packages, wait until they are live, then publish the main package; skip versions already on npm so a failed run can be re-run. - Drop the platform optionalDependencies from cli/package.json. The published main package gets them from prepare-npm-packages; the workspace copy only made bun.lock depend on not-yet-published versions.
73 lines
2.6 KiB
YAML
73 lines
2.6 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
# npm Trusted Publishing (OIDC); no npm token is stored in the repo.
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: release-${{ github.ref }}
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
# Trusted Publishing needs npm >= 11.5.1.
|
|
- run: npm install -g npm@11
|
|
- name: Check tag matches CLI version
|
|
run: |
|
|
VERSION="$(node -p "require('./cli/package.json').version")"
|
|
if [[ "v$VERSION" != "$GITHUB_REF_NAME" ]]; then
|
|
echo "::error::Tag $GITHUB_REF_NAME does not match cli/package.json version $VERSION"
|
|
exit 1
|
|
fi
|
|
- run: bun install --frozen-lockfile
|
|
- run: bun run build:single-exe:all
|
|
- name: Publish to npm
|
|
run: bun run --cwd cli publish-npm
|
|
- name: Package release artifacts
|
|
run: |
|
|
cd cli/dist-exe
|
|
mkdir -p ../release-artifacts
|
|
|
|
for dir in bun-*/; do
|
|
target="${dir%/}"
|
|
# bun-darwin-arm64 -> hapi-darwin-arm64
|
|
name="hapi-${target#bun-}"
|
|
name="${name/windows/win32}"
|
|
|
|
if [[ "$target" == *"windows"* ]]; then
|
|
zip -j "../release-artifacts/${name}.zip" "$target"/hapi.exe
|
|
else
|
|
tar -czvf "../release-artifacts/${name}.tar.gz" -C "$target" hapi
|
|
fi
|
|
done
|
|
|
|
cd ../release-artifacts
|
|
sha256sum * > checksums.txt
|
|
- name: Create Release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
gh release create "${GITHUB_REF#refs/tags/}" \
|
|
--title "Release ${GITHUB_REF#refs/tags/}" \
|
|
--generate-notes \
|
|
cli/release-artifacts/*
|
|
- name: Update Homebrew formula
|
|
continue-on-error: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
run: |
|
|
VERSION="${GITHUB_REF#refs/tags/v}"
|
|
cd cli && bun run update-homebrew-formula --version "$VERSION" --push
|