feat: Add CI workflow for publishing and dry-runs #49
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish workspace crates | ||
|
Check failure on line 1 in .github/workflows/publish.yml
|
||
| 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: | ||
| # 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: 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 | ||
| env: | ||
| ARGS: | ||
| --token ${{ secrets.CRATES_TOKEN }} | ||
| --no-default-features | ||
| --features runtime-actix-rustls | ||