-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from scottbedard/check-versions
check versions
- Loading branch information
Showing
7 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,26 @@ env: | |
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
versions: | ||
name: Check versions | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Check versions | ||
run: node ./scripts/check-versions.mjs release=${{ github.ref_name }} | ||
|
||
rust: | ||
name: Rust | ||
|
||
|
@@ -31,11 +51,11 @@ jobs: | |
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v2 | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
version: 8 | ||
version: 9 | ||
run_install: false | ||
|
||
- uses: jetli/[email protected] | ||
|
@@ -54,7 +74,7 @@ jobs: | |
publish: | ||
name: Publish | ||
|
||
needs: [rust, wasm] | ||
needs: [versions, rust, wasm] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
|
@@ -65,11 +85,13 @@ jobs: | |
with: | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- uses: pnpm/action-setup@v2 | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
version: 8 | ||
version: 9 | ||
run_install: false | ||
|
||
- uses: dtolnay/rust-toolchain@stable | ||
|
||
- uses: jetli/[email protected] | ||
with: | ||
|
@@ -81,9 +103,14 @@ jobs: | |
- name: Build wasm package | ||
run: pnpm build | ||
|
||
- name: Publish | ||
- name: Publish to NPM | ||
run: | | ||
cd ./pkg | ||
npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Publish to Crates.io | ||
run: | | ||
cargo login ${{ secrets.CARGO_TOKEN }} | ||
cargo publish |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { fileURLToPath } from 'url' | ||
import fs from 'fs' | ||
import path from 'path' | ||
import toml from 'smol-toml' | ||
|
||
function run() { | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
|
||
const cargo = toml.parse(fs.readFileSync(path.resolve(__dirname, '../Cargo.toml'), 'utf-8')) | ||
const npm = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json')), 'utf-8') | ||
|
||
console.log('Checking versions...') | ||
console.log() | ||
console.log(`Cargo: ${cargo.package.version}`) | ||
console.log(`NPM: ${npm.version}`) | ||
|
||
if (cargo.package.version !== npm.version) { | ||
throw new Error(`Version mismatch [npm: ${npm.version}, cargo: ${cargo.package.version}]`) | ||
} | ||
|
||
let releasing = false | ||
|
||
for (const arg of process.argv) { | ||
if (arg.startsWith('release=')) { | ||
const release = arg.slice(8) | ||
|
||
if (release !== npm.version) { | ||
throw new Error(`Release version mismatch [${release}]`) | ||
} | ||
|
||
console.log(`Release: ${release}`) | ||
releasing = true | ||
} | ||
} | ||
|
||
if (!releasing) { | ||
console.log('Release: \x1b[2mNone') | ||
} | ||
|
||
console.log() | ||
console.log('\x1b[32mSuccess') | ||
} | ||
|
||
run() |