|
1 | 1 | name: Publish workspace crates |
2 | 2 |
|
3 | 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 | 4 | push: |
13 | 5 | branches: |
14 | | - - main |
15 | | - paths: |
16 | | - - '.github/workflows/publish.yml' |
17 | | - - '**/Cargo.toml' |
| 6 | + - '**' |
| 7 | + tags: |
| 8 | + - '*' |
18 | 9 | 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 |
| 10 | + branches: |
| 11 | + - '**' |
29 | 12 |
|
30 | 13 | jobs: |
31 | 14 | publish: |
32 | | - name: Cargo publish (workspace) |
33 | 15 | runs-on: ubuntu-latest |
34 | | - if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run == 'false' }} |
35 | 16 | steps: |
36 | 17 | - name: Checkout |
37 | 18 | uses: actions/checkout@v4 |
38 | 19 |
|
39 | | - - name: Install system dependencies |
40 | | - run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev | cat |
41 | | - |
42 | 20 | - name: Use latest stable Rust (dtolnay/rust-toolchain) |
43 | 21 | uses: dtolnay/rust-toolchain@stable |
44 | 22 | with: |
45 | 23 | toolchain: stable |
46 | | - components: '' |
47 | 24 |
|
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; } |
| 25 | + - name: Dry run workspace publish |
| 26 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 27 | + run: cargo publish --workspace --dry-run --no-verify |
57 | 28 |
|
58 | 29 | - name: Publish workspace |
| 30 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
59 | 31 | env: |
60 | 32 | 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 |
| 33 | + run: cargo publish --workspace |
84 | 34 | on: |
85 | 35 | workflow_dispatch: {} |
86 | 36 | push: |
|
0 commit comments