Merge pull request #764 from bergie/npm_packaging #24
This file contains hidden or 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
| name: Publish to Cargo & JSR | |
| on: | |
| push: | |
| # tags: | |
| # - "**" | |
| permissions: write-all | |
| jobs: | |
| codegen: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: debug | |
| run: cat packages/ts/deno.json && cat packages/rust/Cargo.toml && cat packages/ts/package.json | |
| - name: Set Package Versions to current tag | |
| # run: sed -i "s/__PACKAGE_VERSION__/$(echo $GITHUB_REF | cut -d '/' -f 3)/g" packages/ts/deno.json \ | |
| # && sed -i "s/__PACKAGE_VERSION__/$(echo $GITHUB_REF | cut -d '/' -f 3)/g" packages/ts/package.json \ | |
| # && sed -i "s/__PACKAGE_VERSION__/$(echo $GITHUB_REF | cut -d '/' -f 3)/g" packages/rust/Cargo.toml | |
| run: | | |
| sed -i "s/__PACKAGE_VERSION__/2.7.0/g" packages/ts/deno.json | |
| sed -i "s/__PACKAGE_VERSION__/2.7.0/g" packages/ts/package.json | |
| sed -i "s/__PACKAGE_VERSION__/2.7.0/g" packages/rust/Cargo.toml | |
| - name: Setup Buf | |
| uses: bufbuild/buf-setup-action@main | |
| with: | |
| github_token: ${{ github.token }} | |
| - name: Generate code | |
| run: buf generate | |
| - name: Copy license & README | |
| run: | | |
| cp LICENSE packages/ts | |
| cp LICENSE packages/rust | |
| cp README.md packages/ts | |
| cp README.md packages/rust | |
| - name: Upload Rust code | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rust_code | |
| path: packages/rust | |
| - name: Upload TypeScript code | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ts_code | |
| path: packages/ts | |
| - name: Upload C code | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: c_code | |
| path: packages/c | |
| publish-jsr: | |
| runs-on: ubuntu-24.04 | |
| needs: codegen | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download TypeScript code | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ts_code | |
| - name: Set up Deno | |
| uses: denoland/setup-deno@main | |
| with: | |
| deno-version: rc | |
| - name: Publish to JSR | |
| run: deno publish --unstable-sloppy-imports | |
| publish-npm: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download TypeScript code | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ts_code | |
| - name: Install Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: lts/* | |
| registry-url: https://registry.npmjs.org/ | |
| - name: Install NPM dependencies | |
| run: npm install | |
| - name: Build JavaScript module | |
| run: npm run build | |
| - name: Publish NPM package | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
| publish-cargo: | |
| runs-on: ubuntu-24.04 | |
| needs: codegen | |
| steps: | |
| - name: Download Rust code | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: rust_code | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Check Library | |
| run: cargo check | |
| - name: Publish to crates.io | |
| uses: katyo/publish-crates@v2 | |
| with: | |
| registry-token: ${{ secrets.CARGO_TOKEN }} | |
| ignore-unpublished-changes: true |