crates.io pub #3
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 to crates.io | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| crate: | |
| description: "Which crate to publish?" | |
| required: true | |
| type: choice | |
| options: | |
| - wingfoil | |
| - wingfoil-python | |
| - both | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Build wingfoil to generate Cargo.lock | |
| run: cargo build | |
| - name: Publish wingfoil | |
| if: ${{ github.event.inputs.crate == 'wingfoil' || github.event.inputs.crate == 'both' }} | |
| working-directory: wingfoil | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }} | |
| run: cargo publish | |
| - name: Set wingfoil version in wingfoil-python | |
| if: ${{ github.event.inputs.crate == 'wingfoil-python' || github.event.inputs.crate == 'both' }} | |
| working-directory: wingfoil-python | |
| run: | | |
| # Get the version of wingfoil crate | |
| WINGFOIL_VERSION=$(cargo pkgid --manifest-path ../wingfoil/Cargo.toml | cut -d# -f2) | |
| echo "Replacing path dependency with version $WINGFOIL_VERSION" | |
| # Replace path dependency with version | |
| sed -i "s|path = \"../wingfoil\"|version = \"$WINGFOIL_VERSION\"|" Cargo.toml | |
| - name: Publish wingfoil-python | |
| if: ${{ github.event.inputs.crate == 'wingfoil-python' || github.event.inputs.crate == 'both' }} | |
| working-directory: wingfoil-python | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }} | |
| run: cargo publish | |