Skip to content

Commit ecb02eb

Browse files
cursoragentlovasoa
andcommitted
feat: Add CI workflow for publishing and dry-runs
Co-authored-by: contact <[email protected]>
1 parent d82bd8e commit ecb02eb

File tree

11 files changed

+109
-0
lines changed

11 files changed

+109
-0
lines changed

.github/workflows/publish.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
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
184
on:
285
workflow_dispatch: {}
386
push:

examples/mysql/todos/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sqlx-example-mysql-todos"
33
version = "0.1.0"
44
edition = "2021"
5+
publish = false
56
workspace = "../../../"
67

78
[dependencies]

examples/postgres/axum-social-with-tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sqlx-example-postgres-axum-social"
33
version = "0.1.0"
44
edition = "2021"
5+
publish = false
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

examples/postgres/files/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "files"
33
version = "0.1.0"
44
edition = "2021"
5+
publish = false
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

examples/postgres/json/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "json"
33
version = "0.1.0"
44
edition = "2021"
5+
publish = false
56
workspace = "../../../"
67

78
[dependencies]

examples/postgres/listen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sqlx-example-postgres-listen"
33
version = "0.1.0"
44
edition = "2021"
5+
publish = false
56
workspace = "../../../"
67

78
[dependencies]

examples/postgres/mockable-todos/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sqlx-example-postgres-mockable-todos"
33
version = "0.1.0"
44
edition = "2021"
5+
publish = false
56
workspace = "../../../"
67

78
[dependencies]

examples/postgres/todos/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sqlx-example-postgres-todos"
33
version = "0.1.0"
44
edition = "2018"
5+
publish = false
56
workspace = "../../../"
67

78
[dependencies]

examples/postgres/transaction/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sqlx-example-postgres-transaction"
33
version = "0.1.0"
44
edition = "2021"
5+
publish = false
56
workspace = "../../../"
67

78
[dependencies]

examples/sqlite/todos/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sqlx-example-sqlite-todos"
33
version = "0.1.0"
44
edition = "2018"
5+
publish = false
56
workspace = "../../../"
67

78
[dependencies]

0 commit comments

Comments
 (0)