Skip to content

chore(release): v0.2.1 — fix publish workflow #30

chore(release): v0.2.1 — fix publish workflow

chore(release): v0.2.1 — fix publish workflow #30

Workflow file for this run

name: Release
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
"on":
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
build:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
platform: darwin-arm64
rust-target: aarch64-apple-darwin
- os: macos-latest
platform: darwin-x64
rust-target: x86_64-apple-darwin
- os: ubuntu-latest
platform: linux-x64
rust-target: x86_64-unknown-linux-gnu
- os: windows-latest
platform: win32-x64
rust-target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev pkg-config libxdo-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust-target }}
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Build bunlet-native
env:
CARGO_BUILD_TARGET: ${{ matrix.rust-target }}
run: |
cd packages/bunlet-native
cargo build --release --target ${{ matrix.rust-target }}
bun run scripts/copy-artifact.js
- name: Build bunlet-cef-native
id: build-cef
env:
CARGO_BUILD_TARGET: ${{ matrix.rust-target }}
run: |
cd packages/bunlet-cef
cargo build --manifest-path ../bunlet-cef-native/Cargo.toml --release --target ${{ matrix.rust-target }}
bun run copy-artifact
continue-on-error: true
- name: Build CLI
run: |
cd packages/bunlet-cli
bun run build
- name: Package application
shell: bash
run: |
PLATFORM_FLAG=""
case "${{ matrix.platform }}" in
darwin-arm64|darwin-x64) PLATFORM_FLAG="--mac" ;;
linux-x64|linux-arm64) PLATFORM_FLAG="--linux" ;;
win32-x64) PLATFORM_FLAG="--win" ;;
esac
echo "Would run: bun run bunlet package $PLATFORM_FLAG"
echo "Skipping packaging for now - requires application build"
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.platform }}
path: release/
if-no-files-found: warn
- name: Upload bunlet-native artifacts
uses: actions/upload-artifact@v4
with:
name: bunlet-native-${{ matrix.platform }}
path: packages/bunlet-native/*.node
if-no-files-found: warn
- name: Upload bunlet-cef artifacts
if: steps.build-cef.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: bunlet-cef-${{ matrix.platform }}
path: |
packages/bunlet-cef/*.node
packages/bunlet-cef/bunlet-cef-helper*
if-no-files-found: warn
publish-npm:
name: Publish to npm
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Build packages
run: bun run build
- name: Download all bunlet-native artifacts
uses: actions/download-artifact@v4
with:
path: native-artifacts
pattern: bunlet-native-*
- name: Download all bunlet-cef artifacts
uses: actions/download-artifact@v4
with:
path: cef-artifacts
pattern: bunlet-cef-*
- name: Stage native addons into packages
run: |
mkdir -p packages/bunlet-native
cp native-artifacts/bunlet-native-*/*.node packages/bunlet-native/ || true
mkdir -p packages/bunlet-cef
cp cef-artifacts/bunlet-cef-*/*.node packages/bunlet-cef/ || true
cp cef-artifacts/bunlet-cef-*/bunlet-cef-helper* packages/bunlet-cef/ || true
# Authentication is via npm's OIDC trusted publishing: each
# @bunlet/* package must have a Trusted Publisher configured on
# npmjs.com pointing at github.com/dipankar/bunlet and this
# workflow file. `npm publish` then exchanges the GitHub OIDC
# token for a scoped npm token automatically — no long-lived
# NPM_TOKEN secret needed.
- name: Set up Node for npm OIDC (>=11.5.1)
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Publish @bunlet/native
run: cd packages/bunlet-native && npm publish --provenance --access public
- name: Publish @bunlet/cef
run: cd packages/bunlet-cef && npm publish --provenance --access public
- name: Publish @bunlet/core
run: cd packages/bunlet && npm publish --provenance --access public
- name: Publish @bunlet/cli
run: cd packages/bunlet-cli && npm publish --provenance --access public
publish-cargo:
name: Publish to crates.io
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: |
packages/bunlet-native -> target
packages/bunlet-cef-native -> target
- name: Get crates.io OIDC token
uses: rust-lang/crates-io-auth-action@v1
id: auth
# `cargo publish` defaults to a verify-build that needs every system dep
# the cdylib does (gtk/glib/webkit2gtk on Linux). The artifacts are
# already verified by the build-native matrix on real targets, so use
# --no-verify here to skip the redundant Linux-only build.
- name: Publish bunlet-native
run: |
VERSION=$(grep -m1 '^version' packages/bunlet-native/Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
if ! cargo search bunlet-native --limit 1 2>/dev/null | grep -q "^bunlet-native = \"$VERSION\""; then
cargo publish --no-verify --manifest-path packages/bunlet-native/Cargo.toml
else
echo "bunlet-native v$VERSION already published, skipping"
fi
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Publish bunlet-cef-native
run: |
VERSION=$(grep -m1 '^version' packages/bunlet-cef-native/Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
if ! cargo search bunlet-cef-native --limit 1 2>/dev/null | grep -q "^bunlet-cef-native = \"$VERSION\""; then
cargo publish --no-verify --manifest-path packages/bunlet-cef-native/Cargo.toml
else
echo "bunlet-cef-native v$VERSION already published, skipping"
fi
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
github-release:
name: Create GitHub Release
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all release artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
pattern: release-*
- name: Generate release notes
id: release-notes
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [ -f CHANGELOG.md ]; then
echo "changelog<<EOF" >> $GITHUB_OUTPUT
awk '/^## \[/ {found=0} /^## \['"${VERSION#v}"'\]/ {found=1} found' CHANGELOG.md | head -n 50 >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release-notes.outputs.version }}
name: Release ${{ steps.release-notes.outputs.version }}
draft: false
body: ${{ steps.release-notes.outputs.changelog }}
files: |
release-artifacts/**/*