From ecb02eb2e932ce771694e121536e97ec1c721ce2 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 24 Sep 2025 11:27:39 +0000 Subject: [PATCH 1/8] feat: Add CI workflow for publishing and dry-runs Co-authored-by: contact --- .github/workflows/publish.yml | 83 +++++++++++++++++++ examples/mysql/todos/Cargo.toml | 1 + .../axum-social-with-tests/Cargo.toml | 1 + examples/postgres/files/Cargo.toml | 1 + examples/postgres/json/Cargo.toml | 1 + examples/postgres/listen/Cargo.toml | 1 + examples/postgres/mockable-todos/Cargo.toml | 1 + examples/postgres/todos/Cargo.toml | 1 + examples/postgres/transaction/Cargo.toml | 1 + examples/sqlite/todos/Cargo.toml | 1 + scripts/publish-dry-run.sh | 17 ++++ 11 files changed, 109 insertions(+) create mode 100644 scripts/publish-dry-run.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 97bfb7c769..905727e666 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,3 +1,86 @@ +name: Publish workspace crates + +on: + workflow_dispatch: + inputs: + dry_run: + description: "Run cargo publish with --dry-run" + required: false + default: "false" + type: choice + options: ["false", "true"] + push: + branches: + - main + paths: + - '.github/workflows/publish.yml' + - '**/Cargo.toml' + pull_request: + paths: + - '.github/workflows/publish.yml' + - '**/Cargo.toml' + +permissions: + contents: read + +concurrency: + group: publish-${{ github.ref }} + cancel-in-progress: false + +jobs: + publish: + name: Cargo publish (workspace) + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run == 'false' }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev | cat + + - name: Use latest stable Rust (dtolnay/rust-toolchain) + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + components: '' + + - name: Verify cargo version + run: cargo --version | tee /tmp/cargo-version.txt + + - name: Configure crates.io token + if: ${{ inputs.dry_run != 'true' && github.event_name != 'pull_request' }} + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: | + test -n "$CARGO_REGISTRY_TOKEN" || { echo "CARGO_REGISTRY_TOKEN is not set"; exit 1; } + + - name: Publish workspace + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: | + set -euo pipefail + echo "Running cargo publish --workspace" + cargo publish --workspace + + dry-run: + name: Cargo publish dry-run (CI) + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run == 'true') }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev | cat + + - name: Use latest stable Rust (dtolnay/rust-toolchain) + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Dry run publish (workspace) + run: cargo publish --workspace --allow-dirty --dry-run --no-verify on: workflow_dispatch: {} push: diff --git a/examples/mysql/todos/Cargo.toml b/examples/mysql/todos/Cargo.toml index 7b8f8da467..0412c9eb99 100644 --- a/examples/mysql/todos/Cargo.toml +++ b/examples/mysql/todos/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlx-example-mysql-todos" version = "0.1.0" edition = "2021" +publish = false workspace = "../../../" [dependencies] diff --git a/examples/postgres/axum-social-with-tests/Cargo.toml b/examples/postgres/axum-social-with-tests/Cargo.toml index 911022cd7f..ab19877239 100644 --- a/examples/postgres/axum-social-with-tests/Cargo.toml +++ b/examples/postgres/axum-social-with-tests/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlx-example-postgres-axum-social" version = "0.1.0" edition = "2021" +publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/examples/postgres/files/Cargo.toml b/examples/postgres/files/Cargo.toml index 2267e0442c..85fa3ecc99 100644 --- a/examples/postgres/files/Cargo.toml +++ b/examples/postgres/files/Cargo.toml @@ -2,6 +2,7 @@ name = "files" version = "0.1.0" edition = "2021" +publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/examples/postgres/json/Cargo.toml b/examples/postgres/json/Cargo.toml index 0feeda419e..23bfaab94f 100644 --- a/examples/postgres/json/Cargo.toml +++ b/examples/postgres/json/Cargo.toml @@ -2,6 +2,7 @@ name = "json" version = "0.1.0" edition = "2021" +publish = false workspace = "../../../" [dependencies] diff --git a/examples/postgres/listen/Cargo.toml b/examples/postgres/listen/Cargo.toml index dd7941ea67..82077a7e4e 100644 --- a/examples/postgres/listen/Cargo.toml +++ b/examples/postgres/listen/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlx-example-postgres-listen" version = "0.1.0" edition = "2021" +publish = false workspace = "../../../" [dependencies] diff --git a/examples/postgres/mockable-todos/Cargo.toml b/examples/postgres/mockable-todos/Cargo.toml index b25aa82fd8..dcb950a0ce 100644 --- a/examples/postgres/mockable-todos/Cargo.toml +++ b/examples/postgres/mockable-todos/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlx-example-postgres-mockable-todos" version = "0.1.0" edition = "2021" +publish = false workspace = "../../../" [dependencies] diff --git a/examples/postgres/todos/Cargo.toml b/examples/postgres/todos/Cargo.toml index 999b54100b..6f05fad314 100644 --- a/examples/postgres/todos/Cargo.toml +++ b/examples/postgres/todos/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlx-example-postgres-todos" version = "0.1.0" edition = "2018" +publish = false workspace = "../../../" [dependencies] diff --git a/examples/postgres/transaction/Cargo.toml b/examples/postgres/transaction/Cargo.toml index 8f058a2de2..5c0047f04b 100644 --- a/examples/postgres/transaction/Cargo.toml +++ b/examples/postgres/transaction/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlx-example-postgres-transaction" version = "0.1.0" edition = "2021" +publish = false workspace = "../../../" [dependencies] diff --git a/examples/sqlite/todos/Cargo.toml b/examples/sqlite/todos/Cargo.toml index 24c5333196..a48df4b11d 100644 --- a/examples/sqlite/todos/Cargo.toml +++ b/examples/sqlite/todos/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlx-example-sqlite-todos" version = "0.1.0" edition = "2018" +publish = false workspace = "../../../" [dependencies] diff --git a/scripts/publish-dry-run.sh b/scripts/publish-dry-run.sh new file mode 100644 index 0000000000..e5e980f973 --- /dev/null +++ b/scripts/publish-dry-run.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Ensure we are at repo root +cd "$(dirname "$0")/.." + +if [ -f "/usr/local/cargo/env" ]; then + . "/usr/local/cargo/env" +fi +if command -v rustup >/dev/null 2>&1; then + rustup show >/dev/null 2>&1 || true +fi + +echo "cargo version: $(cargo --version)" +echo "Running: cargo publish --workspace --allow-dirty --dry-run --no-verify" +cargo publish --workspace --allow-dirty --dry-run --no-verify +echo "Dry-run finished" From 9c3d9252de5666dd179255b2847b579aec78c36d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 24 Sep 2025 12:36:17 +0000 Subject: [PATCH 2/8] Refactor publish workflow and remove dry-run script Co-authored-by: contact --- .github/workflows/publish.yml | 70 +++++------------------------------ scripts/publish-dry-run.sh | 17 --------- 2 files changed, 10 insertions(+), 77 deletions(-) delete mode 100644 scripts/publish-dry-run.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 905727e666..643b4a43c7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,86 +1,36 @@ name: Publish workspace crates on: - workflow_dispatch: - inputs: - dry_run: - description: "Run cargo publish with --dry-run" - required: false - default: "false" - type: choice - options: ["false", "true"] push: branches: - - main - paths: - - '.github/workflows/publish.yml' - - '**/Cargo.toml' + - '**' + tags: + - '*' pull_request: - paths: - - '.github/workflows/publish.yml' - - '**/Cargo.toml' - -permissions: - contents: read - -concurrency: - group: publish-${{ github.ref }} - cancel-in-progress: false + branches: + - '**' jobs: publish: - name: Cargo publish (workspace) runs-on: ubuntu-latest - if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run == 'false' }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev | cat - - name: Use latest stable Rust (dtolnay/rust-toolchain) uses: dtolnay/rust-toolchain@stable with: toolchain: stable - components: '' - - name: Verify cargo version - run: cargo --version | tee /tmp/cargo-version.txt - - - name: Configure crates.io token - if: ${{ inputs.dry_run != 'true' && github.event_name != 'pull_request' }} - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: | - test -n "$CARGO_REGISTRY_TOKEN" || { echo "CARGO_REGISTRY_TOKEN is not set"; exit 1; } + - name: Dry run workspace publish + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + run: cargo publish --workspace --dry-run --no-verify - name: Publish workspace + if: ${{ startsWith(github.ref, 'refs/tags/') }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: | - set -euo pipefail - echo "Running cargo publish --workspace" - cargo publish --workspace - - dry-run: - name: Cargo publish dry-run (CI) - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run == 'true') }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev | cat - - - name: Use latest stable Rust (dtolnay/rust-toolchain) - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - - - name: Dry run publish (workspace) - run: cargo publish --workspace --allow-dirty --dry-run --no-verify + run: cargo publish --workspace on: workflow_dispatch: {} push: diff --git a/scripts/publish-dry-run.sh b/scripts/publish-dry-run.sh deleted file mode 100644 index e5e980f973..0000000000 --- a/scripts/publish-dry-run.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Ensure we are at repo root -cd "$(dirname "$0")/.." - -if [ -f "/usr/local/cargo/env" ]; then - . "/usr/local/cargo/env" -fi -if command -v rustup >/dev/null 2>&1; then - rustup show >/dev/null 2>&1 || true -fi - -echo "cargo version: $(cargo --version)" -echo "Running: cargo publish --workspace --allow-dirty --dry-run --no-verify" -cargo publish --workspace --allow-dirty --dry-run --no-verify -echo "Dry-run finished" From dbeb10687a40f30b4d07b1ee04414e0d22311911 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 24 Sep 2025 15:42:03 +0000 Subject: [PATCH 3/8] Refine publish workflow to only publish tagged versions Co-authored-by: contact --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 643b4a43c7..3c87db5737 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,11 +23,11 @@ jobs: toolchain: stable - name: Dry run workspace publish - if: ${{ !startsWith(github.ref, 'refs/tags/') }} - run: cargo publish --workspace --dry-run --no-verify + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + run: cargo publish --workspace --dry-run - name: Publish workspace - if: ${{ startsWith(github.ref, 'refs/tags/') }} + if: ${{ startsWith(github.ref, 'refs/tags/v') }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} run: cargo publish --workspace From 4bfe6321c15b7ecfd42ba0dd4d3d894586ce5244 Mon Sep 17 00:00:00 2001 From: lovasoa Date: Wed, 24 Sep 2025 17:59:48 +0200 Subject: [PATCH 4/8] simple publish workspace with dry run --- .github/workflows/publish.yml | 57 ++++++++--------------------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3c87db5737..b67e29d92d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,59 +1,26 @@ name: Publish workspace crates on: + workflow_dispatch: {} push: - branches: - - '**' + paths: + - "**/Cargo.toml" + - ".github/workflows/publish.yml" tags: - - '*' + - "v*" pull_request: - branches: - - '**' + paths: + - "**/Cargo.toml" + - ".github/workflows/publish.yml" jobs: publish: runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Use latest stable Rust (dtolnay/rust-toolchain) - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - - - name: Dry run workspace publish - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} - run: cargo publish --workspace --dry-run - - - name: Publish workspace - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: cargo publish --workspace -on: - workflow_dispatch: {} - push: - # Sequence of patterns matched against refs/tags - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - -name: Publish - -jobs: - publish: - name: Publish - runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - run: | - cargo publish ${ARGS} --package sqlx-rt-oldapi - cargo publish ${ARGS} --package sqlx-core-oldapi - cargo publish ${ARGS} --package sqlx-macros-oldapi - cargo publish ${ARGS} --package sqlx-oldapi + - name: Publish workspace + run: cargo publish ${DRY} --workspace --token ${{ secrets.CRATES_TOKEN }} --no-default-features --features runtime-actix-rustls env: - ARGS: - --token ${{ secrets.CRATES_TOKEN }} - --no-default-features - --features runtime-actix-rustls + DRY: ${{ startsWith(github.ref, 'refs/tags/v') && '--dry-run' || '' }} From 3e227856f3ea0acd2beafa64cb083ae1a53bd786 Mon Sep 17 00:00:00 2001 From: lovasoa Date: Wed, 24 Sep 2025 18:06:17 +0200 Subject: [PATCH 5/8] Refactor publish workflow for improved readability and maintainability --- .github/workflows/publish.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b67e29d92d..6d27d92d87 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,10 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: Publish workspace - run: cargo publish ${DRY} --workspace --token ${{ secrets.CRATES_TOKEN }} --no-default-features --features runtime-actix-rustls - env: - DRY: ${{ startsWith(github.ref, 'refs/tags/v') && '--dry-run' || '' }} + run: | + cargo publish \ + ${{ startsWith(github.ref, 'refs/tags/v') && '--dry-run' || '' }} \ + --workspace \ + --token ${{ secrets.CRATES_TOKEN }} \ + --no-default-features \ + --features runtime-actix-rustls From 0d872dfab1971c39d952152ae7e48976f642ce4e Mon Sep 17 00:00:00 2001 From: lovasoa Date: Wed, 24 Sep 2025 18:14:18 +0200 Subject: [PATCH 6/8] Fix publish workflow to correctly handle dry-run flag for non-tagged versions --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6d27d92d87..81fe1c4157 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,7 +23,7 @@ jobs: - name: Publish workspace run: | cargo publish \ - ${{ startsWith(github.ref, 'refs/tags/v') && '--dry-run' || '' }} \ + ${{ startsWith(github.ref, 'refs/tags/v') && '' || '--dry-run' }} \ --workspace \ --token ${{ secrets.CRATES_TOKEN }} \ --no-default-features \ From 3bda0416529c5f7032bf50d1ebfdc5eb4456953e Mon Sep 17 00:00:00 2001 From: lovasoa Date: Wed, 24 Sep 2025 21:38:48 +0200 Subject: [PATCH 7/8] Update Cargo.toml to include additional runtime dependencies for async-std and tokio with native-tls and rustls support --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index ba983725e8..65e1168eff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,6 +83,7 @@ runtime-actix-native-tls = ["runtime-tokio-native-tls"] runtime-async-std-native-tls = [ "sqlx-core/runtime-async-std-native-tls", "sqlx-macros/runtime-async-std-native-tls", + "sqlx-rt/runtime-async-std-native-tls", "_rt-async-std", ] runtime-tokio-native-tls = [ @@ -95,6 +96,7 @@ runtime-actix-rustls = ["runtime-tokio-rustls"] runtime-async-std-rustls = [ "sqlx-core/runtime-async-std-rustls", "sqlx-macros/runtime-async-std-rustls", + "sqlx-rt/runtime-async-std-rustls", "aws_lc_rs", "tls12", "_rt-async-std", @@ -102,11 +104,13 @@ runtime-async-std-rustls = [ runtime-async-std-rustls-nocrypto = [ "sqlx-core/runtime-async-std-rustls", "sqlx-macros/runtime-async-std-rustls", + "sqlx-rt/runtime-async-std-rustls", "_rt-async-std", ] runtime-tokio-rustls = [ "sqlx-core/runtime-tokio-rustls", "sqlx-macros/runtime-tokio-rustls", + "sqlx-rt/runtime-tokio-rustls", "aws_lc_rs", "tls12", "_rt-tokio", @@ -114,6 +118,7 @@ runtime-tokio-rustls = [ runtime-tokio-rustls-nocrypto = [ "sqlx-core/runtime-tokio-rustls", "sqlx-macros/runtime-tokio-rustls", + "sqlx-rt/runtime-tokio-rustls", "_rt-tokio", ] From e50353d4ac291abb5d2e62408f9827d5f5c2845f Mon Sep 17 00:00:00 2001 From: lovasoa Date: Wed, 24 Sep 2025 21:56:09 +0200 Subject: [PATCH 8/8] Update Cargo.toml to set publish flag to false and add runtime dependencies for actix and async-std with rustls support --- sqlx-cli/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sqlx-cli/Cargo.toml b/sqlx-cli/Cargo.toml index 8509a503b0..0268201007 100644 --- a/sqlx-cli/Cargo.toml +++ b/sqlx-cli/Cargo.toml @@ -14,6 +14,7 @@ authors = [ "Jesper Axelsson ", "Austin Bonander ", ] +publish = false [[bin]] name = "sqlx" @@ -55,6 +56,9 @@ backoff = { version = "0.4.0", features = ["futures", "tokio"] } default = ["postgres", "sqlite", "mysql", "native-tls"] rustls = ["sqlx/runtime-tokio-rustls"] native-tls = ["sqlx/runtime-tokio-native-tls"] +runtime-actix-rustls = ["sqlx/runtime-actix-rustls"] +runtime-async-std-rustls = ["sqlx/runtime-async-std-rustls"] +runtime-tokio-rustls = ["sqlx/runtime-tokio-rustls"] # databases mysql = ["sqlx/mysql"]