From 3acbe7b461969f3ea23efa75ecdbb488894ee1ce Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 23 May 2026 16:14:51 -0400 Subject: [PATCH 1/2] chore: modernize CI and expand README install section - Bump actions/checkout to v6 in ci.yml and release.yml - Bump actions/setup-node to v6 in ci.yml - Bump denoland/setup-deno to v2 (with deno-version: v2.x) in ci.yml and release.yml - Replace deprecated `::set-output` with `$GITHUB_OUTPUT` in ci.yml - Use jsr:@dprint/automation@0.10.3/tasks/publish-release in release.yml - Expand README install section to mention both `dprint add typescript` and `dprint add npm:@dprint/typescript` --- .github/workflows/ci.yml | 8 +++++--- .github/workflows/release.yml | 6 +++--- README.md | 12 +++++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 758125db..e098de6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: RUST_BACKTRACE: full steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: dsherret/rust-toolchain-file@v1 - name: Install wasm32 target if: matrix.config.kind == 'test_release' @@ -69,10 +69,10 @@ 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@v2 + - uses: actions/setup-node@v6 if: matrix.config.kind == 'test_release' with: node-version: '24.x' @@ -89,6 +89,8 @@ jobs: # 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: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd631946..05dc25dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,11 +20,11 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 with: token: ${{ secrets.GH_DPRINTBOT_PAT }} - - uses: denoland/setup-deno@v1 + - uses: denoland/setup-deno@v2 - uses: dsherret/rust-toolchain-file@v1 - name: Bump version and tag @@ -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.5.1/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 a0e254e6..827658c9 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,17 @@ This uses the [swc](https://github.com/swc-project/swc) parser for TypeScript wr ## Install -See the GitHub [releases](https://github.com/dprint/dprint-plugin-typescript/releases). +[Install](https://dprint.dev/install/) and [setup](https://dprint.dev/setup/) dprint. + +Then in your project's directory with a dprint.json file, run: + +```shellsession +dprint add typescript +# or install from npm +dprint add npm:@dprint/typescript +``` + +See https://dprint.dev/plugins/typescript/ for more information. ## Development From 8a04c3e17d8dfaf6f379958e7c752909535e2eba Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 24 May 2026 09:54:00 -0400 Subject: [PATCH 2/2] chore: migrate workflows to gagen --- .github/workflows/ci.generated.yml | 106 ++++++++++++++++ .github/workflows/ci.ts | 161 ++++++++++++++++++++++++ .github/workflows/ci.yml | 113 ----------------- .github/workflows/publish.generated.yml | 45 +++++++ .github/workflows/publish.ts | 71 +++++++++++ .github/workflows/publish.yml | 47 ------- .github/workflows/release.generated.yml | 34 +++++ .github/workflows/release.ts | 53 ++++++++ .github/workflows/release.yml | 37 ------ 9 files changed, 470 insertions(+), 197 deletions(-) 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.generated.yml create mode 100755 .github/workflows/publish.ts delete mode 100644 .github/workflows/publish.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/ci.generated.yml b/.github/workflows/ci.generated.yml new file mode 100644 index 00000000..bee4e54c --- /dev/null +++ b/.github/workflows/ci.generated.yml @@ -0,0 +1,106 @@ +# 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: Lint + if: matrix.config.kind == 'test_debug' + run: cargo clippy + - name: Test debug + if: matrix.config.kind == 'test_debug' + run: cargo test + - name: Build release + if: matrix.config.kind == 'test_release' + run: cargo build --target wasm32-unknown-unknown --features "wasm" --release + - name: Test release + if: matrix.config.kind == 'test_release' + run: cargo test --release + - name: Wasm integration test - Setup + if: matrix.config.kind == 'test_release' + run: 'echo ''{ "plugins": ["./target/wasm32-unknown-unknown/release/dprint_plugin_typescript.wasm"] }'' >> dprint.test.json' + - name: Wasm integration test - Run + uses: dprint/check@2f1cf31537886c3bfb05591c031f7744e48ba8a1 # v2.2 + if: matrix.config.kind == 'test_release' + with: + config-path: dprint.test.json + - name: Wasm integration test - Cleanup + if: matrix.config.kind == 'test_release' + run: rm dprint.test.json + - 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/typescript\/0.0.0/typescript\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json + # rename the wasm file + (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_typescript.wasm plugin.wasm) + # create release notes + deno run -A ./scripts/generate_release_notes.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.ts --lint + ./.github/workflows/release.ts --lint diff --git a/.github/workflows/ci.ts b/.github/workflows/ci.ts new file mode 100755 index 00000000..893d834e --- /dev/null +++ b/.github/workflows/ci.ts @@ -0,0 +1,161 @@ +#!/usr/bin/env -S deno run -A +import { conditions, defineMatrix, expr, job, step, workflow } from "jsr:@david/gagen@^0.5.0"; + +const pluginName = "typescript"; +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: "Lint", if: isDebug, run: "cargo clippy" }, + { name: "Test debug", if: isDebug, run: "cargo test" }, + + { + name: "Build release", + if: isRelease, + run: `cargo build --target wasm32-unknown-unknown --features "wasm" --release`, + }, + { name: "Test release", if: isRelease, run: "cargo test --release" }, + + // wasm integration test (typescript-specific) + { + name: "Wasm integration test - Setup", + if: isRelease, + run: + `echo '{ "plugins": ["./target/wasm32-unknown-unknown/release/${cargoWasmName}.wasm"] }' >> dprint.test.json`, + }, + { + name: "Wasm integration test - Run", + if: isRelease, + uses: "dprint/check@v2.2", + with: { "config-path": "dprint.test.json" }, + }, + { + name: "Wasm integration test - Cleanup", + if: isRelease, + run: "rm dprint.test.json", + }, + + 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/generate_release_notes.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.ts --lint", + "./.github/workflows/release.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 e098de6f..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,113 +0,0 @@ -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@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: Lint - if: matrix.config.kind == 'test_debug' - run: cargo clippy - - name: Test debug - if: matrix.config.kind == 'test_debug' - run: cargo test - - - name: Build release - if: matrix.config.kind == 'test_release' - run: cargo build --target wasm32-unknown-unknown --features "wasm" --release - - name: Test release - if: matrix.config.kind == 'test_release' - run: cargo test --release - - name: Wasm integration test - Setup - if: matrix.config.kind == 'test_release' - run: | - echo '{ "plugins": ["./target/wasm32-unknown-unknown/release/dprint_plugin_typescript.wasm"] }' >> dprint.test.json - - name: Wasm integration test - Run - if: matrix.config.kind == 'test_release' - uses: dprint/check@v2.2 - with: - config-path: dprint.test.json - - name: Wasm integration test - Cleanup - if: matrix.config.kind == 'test_release' - run: rm dprint.test.json - - - 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/typescript\/0.0.0/typescript\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json - # rename the wasm file - (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_typescript.wasm plugin.wasm) - # create release notes - deno run -A ./scripts/generate_release_notes.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 diff --git a/.github/workflows/publish.generated.yml b/.github/workflows/publish.generated.yml new file mode 100644 index 00000000..3289e672 --- /dev/null +++ b/.github/workflows/publish.generated.yml @@ -0,0 +1,45 @@ +# GENERATED BY ./publish.ts -- DO NOT DIRECTLY EDIT + +name: publish +on: + workflow_dispatch: {} + push: + tags: + - '*' +permissions: + id-token: write + contents: read +jobs: + cargo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 + - id: auth + uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1 + - name: Cargo publish + env: + CARGO_REGISTRY_TOKEN: '${{ steps.auth.outputs.token }}' + run: cargo 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 + - name: npm publish + run: |- + cd deployment/npm + npm publish --access public diff --git a/.github/workflows/publish.ts b/.github/workflows/publish.ts new file mode 100755 index 00000000..adb1cab7 --- /dev/null +++ b/.github/workflows/publish.ts @@ -0,0 +1,71 @@ +#!/usr/bin/env -S deno run -A +import { job, step, workflow } from "jsr:@david/gagen@^0.5.0"; + +const auth = step({ + id: "auth", + uses: "rust-lang/crates-io-auth-action@v1", + outputs: ["token"], +}); + +const cargoJob = job("cargo", { + runsOn: "ubuntu-latest", + steps: [ + { uses: "actions/checkout@v6" }, + { uses: "dsherret/rust-toolchain-file@v1" }, + auth, + { + name: "Cargo publish", + env: { CARGO_REGISTRY_TOKEN: auth.outputs.token }, + run: "cargo publish", + }, + ], +}); + +const npmJob = job("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", + ], + }, + { + name: "npm publish", + run: [ + "cd deployment/npm", + "npm publish --access public", + ], + }, + ], +}); + +workflow({ + name: "publish", + on: { + workflow_dispatch: {}, + push: { tags: ["*"] }, + }, + permissions: { "id-token": "write", contents: "read" }, + jobs: [cargoJob, npmJob], +}).writeOrLint({ + filePath: new URL("./publish.generated.yml", import.meta.url), + header: "# GENERATED BY ./publish.ts -- DO NOT DIRECTLY EDIT", + pinDeps: true, +}); diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index c1d05d0a..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: publish - -on: - workflow_dispatch: - push: - tags: - - '*' - -permissions: - id-token: write - contents: read - -jobs: - cargo: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: dsherret/rust-toolchain-file@v1 - - uses: rust-lang/crates-io-auth-action@v1 - id: auth - - name: Cargo publish - env: - CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} - run: cargo 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 - - 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 00000000..65df7a2d --- /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 00000000..af097198 --- /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 05dc25dd..00000000 --- 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}}