|
| 1 | +name: Publish client packages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + rust_api: |
| 7 | + description: Publish the Rust API client |
| 8 | + type: boolean |
| 9 | + default: false |
| 10 | + npm_api: |
| 11 | + description: Publish the npm API client |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + npm_tracker: |
| 15 | + description: Publish the npm tracker |
| 16 | + type: boolean |
| 17 | + default: false |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + check-selection: |
| 24 | + if: '!inputs.rust_api && !inputs.npm_api && !inputs.npm_tracker' |
| 25 | + runs-on: ubuntu-24.04 |
| 26 | + steps: |
| 27 | + - run: | |
| 28 | + echo 'Select at least one client package to publish.' >&2 |
| 29 | + exit 1 |
| 30 | +
|
| 31 | + publish-rust: |
| 32 | + if: github.ref == 'refs/heads/main' && inputs.rust_api |
| 33 | + runs-on: ubuntu-24.04 |
| 34 | + environment: client-release |
| 35 | + permissions: |
| 36 | + contents: read |
| 37 | + id-token: write |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 40 | + with: |
| 41 | + persist-credentials: false |
| 42 | + - uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2.0.0 |
| 43 | + - run: cargo test -p liwan-api --all-features --locked |
| 44 | + - uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 |
| 45 | + id: auth |
| 46 | + - run: cargo publish -p liwan-api --locked |
| 47 | + env: |
| 48 | + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |
| 49 | + |
| 50 | + publish-npm: |
| 51 | + if: github.ref == 'refs/heads/main' && (inputs.npm_api || inputs.npm_tracker) |
| 52 | + runs-on: ubuntu-24.04 |
| 53 | + environment: client-release |
| 54 | + permissions: |
| 55 | + contents: read |
| 56 | + id-token: write |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 59 | + with: |
| 60 | + persist-credentials: false |
| 61 | + - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 |
| 62 | + with: |
| 63 | + node-version: "24" |
| 64 | + registry-url: https://registry.npmjs.org |
| 65 | + package-manager-cache: false |
| 66 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 67 | + with: |
| 68 | + bun-version: latest |
| 69 | + no-cache: true |
| 70 | + - run: bun install --frozen-lockfile |
| 71 | + - name: Test and build API client |
| 72 | + if: inputs.npm_api |
| 73 | + run: | |
| 74 | + bun run --cwd packages/api test |
| 75 | + bun run --cwd packages/api typecheck |
| 76 | + bun run --cwd packages/api build |
| 77 | + - name: Build tracker |
| 78 | + if: inputs.npm_tracker |
| 79 | + run: | |
| 80 | + bun run --cwd packages/tracker typecheck |
| 81 | + bun run --cwd packages/tracker build |
| 82 | + - name: Publish API client |
| 83 | + if: inputs.npm_api |
| 84 | + working-directory: packages/api |
| 85 | + run: npm publish --access public |
| 86 | + - name: Publish tracker |
| 87 | + if: inputs.npm_tracker |
| 88 | + working-directory: packages/tracker |
| 89 | + run: npm publish --access public |
0 commit comments