Skip to content

Commit

Permalink
ci: publish workflow via changesets (#5038)
Browse files Browse the repository at this point in the history
Co-authored-by: dyc3 <[email protected]>
  • Loading branch information
ematipico and dyc3 authored Feb 6, 2025
1 parent 71c825e commit 76167db
Show file tree
Hide file tree
Showing 10 changed files with 6,743 additions and 6,733 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "withastro/astro" }],
"changelog": ["@changesets/changelog-github", { "repo": "biomejs/biome" }],
"commit": false,
"fixed": [
[
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/prepare_release.yml

This file was deleted.

221 changes: 143 additions & 78 deletions .github/workflows/release_knope.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,80 @@
name: Release

on:
pull_request:
types: [ closed ]
branches: [ main ]
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
actions: write
contents: write
pull-requests: write

jobs:
retrieve-version:
if: github.head_ref == 'release/automated-ci' && github.event.pull_request.merged == true
name: Retrieve version
changesets:
name: Release
runs-on: ubuntu-latest
outputs:
version: ${{ env.version }}
version_changed: ${{ steps.version.outputs.changed }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Pin Corepack 0.20
run: |
echo "Before: corepack => $(corepack --version || echo 'not installed')"
npm install -g [email protected]
echo "After : corepack => $(corepack --version)"
corepack enable
pnpm --version
- name: Create Release Pull Request
uses: changesets/action@v1
with:
version: pnpm run version
commit: "ci: release"
title: "ci: release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check version changes
# Retrieve version of `@biomejs/biome` and `@biomejs/js-api`
version:
needs: changesets
if: steps.changesets.outputs.hasChangesets == 'false' && github.head_ref == 'changeset-release/main'
outputs:
cli-version: ${{ env.cli-version }}
js-api-version: ${{ env.cli-js-api-version }}

steps:
- name: Check CLI version changes
uses: EndBug/version-check@36ff30f37c7deabe56a30caa043d127be658c425 # v2.1.5
id: version
id: cli-version-changed
with:
diff-search: true
file-name: packages/@biomejs/biome/package.json

- name: Set version name
if: steps.version.outputs.changed == 'true'
- name: Check JS API version changes
uses: EndBug/version-check@36ff30f37c7deabe56a30caa043d127be658c425 # v2.1.5
id: js-api-version-changed
with:
diff-search: true
file-name: packages/@biomejs/js-api/package.json

- name: Set Biome Version as Environment Variable
run: |
echo "Version change found! New version: ${{ steps.version.outputs.version }} (${{ steps.version.outputs.version_type }})"
echo "version=${{ steps.version.outputs.version }}" >> $GITHUB_ENV
echo "cli-version=${{ steps.cli-version-changed.outputs.version }}" >> $GITHUB_ENV
echo "js-api-version=${{ steps.js-api-version-changed.outputs.version }}" >> $GITHUB_ENV
# Building jobs

build:
build-binaries:
needs: version
if: steps.cli-version-changed.outputs.changed == 'true'
strategy:
matrix:
include:
Expand Down Expand Up @@ -59,13 +102,9 @@ jobs:
- os: macos-14
target: aarch64-apple-darwin
code-target: darwin-arm64

name: Package ${{ matrix.code-target }}
runs-on: ${{ matrix.os }}
needs: retrieve-version
env:
version: ${{ needs.check.outputs.version }}
outputs:
version: ${{ env.version }}

steps:
- name: Checkout repository
Expand All @@ -76,14 +115,8 @@ jobs:
with:
node-version: 20

- name: Install toolchain
uses: moonrepo/setup-rust@e013866c4215f77c925f42f60257dec7dd18836e # v1.2.1
with:
channel: stable
cache-target: release
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
run: rustup target add ${{ matrix.target }}

- name: Install arm64 toolchain
if: matrix.code-target == 'linux-arm64' || matrix.code-target == 'linux-arm64-musl'
Expand Down Expand Up @@ -115,7 +148,7 @@ jobs:
# Strip all debug symbols from the resulting binaries
RUSTFLAGS: "-C strip=symbols -C codegen-units=1"
# Inline the version of the npm package in the CLI binary
BIOME_VERSION: ${{ env.version }}
BIOME_VERSION: ${{ env.cli-version }}

# Copy the CLI binary and rename it to include the name of the target platform
- name: Copy CLI binary
Expand All @@ -129,8 +162,8 @@ jobs:
mkdir dist
cp target/${{ matrix.target }}/release/biome ./dist/biome-${{ matrix.code-target }}
- name: Upload Artifact
# Upload the CLI binary as a build artifact
- name: Upload CLI artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: cli-${{ matrix.target }}
Expand All @@ -140,7 +173,8 @@ jobs:
build-wasm:
name: Build WASM
runs-on: ubuntu-latest
needs: retrieve-version
needs: version
if: steps.cli-version-changed.outputs.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -165,11 +199,60 @@ jobs:
./packages/@biomejs/wasm-web
if-no-files-found: error

release:
build-js-api:
name: Package JavaScript APIs
runs-on: ubuntu-latest
needs: version
if: steps.js-api-version-changed.outputs.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 20

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Cache pnpm modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0

- name: Compile backends
run: |
pnpm --filter @biomejs/js-api run build:wasm-bundler
pnpm --filter @biomejs/js-api run build:wasm-node
pnpm --filter @biomejs/js-api run build:wasm-web
pnpm --filter @biomejs/backend-jsonrpc i
pnpm --filter @biomejs/backend-jsonrpc run build
- name: Build package
run: |
pnpm --filter @biomejs/js-api i
pnpm --filter @biomejs/js-api run build
- name: Upload JS API artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: js-api
path: |
./packages/@biomejs/js-api/dist
if-no-files-found: error

# Publishing jobs

publish-cli:
name: Publish
runs-on: ubuntu-latest
needs:
- build
- build-binaries
- build-wasm
environment: npm-publish
permissions:
Expand All @@ -190,66 +273,48 @@ jobs:
merge-multiple: true
path: packages/@biomejs

- uses: knope-dev/action@407e9ef7c272d2dd53a4e71e39a7839e29933c48 # v2.1.0
- name: Install Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
version: 0.16.2
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: knope release
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: Generate npm packages
run: node packages/@biomejs/biome/scripts/generate-packages.mjs

- name: Publish npm packages as latest
run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Upload assets to the latest tag
run: |
files=$(ls biome-* | tr '\n' ' ')
gh release upload @biomejs/biome@${{ env.cli-version }} $files
publish-npm:
name: Publish npm packages
publish-js-api:
name: Publish
runs-on: ubuntu-latest
needs: release
needs: build-js-api
environment: npm-publish
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Download CLI artifacts
- name: Download package artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: cli-*
merge-multiple: true
- name: Download WASM artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: wasm-*
merge-multiple: true
path: packages/@biomejs
name: js-api
path: packages/@biomejs/js-api/dist

- name: Install Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: Publish npm packages as latest
run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public; fi; done
- name: Publish npm package as latest
run: npm publish packages/@biomejs/js-api --tag latest --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish npm packages as nightly
run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag nightly --access public; fi; done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-crate:
name: Publish crates
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install toolchain
uses: moonrepo/setup-rust@e013866c4215f77c925f42f60257dec7dd18836e # v1.2.1
with:
channel: stable
cache-target: release
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_TOKEN }}
4 changes: 0 additions & 4 deletions .github/workflows/release_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: ${{ env.version }}
prerelease: ${{ env.prerelease }}
nightly: ${{ env.nightly }}
version_changed: ${{ steps.version.outputs.changed }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

Expand All @@ -28,7 +25,6 @@ jobs:

- name: Check version changes
uses: EndBug/version-check@36ff30f37c7deabe56a30caa043d127be658c425 # v2.1.5
if: env.nightly != 'true'
id: version
with:
diff-search: true
Expand Down
Loading

0 comments on commit 76167db

Please sign in to comment.