From 9af70f273da1519bc87964bde5cab49fbb4b3fc6 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 23 May 2026 16:12:51 -0400 Subject: [PATCH 1/6] chore: modernize CI and add npm install option to README - Replace deprecated `::set-output` with `$GITHUB_OUTPUT` in ci.yml - Bump release.yml to use jsr:@dprint/automation@0.10.3/tasks/publish-release - Add `dprint add npm:@dprint/biome` install option in README --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- README.md | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25ab748..4b2aeb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Get tag version if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') id: get_tag_version - run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} + run: echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT" # NPM - uses: actions/setup-node@v6 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b46b0fa..05dc25d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,4 +34,4 @@ jobs: run: | git config user.email "${{ github.actor }}@users.noreply.github.com" git config user.name "${{ github.actor }}" - deno run -A https://raw.githubusercontent.com/dprint/automation/0.10.0/tasks/publish_release.ts --${{github.event.inputs.releaseKind}} + deno run -A jsr:@dprint/automation@0.10.3/tasks/publish-release --${{github.event.inputs.releaseKind}} diff --git a/README.md b/README.md index f46956e..4f950e5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ Adapter for [Biome](https://github.com/biomejs/biome) for use as a formatting pl Then in your project's directory with a dprint.json file, run: ```shellsession -dprint config add biome +dprint add biome +# or install from npm +dprint add npm:@dprint/biome ``` Note: You do not need Biome installed globally as dprint will run Biome from the .wasm file in a sandboxed environment. From 43bb3a099071f2101db42a6fe28c38e4e4ab1924 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 23 May 2026 18:05:34 -0400 Subject: [PATCH 2/6] chore: also bump rust-toolchain.toml from update.ts Previously update.ts only updated the biome tag in Cargo.toml. When biome bumps its declared rust-toolchain (e.g. across 2.x), CI would silently end up trying to compile newer biome on the old toolchain. Match what dprint-plugin-ruff already does: fetch biome's rust-toolchain.toml at the new tag and bump our local channel to match (only ever upgrading; never downgrading). --- scripts/update.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/scripts/update.ts b/scripts/update.ts index 8bdfaa6..754e8dd 100644 --- a/scripts/update.ts +++ b/scripts/update.ts @@ -17,6 +17,9 @@ if (cargoTomlVersion.tag === latestTag.tag) { } $.log("Found new version."); +$.logStep("Updating rust-toolchain.toml..."); +await updateRustToolchain(latestTag.tag); + $.logStep("Updating Cargo.toml..."); const isPatchBump = cargoTomlVersion.version.major === latestTag.version.major && cargoTomlVersion.version.minor === latestTag.version.minor; @@ -88,3 +91,40 @@ async function getGitTags(): Promise { }); return tags.map(tag => tag.name); } + +async function updateRustToolchain(tag: string) { + // biome's tag (e.g. "@biomejs/biome@2.3.10") contains "/" and "@", + // both of which need percent-encoding in the raw.githubusercontent.com URL. + const encodedTag = encodeURIComponent(tag); + const response = await fetch( + `https://raw.githubusercontent.com/biomejs/biome/${encodedTag}/rust-toolchain.toml`, + ); + if (response.status === 404) { + $.log(`biome ${tag} does not include a rust-toolchain.toml; leaving local one alone.`); + return; + } + if (!response.ok) { + throw new Error(`Failed to fetch biome rust-toolchain.toml for ${tag}: ${response.statusText}`); + } + const content = await response.text(); + const match = content.match(/channel\s*=\s*"([^"]+)"/); + if (match == null) { + throw new Error("Could not find channel in biome's rust-toolchain.toml."); + } + const biomeRustVersion = match[1]; + const toolchainPath = rootDirPath.join("rust-toolchain.toml"); + const localContent = toolchainPath.readTextSync(); + const localMatch = localContent.match(/channel\s*=\s*"([^"]+)"/); + if (localMatch == null) { + throw new Error("Could not find channel in local rust-toolchain.toml."); + } + // only bump up; never downgrade. compare as semver so 1.95.0 > 1.91.0. + const local = semver.parse(localMatch[1]); + const upstream = semver.parse(biomeRustVersion); + if (semver.greaterThan(upstream, local)) { + $.log(`Updating Rust toolchain: ${localMatch[1]} -> ${biomeRustVersion}`); + toolchainPath.writeTextSync(localContent.replace(localMatch[0], `channel = "${biomeRustVersion}"`)); + } else { + $.log(`Rust toolchain at ${localMatch[1]} already satisfies biome ${tag} (needs >= ${biomeRustVersion}).`); + } +} From 17fb12448406856f48c849b423be80280c956603 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 23 May 2026 18:07:07 -0400 Subject: [PATCH 3/6] chore: normalize rust toolchain channel when comparing in update.ts rust-toolchain.toml channels may be just "1.84" (no patch); pad to MAJOR.MINOR.PATCH so @std/semver can parse it. --- scripts/update.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/update.ts b/scripts/update.ts index 754e8dd..c3dfbf0 100644 --- a/scripts/update.ts +++ b/scripts/update.ts @@ -118,9 +118,12 @@ async function updateRustToolchain(tag: string) { if (localMatch == null) { throw new Error("Could not find channel in local rust-toolchain.toml."); } + // rust-toolchain.toml channels may be just "1.84" (no patch); pad to + // MAJOR.MINOR.PATCH so @std/semver can parse it. + const normalize = (v: string) => /^\d+\.\d+$/.test(v) ? `${v}.0` : v; // only bump up; never downgrade. compare as semver so 1.95.0 > 1.91.0. - const local = semver.parse(localMatch[1]); - const upstream = semver.parse(biomeRustVersion); + const local = semver.parse(normalize(localMatch[1])); + const upstream = semver.parse(normalize(biomeRustVersion)); if (semver.greaterThan(upstream, local)) { $.log(`Updating Rust toolchain: ${localMatch[1]} -> ${biomeRustVersion}`); toolchainPath.writeTextSync(localContent.replace(localMatch[0], `channel = "${biomeRustVersion}"`)); From 7c0644fb72afcaf5abd8b021b25221d2662a238e Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 24 May 2026 09:35:56 -0400 Subject: [PATCH 4/6] chore: use dax $.request instead of fetch in update.ts Aligns with how dprint-plugin-ruff's update.ts already calls raw.githubusercontent.com. The 404 branch here uses `.noThrow()` so the 404 still falls through to "upstream has no rust-toolchain.toml" rather than throwing. --- scripts/update.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/update.ts b/scripts/update.ts index c3dfbf0..8edf579 100644 --- a/scripts/update.ts +++ b/scripts/update.ts @@ -96,16 +96,14 @@ async function updateRustToolchain(tag: string) { // biome's tag (e.g. "@biomejs/biome@2.3.10") contains "/" and "@", // both of which need percent-encoding in the raw.githubusercontent.com URL. const encodedTag = encodeURIComponent(tag); - const response = await fetch( + // .noThrow() so we can branch on 404 instead of throwing. + const response = await $.request( `https://raw.githubusercontent.com/biomejs/biome/${encodedTag}/rust-toolchain.toml`, - ); + ).noThrow(); if (response.status === 404) { $.log(`biome ${tag} does not include a rust-toolchain.toml; leaving local one alone.`); return; } - if (!response.ok) { - throw new Error(`Failed to fetch biome rust-toolchain.toml for ${tag}: ${response.statusText}`); - } const content = await response.text(); const match = content.match(/channel\s*=\s*"([^"]+)"/); if (match == null) { From 7510e035daad8607abb943619a9eb42ff655b333 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 24 May 2026 09:54:17 -0400 Subject: [PATCH 5/6] chore: migrate workflows to gagen --- ...pdates.yml => check_updates.generated.yml} | 23 ++- .github/workflows/check_updates.ts | 49 ++++++ .github/workflows/ci.generated.yml | 93 ++++++++++++ .github/workflows/ci.ts | 142 ++++++++++++++++++ .github/workflows/ci.yml | 90 ----------- .github/workflows/publish_npm.generated.yml | 36 +++++ .github/workflows/publish_npm.ts | 53 +++++++ .github/workflows/publish_npm.yml | 38 ----- .github/workflows/release.generated.yml | 34 +++++ .github/workflows/release.ts | 53 +++++++ .github/workflows/release.yml | 37 ----- 11 files changed, 469 insertions(+), 179 deletions(-) rename .github/workflows/{check_updates.yml => check_updates.generated.yml} (60%) create mode 100755 .github/workflows/check_updates.ts create mode 100644 .github/workflows/ci.generated.yml create mode 100755 .github/workflows/ci.ts delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish_npm.generated.yml create mode 100755 .github/workflows/publish_npm.ts delete mode 100644 .github/workflows/publish_npm.yml create mode 100644 .github/workflows/release.generated.yml create mode 100755 .github/workflows/release.ts delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/check_updates.yml b/.github/workflows/check_updates.generated.yml similarity index 60% rename from .github/workflows/check_updates.yml rename to .github/workflows/check_updates.generated.yml index 590c54d..6ba06ac 100644 --- a/.github/workflows/check_updates.yml +++ b/.github/workflows/check_updates.generated.yml @@ -1,33 +1,28 @@ -name: check_updates +# GENERATED BY ./check_updates.ts -- DO NOT DIRECTLY EDIT +name: check_updates on: - workflow_dispatch: + workflow_dispatch: {} schedule: - # do this once per day - - cron: "0 7 * * *" - + - cron: 0 7 * * * jobs: build: name: check updates if: github.repository == 'dprint/dprint-plugin-biome' runs-on: ubuntu-latest timeout-minutes: 45 - steps: - name: Clone repository - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: - token: ${{ secrets.GH_DPRINTBOT_PAT }} - - - uses: denoland/setup-deno@v2 - - uses: dsherret/rust-toolchain-file@v1 - + token: '${{ secrets.GH_DPRINTBOT_PAT }}' + - uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2 + - uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 - name: Run script - run: | + run: |- git config user.email "dprintbot@users.noreply.github.com" git config user.name "dprintbot" deno run -A ./scripts/update.ts - # This is necessary to prevent GH automatically disabling this workflow after 60 days. workflow-keepalive: if: github.event_name == 'schedule' runs-on: ubuntu-latest diff --git a/.github/workflows/check_updates.ts b/.github/workflows/check_updates.ts new file mode 100755 index 0000000..dd4eb85 --- /dev/null +++ b/.github/workflows/check_updates.ts @@ -0,0 +1,49 @@ +#!/usr/bin/env -S deno run -A +import { job, workflow } from "jsr:@david/gagen@^0.5.0"; + +const buildJob = job("build", { + name: "check updates", + if: "github.repository == 'dprint/dprint-plugin-biome'", + runsOn: "ubuntu-latest", + timeoutMinutes: 45, + steps: [ + { + name: "Clone repository", + uses: "actions/checkout@v6", + with: { token: "${{ secrets.GH_DPRINTBOT_PAT }}" }, + }, + { uses: "denoland/setup-deno@v2" }, + { uses: "dsherret/rust-toolchain-file@v1" }, + { + name: "Run script", + run: [ + `git config user.email "dprintbot@users.noreply.github.com"`, + `git config user.name "dprintbot"`, + "deno run -A ./scripts/update.ts", + ], + }, + ], +}); + +// This is necessary to prevent GH automatically disabling this workflow after 60 days. +const keepaliveJob = job("workflow-keepalive", { + if: "github.event_name == 'schedule'", + runsOn: "ubuntu-latest", + permissions: { actions: "write" }, + steps: [ + { uses: "liskin/gh-workflow-keepalive@f72ff1a1336129f29bf0166c0fd0ca6cf1bcb38c" }, + ], +}); + +workflow({ + name: "check_updates", + on: { + workflow_dispatch: {}, + schedule: [{ cron: "0 7 * * *" }], + }, + jobs: [buildJob, keepaliveJob], +}).writeOrLint({ + filePath: new URL("./check_updates.generated.yml", import.meta.url), + header: "# GENERATED BY ./check_updates.ts -- DO NOT DIRECTLY EDIT", + pinDeps: true, +}); diff --git a/.github/workflows/ci.generated.yml b/.github/workflows/ci.generated.yml new file mode 100644 index 0000000..c55891c --- /dev/null +++ b/.github/workflows/ci.generated.yml @@ -0,0 +1,93 @@ +# GENERATED BY ./ci.ts -- DO NOT DIRECTLY EDIT + +name: CI +on: + pull_request: + branches: + - main + push: + branches: + - main + tags: + - '*' +jobs: + build: + name: '${{ matrix.config.kind }} ${{ matrix.config.os }}' + runs-on: '${{ matrix.config.os }}' + strategy: + matrix: + config: + - os: ubuntu-latest + kind: test_release + - os: ubuntu-latest + kind: test_debug + env: + CARGO_INCREMENTAL: 0 + RUST_BACKTRACE: full + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 + - name: Install wasm32 target + if: matrix.config.kind == 'test_release' + run: rustup target add wasm32-unknown-unknown + - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 + with: + save-if: '${{ github.ref == ''refs/heads/main'' }}' + - uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2 + with: + deno-version: v2.x + - name: Build debug + if: matrix.config.kind == 'test_debug' + run: cargo build + - name: Build release + if: matrix.config.kind == 'test_release' + run: cargo build --target wasm32-unknown-unknown --features wasm --release + - name: Test debug + if: matrix.config.kind == 'test_debug' + run: cargo test + - name: Test release + if: matrix.config.kind == 'test_release' + run: cargo test --release + - name: Get tag version + id: get_tag_version + if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')' + run: 'echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"' + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + if: matrix.config.kind == 'test_release' + with: + node-version: 24.x + registry-url: 'https://registry.npmjs.org' + - name: Setup and test npm deployment + if: matrix.config.kind == 'test_release' + run: |- + cd deployment/npm + npm install + node setup.js + npm run test + - name: Pre-release + if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')' + run: |- + # update config schema to have version + sed -i 's/biome\/0.0.0/biome\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json + # rename the wasm file + (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_biome.wasm plugin.wasm) + # create release notes + deno run -A ./scripts/generateReleaseNotes.ts ${{ steps.get_tag_version.outputs.TAG_VERSION }} > ${{ github.workspace }}-CHANGELOG.txt + - name: Release + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 + if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')' + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + with: + files: |- + target/wasm32-unknown-unknown/release/plugin.wasm + deployment/schema.json + body_path: '${{ github.workspace }}-CHANGELOG.txt' + draft: false + - name: Lint workflow generation + if: matrix.config.kind == 'test_debug' + run: |- + ./.github/workflows/ci.ts --lint + ./.github/workflows/publish_npm.ts --lint + ./.github/workflows/release.ts --lint + ./.github/workflows/check_updates.ts --lint diff --git a/.github/workflows/ci.ts b/.github/workflows/ci.ts new file mode 100755 index 0000000..0785830 --- /dev/null +++ b/.github/workflows/ci.ts @@ -0,0 +1,142 @@ +#!/usr/bin/env -S deno run -A +import { conditions, defineMatrix, expr, job, step, workflow } from "jsr:@david/gagen@^0.5.0"; + +const pluginName = "biome"; +const cargoWasmName = `dprint_plugin_${pluginName}`; + +const matrix = defineMatrix({ + config: [ + { os: "ubuntu-latest", kind: "test_release" }, + { os: "ubuntu-latest", kind: "test_debug" }, + ], +}); + +const kind = expr("matrix.config.kind"); +const os = expr("matrix.config.os"); + +const isRelease = kind.equals("test_release"); +const isDebug = kind.equals("test_debug"); +const isTag = conditions.isTag(); +const isReleaseAndTag = isRelease.and(isTag); + +const getTagVersion = step({ + id: "get_tag_version", + name: "Get tag version", + if: isReleaseAndTag, + run: `echo "TAG_VERSION=\${GITHUB_REF/refs\\/tags\\//}" >> "$GITHUB_OUTPUT"`, + outputs: ["TAG_VERSION"], +}); + +const buildJob = job("build", { + name: `${kind} ${os}`, + runsOn: os, + strategy: { matrix }, + env: { + CARGO_INCREMENTAL: 0, + RUST_BACKTRACE: "full", + }, + steps: [ + { uses: "actions/checkout@v6" }, + { uses: "dsherret/rust-toolchain-file@v1" }, + { + name: "Install wasm32 target", + if: isRelease, + run: "rustup target add wasm32-unknown-unknown", + }, + { + uses: "Swatinem/rust-cache@v2", + with: { "save-if": "${{ github.ref == 'refs/heads/main' }}" }, + }, + // deno is needed by the "Lint workflow generation" step (test_debug) + // and by the "Pre-release" step (test_release on tag). Install it + // once at the top of every job to keep the matrix steps simple. + { + uses: "denoland/setup-deno@v2", + with: { "deno-version": "v2.x" }, + }, + + { name: "Build debug", if: isDebug, run: "cargo build" }, + { + name: "Build release", + if: isRelease, + run: "cargo build --target wasm32-unknown-unknown --features wasm --release", + }, + + { name: "Test debug", if: isDebug, run: "cargo test" }, + { name: "Test release", if: isRelease, run: "cargo test --release" }, + + getTagVersion, + + // NPM + { + uses: "actions/setup-node@v6", + if: isRelease, + with: { + "node-version": "24.x", + "registry-url": "https://registry.npmjs.org", + }, + }, + { + name: "Setup and test npm deployment", + if: isRelease, + run: [ + "cd deployment/npm", + "npm install", + "node setup.js", + "npm run test", + ], + }, + + // GITHUB RELEASE + { + name: "Pre-release", + if: isReleaseAndTag, + run: [ + "# update config schema to have version", + `sed -i 's/${pluginName}\\/0.0.0/${pluginName}\\/${getTagVersion.outputs.TAG_VERSION}/' deployment/schema.json`, + "# rename the wasm file", + `(cd target/wasm32-unknown-unknown/release/ && mv ${cargoWasmName}.wasm plugin.wasm)`, + "# create release notes", + `deno run -A ./scripts/generateReleaseNotes.ts ${getTagVersion.outputs.TAG_VERSION} > \${{ github.workspace }}-CHANGELOG.txt`, + ], + }, + { + name: "Release", + // pinned because softprops/action-gh-release was once compromised + uses: "softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844", + if: isReleaseAndTag, + env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, + with: { + files: [ + "target/wasm32-unknown-unknown/release/plugin.wasm", + "deployment/schema.json", + ].join("\n"), + body_path: "${{ github.workspace }}-CHANGELOG.txt", + draft: false, + }, + }, + { + name: "Lint workflow generation", + if: isDebug, + run: [ + "./.github/workflows/ci.ts --lint", + "./.github/workflows/publish_npm.ts --lint", + "./.github/workflows/release.ts --lint", + "./.github/workflows/check_updates.ts --lint", + ], + }, + ], +}); + +workflow({ + name: "CI", + on: { + pull_request: { branches: ["main"] }, + push: { branches: ["main"], tags: ["*"] }, + }, + jobs: [buildJob], +}).writeOrLint({ + filePath: new URL("./ci.generated.yml", import.meta.url), + header: "# GENERATED BY ./ci.ts -- DO NOT DIRECTLY EDIT", + pinDeps: true, +}); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 4b2aeb8..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - build: - name: ${{ matrix.config.kind }} ${{ matrix.config.os }} - runs-on: ${{ matrix.config.os }} - strategy: - matrix: - config: - - os: ubuntu-latest - kind: test_release - - os: ubuntu-latest - kind: test_debug - - env: - CARGO_INCREMENTAL: 0 - RUST_BACKTRACE: full - - steps: - - uses: actions/checkout@v6 - - uses: dsherret/rust-toolchain-file@v1 - - name: Install wasm32 target - if: matrix.config.kind == 'test_release' - run: rustup target add wasm32-unknown-unknown - - - uses: Swatinem/rust-cache@v2 - with: - save-if: ${{ github.ref == 'refs/heads/main' }} - - - name: Build debug - if: matrix.config.kind == 'test_debug' - run: cargo build - - name: Build release - if: matrix.config.kind == 'test_release' - run: cargo build --target wasm32-unknown-unknown --features wasm --release - - - name: Test debug - if: matrix.config.kind == 'test_debug' - run: cargo test - - name: Test release - if: matrix.config.kind == 'test_release' - run: cargo test --release - - - name: Get tag version - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') - id: get_tag_version - run: echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT" - - # NPM - - uses: actions/setup-node@v6 - if: matrix.config.kind == 'test_release' - with: - node-version: '24.x' - registry-url: 'https://registry.npmjs.org' - - - name: Setup and test npm deployment - if: matrix.config.kind == 'test_release' - run: | - cd deployment/npm - npm install - node setup.js - npm run test - - # GITHUB RELEASE - - uses: denoland/setup-deno@v2 - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') - with: - deno-version: v2.x - - name: Pre-release - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') - run: | - # update config schema to have version - sed -i 's/biome\/0.0.0/biome\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json - # rename the wasm file - (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_biome.wasm plugin.wasm) - # create release notes - deno run -A ./scripts/generateReleaseNotes.ts ${{ steps.get_tag_version.outputs.TAG_VERSION }} > ${{ github.workspace }}-CHANGELOG.txt - - name: Release - uses: softprops/action-gh-release@v2 - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: | - target/wasm32-unknown-unknown/release/plugin.wasm - deployment/schema.json - body_path: ${{ github.workspace }}-CHANGELOG.txt - draft: false diff --git a/.github/workflows/publish_npm.generated.yml b/.github/workflows/publish_npm.generated.yml new file mode 100644 index 0000000..8b6ea61 --- /dev/null +++ b/.github/workflows/publish_npm.generated.yml @@ -0,0 +1,36 @@ +# GENERATED BY ./publish_npm.ts -- DO NOT DIRECTLY EDIT + +name: publish npm +on: + workflow_dispatch: {} + push: + tags: + - '*' +permissions: + id-token: write + contents: read +jobs: + build: + name: publish-npm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 + - name: Install wasm32 target + run: rustup target add wasm32-unknown-unknown + - name: Build release + run: cargo build --target wasm32-unknown-unknown --features wasm --release + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + with: + node-version: 24.x + registry-url: 'https://registry.npmjs.org' + - name: Setup and test npm deployment + run: |- + cd deployment/npm + npm install + node setup.js sync-version + npm run test + - name: npm publish + run: |- + cd deployment/npm + npm publish --access public diff --git a/.github/workflows/publish_npm.ts b/.github/workflows/publish_npm.ts new file mode 100755 index 0000000..de23b20 --- /dev/null +++ b/.github/workflows/publish_npm.ts @@ -0,0 +1,53 @@ +#!/usr/bin/env -S deno run -A +import { job, workflow } from "jsr:@david/gagen@^0.5.0"; + +const npmJob = job("build", { + name: "publish-npm", + runsOn: "ubuntu-latest", + steps: [ + { uses: "actions/checkout@v6" }, + { uses: "dsherret/rust-toolchain-file@v1" }, + { name: "Install wasm32 target", run: "rustup target add wasm32-unknown-unknown" }, + { + name: "Build release", + run: "cargo build --target wasm32-unknown-unknown --features wasm --release", + }, + { + uses: "actions/setup-node@v6", + with: { + "node-version": "24.x", + "registry-url": "https://registry.npmjs.org", + }, + }, + { + name: "Setup and test npm deployment", + run: [ + "cd deployment/npm", + "npm install", + "node setup.js sync-version", + "npm run test", + ], + }, + { + name: "npm publish", + run: [ + "cd deployment/npm", + "npm publish --access public", + ], + }, + ], +}); + +workflow({ + name: "publish npm", + on: { + workflow_dispatch: {}, + push: { tags: ["*"] }, + }, + permissions: { "id-token": "write", contents: "read" }, + jobs: [npmJob], +}).writeOrLint({ + filePath: new URL("./publish_npm.generated.yml", import.meta.url), + header: "# GENERATED BY ./publish_npm.ts -- DO NOT DIRECTLY EDIT", + pinDeps: true, +}); diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml deleted file mode 100644 index 560b519..0000000 --- a/.github/workflows/publish_npm.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: publish npm - -on: - workflow_dispatch: - push: - tags: - - '*' - -permissions: - id-token: write - contents: read - -jobs: - build: - name: publish-npm - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: dsherret/rust-toolchain-file@v1 - - name: Install wasm32 target - run: rustup target add wasm32-unknown-unknown - - name: Build release - run: cargo build --target wasm32-unknown-unknown --features wasm --release - - - uses: actions/setup-node@v6 - with: - node-version: '24.x' - registry-url: 'https://registry.npmjs.org' - - name: Setup and test npm deployment - run: | - cd deployment/npm - npm install - node setup.js sync-version - npm run test - - name: npm publish - run: | - cd deployment/npm - npm publish --access public diff --git a/.github/workflows/release.generated.yml b/.github/workflows/release.generated.yml new file mode 100644 index 0000000..65df7a2 --- /dev/null +++ b/.github/workflows/release.generated.yml @@ -0,0 +1,34 @@ +# GENERATED BY ./release.ts -- DO NOT DIRECTLY EDIT + +name: release +on: + workflow_dispatch: + inputs: + releaseKind: + description: Kind of release + default: minor + type: choice + options: + - patch + - minor + required: true +jobs: + rust: + name: release + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Clone repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + token: '${{ secrets.GH_DPRINTBOT_PAT }}' + - uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2 + - uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 + - name: Bump version and tag + env: + GITHUB_TOKEN: '${{ secrets.GH_DPRINTBOT_PAT }}' + GH_WORKFLOW_ACTOR: '${{ github.actor }}' + run: |- + git config user.email "${{ github.actor }}@users.noreply.github.com" + git config user.name "${{ github.actor }}" + deno run -A jsr:@dprint/automation@0.10.3/tasks/publish-release --${{ github.event.inputs.releaseKind }} diff --git a/.github/workflows/release.ts b/.github/workflows/release.ts new file mode 100755 index 0000000..af09719 --- /dev/null +++ b/.github/workflows/release.ts @@ -0,0 +1,53 @@ +#!/usr/bin/env -S deno run -A +import { expr, workflow } from "jsr:@david/gagen@^0.5.0"; + +const releaseKind = expr("github.event.inputs.releaseKind"); +const actor = expr("github.actor"); + +workflow({ + name: "release", + on: { + workflow_dispatch: { + inputs: { + releaseKind: { + description: "Kind of release", + default: "minor", + type: "choice", + options: ["patch", "minor"], + required: true, + }, + }, + }, + }, + jobs: [{ + id: "rust", + name: "release", + runsOn: "ubuntu-latest", + timeoutMinutes: 30, + steps: [ + { + name: "Clone repository", + uses: "actions/checkout@v6", + with: { token: "${{ secrets.GH_DPRINTBOT_PAT }}" }, + }, + { uses: "denoland/setup-deno@v2" }, + { uses: "dsherret/rust-toolchain-file@v1" }, + { + name: "Bump version and tag", + env: { + GITHUB_TOKEN: "${{ secrets.GH_DPRINTBOT_PAT }}", + GH_WORKFLOW_ACTOR: actor, + }, + run: [ + `git config user.email "${actor}@users.noreply.github.com"`, + `git config user.name "${actor}"`, + `deno run -A jsr:@dprint/automation@0.10.3/tasks/publish-release --${releaseKind}`, + ], + }, + ], + }], +}).writeOrLint({ + filePath: new URL("./release.generated.yml", import.meta.url), + header: "# GENERATED BY ./release.ts -- DO NOT DIRECTLY EDIT", + pinDeps: true, +}); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 05dc25d..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: release - -on: - workflow_dispatch: - inputs: - releaseKind: - description: 'Kind of release' - default: 'minor' - type: choice - options: - - patch - - minor - required: true - -jobs: - rust: - name: release - runs-on: ubuntu-latest - timeout-minutes: 30 - - steps: - - name: Clone repository - uses: actions/checkout@v6 - with: - token: ${{ secrets.GH_DPRINTBOT_PAT }} - - - uses: denoland/setup-deno@v2 - - uses: dsherret/rust-toolchain-file@v1 - - - name: Bump version and tag - env: - GITHUB_TOKEN: ${{ secrets.GH_DPRINTBOT_PAT }} - GH_WORKFLOW_ACTOR: ${{ github.actor }} - run: | - git config user.email "${{ github.actor }}@users.noreply.github.com" - git config user.name "${{ github.actor }}" - deno run -A jsr:@dprint/automation@0.10.3/tasks/publish-release --${{github.event.inputs.releaseKind}} From 6fd9dcd6c97fcfe326006357435c52020166c572 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 24 May 2026 10:00:42 -0400 Subject: [PATCH 6/6] ci: re-trigger workflow