|
| 1 | +name: Publish workspace crates |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + dry_run: |
| 7 | + description: "Run cargo publish with --dry-run" |
| 8 | + required: false |
| 9 | + default: "false" |
| 10 | + type: choice |
| 11 | + options: ["false", "true"] |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths: |
| 16 | + - '.github/workflows/publish.yml' |
| 17 | + - '**/Cargo.toml' |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - '.github/workflows/publish.yml' |
| 21 | + - '**/Cargo.toml' |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: publish-${{ github.ref }} |
| 28 | + cancel-in-progress: false |
| 29 | + |
| 30 | +jobs: |
| 31 | + publish: |
| 32 | + name: Cargo publish (workspace) |
| 33 | + runs-on: ubuntu-latest |
| 34 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run == 'false' }} |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Install system dependencies |
| 40 | + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev | cat |
| 41 | + |
| 42 | + - name: Use latest stable Rust (dtolnay/rust-toolchain) |
| 43 | + uses: dtolnay/rust-toolchain@stable |
| 44 | + with: |
| 45 | + toolchain: stable |
| 46 | + components: '' |
| 47 | + |
| 48 | + - name: Verify cargo version |
| 49 | + run: cargo --version | tee /tmp/cargo-version.txt |
| 50 | + |
| 51 | + - name: Configure crates.io token |
| 52 | + if: ${{ inputs.dry_run != 'true' && github.event_name != 'pull_request' }} |
| 53 | + env: |
| 54 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 55 | + run: | |
| 56 | + test -n "$CARGO_REGISTRY_TOKEN" || { echo "CARGO_REGISTRY_TOKEN is not set"; exit 1; } |
| 57 | +
|
| 58 | + - name: Publish workspace |
| 59 | + env: |
| 60 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + echo "Running cargo publish --workspace" |
| 64 | + cargo publish --workspace |
| 65 | +
|
| 66 | + dry-run: |
| 67 | + name: Cargo publish dry-run (CI) |
| 68 | + runs-on: ubuntu-latest |
| 69 | + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run == 'true') }} |
| 70 | + steps: |
| 71 | + - name: Checkout |
| 72 | + uses: actions/checkout@v4 |
| 73 | + |
| 74 | + - name: Install system dependencies |
| 75 | + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev | cat |
| 76 | + |
| 77 | + - name: Use latest stable Rust (dtolnay/rust-toolchain) |
| 78 | + uses: dtolnay/rust-toolchain@stable |
| 79 | + with: |
| 80 | + toolchain: stable |
| 81 | + |
| 82 | + - name: Dry run publish (workspace) |
| 83 | + run: cargo publish --workspace --allow-dirty --dry-run --no-verify |
1 | 84 | on: |
2 | 85 | workflow_dispatch: {} |
3 | 86 | push: |
|
0 commit comments