From fc5e9d3c74368726ce1a2053f1cb94ade3898d6d Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 21:25:46 -0500 Subject: [PATCH 01/11] check versions --- .github/workflows/build.yml | 15 +++++++++++++++ package.json | 1 + pnpm-lock.yaml | 9 +++++++++ scripts/check-version.mjs | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 scripts/check-version.mjs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d425b4..27d9d06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,22 @@ env: CARGO_TERM_COLOR: always jobs: + versions: + name: Versions + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Check versions + run: node ./scripts/check-versions.mjs + rust: name: Rust + needs: [versions] + runs-on: ubuntu-latest container: @@ -36,6 +49,8 @@ jobs: wasm: name: WASM + needs: [versions] + runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 89f64a8..4c3edce 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "Scott Bedard", "devDependencies": { "@bedard/hexchess": "link:pkg", + "smol-toml": "^1.3.0", "typescript": "^5.5.4", "vite": "^5.4.2", "vite-plugin-top-level-await": "^1.4.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 320fdb2..58ea6e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@bedard/hexchess': specifier: link:pkg version: link:pkg + smol-toml: + specifier: ^1.3.0 + version: 1.3.0 typescript: specifier: ^5.5.4 version: 5.5.4 @@ -595,6 +598,10 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + smol-toml@1.3.0: + resolution: {integrity: sha512-tWpi2TsODPScmi48b/OQZGi2lgUmBCHy6SZrhi/FdnnHiU1GwebbCfuQuxsC3nHaLwtYeJGPrDZDIeodDOc4pA==} + engines: {node: '>= 18'} + source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} @@ -1189,6 +1196,8 @@ snapshots: signal-exit@4.1.0: {} + smol-toml@1.3.0: {} + source-map-js@1.2.0: {} stackback@0.0.2: {} diff --git a/scripts/check-version.mjs b/scripts/check-version.mjs new file mode 100644 index 0000000..ef51d72 --- /dev/null +++ b/scripts/check-version.mjs @@ -0,0 +1,18 @@ +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') + + if (cargo.package.version !== npm.version) { + throw new Error('Cargo / NPM version mismatch') + } +} + +run() From 3f5f9824206126c0de7bd3cf282744df631a0b1f Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 21:26:35 -0500 Subject: [PATCH 02/11] ci --- scripts/{check-version.mjs => check-versions.mjs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{check-version.mjs => check-versions.mjs} (100%) diff --git a/scripts/check-version.mjs b/scripts/check-versions.mjs similarity index 100% rename from scripts/check-version.mjs rename to scripts/check-versions.mjs From 9d755f8cbfaa0745d19764b3e77f336f0f8323f4 Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 21:28:28 -0500 Subject: [PATCH 03/11] ci --- .github/workflows/build.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27d9d06..fa4f640 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,13 +11,22 @@ env: jobs: versions: - name: 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 @@ -56,10 +65,10 @@ 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 - name: Install dependencies From 8813157e2545c3dde74425d27b553b71f348213b Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 21:29:50 -0500 Subject: [PATCH 04/11] 0.5.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee33123..9b2772b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,7 +146,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hexchess" -version = "0.1.0" +version = "0.5.0" dependencies = [ "clap", "console_error_panic_hook", diff --git a/Cargo.toml b/Cargo.toml index fe06235..9d31b74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" name = "hexchess" readme = "README.md" repository = "https://github.com/scottbedard/hexchess.rs" -version = "0.1.0" +version = "0.5.0" [features] default = ["console_error_panic_hook"] From b9a725ca74ea2c61918ec25b03aa939fc28ee000 Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 21:34:45 -0500 Subject: [PATCH 05/11] ci --- .github/workflows/build.yml | 4 ---- .github/workflows/release.yml | 32 ++++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa4f640..21748ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,8 +33,6 @@ jobs: rust: name: Rust - needs: [versions] - runs-on: ubuntu-latest container: @@ -58,8 +56,6 @@ jobs: wasm: name: WASM - needs: [versions] - runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 437a3c3..c31cd97 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 + 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/wasm-pack-action@v0.4.0 @@ -54,7 +74,7 @@ jobs: publish: name: Publish - needs: [rust, wasm] + needs: [versions, rust, wasm] runs-on: ubuntu-latest @@ -65,10 +85,10 @@ 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: jetli/wasm-pack-action@v0.4.0 From 4bca5964cca4c8f23fcfba1ea65d2499769fc326 Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 21:47:39 -0500 Subject: [PATCH 06/11] ci --- .github/workflows/release.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c31cd97..705078c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,6 +90,8 @@ jobs: with: version: 9 run_install: false + + - uses: dtolnay/rust-toolchain@stable - uses: jetli/wasm-pack-action@v0.4.0 with: @@ -101,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: | - cd ./pkg - npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + cargo login ${{ secrets.CARGO_TOKEN }} + cargo publish --dry-run From 2be4382701b8270d49af94a1ef6679981a4a8ba9 Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 22:06:17 -0500 Subject: [PATCH 07/11] ci --- scripts/check-versions.mjs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/check-versions.mjs b/scripts/check-versions.mjs index ef51d72..09bce92 100644 --- a/scripts/check-versions.mjs +++ b/scripts/check-versions.mjs @@ -4,15 +4,43 @@ 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('Cargo / NPM version mismatch') + 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() From 5cc74d66e04d5cfbd8755f61740507bd3485ab86 Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 22:08:05 -0500 Subject: [PATCH 08/11] ci --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 705078c..e31c2f4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: run: pnpm install - name: Check versions - run: node ./scripts/check-versions.mjs + run: node ./scripts/check-versions.mjs release=${{ github.ref_name }} rust: name: Rust From a6532645459908c4f99aeb896887f79aff9fdf3c Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 22:11:02 -0500 Subject: [PATCH 09/11] 0.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c3edce..48e88a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bedard/hexchess", - "version": "0.5.0", + "version": "0.5.1", "description": "", "scripts": { "build": "wasm-pack build --release && node scripts/build.mjs", From 9c840ccae7a7d7f57a0f9222dcd97f40da4ff1b9 Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 22:12:00 -0500 Subject: [PATCH 10/11] 0.5.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b2772b..808283c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,7 +146,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hexchess" -version = "0.5.0" +version = "0.5.1" dependencies = [ "clap", "console_error_panic_hook", diff --git a/Cargo.toml b/Cargo.toml index 9d31b74..6b5c50a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" name = "hexchess" readme = "README.md" repository = "https://github.com/scottbedard/hexchess.rs" -version = "0.5.0" +version = "0.5.1" [features] default = ["console_error_panic_hook"] From 372da3a26db4d59f882af39abc2339aba889d81e Mon Sep 17 00:00:00 2001 From: Scott Bedard Date: Tue, 3 Sep 2024 22:23:50 -0500 Subject: [PATCH 11/11] ci --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e31c2f4..d1a6c5f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,14 +103,14 @@ jobs: - name: Build wasm package run: pnpm build - # - name: Publish to NPM - # run: | - # cd ./pkg - # npm publish --access public - # env: - # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - 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 --dry-run + cargo publish