fix(ci): preserve compatible registry dependency versions #16
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 crates | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| - '[0-9]*' | |
| - 'yank-pd-host-function-*' | |
| - 'unyank-pd-host-function-*' | |
| - 'publish-crates-*-host-*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish. Tag pushes use the tag name without leading v.' | |
| required: true | |
| type: string | |
| pd_host_function_version: | |
| description: 'Compatible pd-host-function version. Defaults to 0.22.7.' | |
| required: false | |
| type: string | |
| yank_pd_host_function_version: | |
| description: 'Optional pd-host-function version to yank before publishing.' | |
| required: false | |
| type: string | |
| concurrency: | |
| group: publish-crates-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| env: | |
| PACKAGE_ORDER: pd-host-function pd-vm pd-vm-nostd rustscript | |
| steps: | |
| - name: Checkout rustscript | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 | |
| with: | |
| path: rustscript | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 | |
| - name: Verify crate publish order | |
| working-directory: rustscript | |
| run: python3 scripts/verify_publish_order.py $PACKAGE_ORDER | |
| - name: Publish crates | |
| working-directory: rustscript | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| INPUT_VERSION: ${{ inputs.version }} | |
| INPUT_HOST_VERSION: ${{ inputs.pd_host_function_version }} | |
| INPUT_YANK_HOST_VERSION: ${{ inputs.yank_pd_host_function_version }} | |
| run: | | |
| set -euo pipefail | |
| if [[ "$GITHUB_REF_NAME" == yank-pd-host-function-* ]]; then | |
| host_version="${GITHUB_REF_NAME#yank-pd-host-function-}" | |
| cargo yank --vers "$host_version" pd-host-function | |
| exit 0 | |
| fi | |
| if [[ "$GITHUB_REF_NAME" == unyank-pd-host-function-* ]]; then | |
| host_version="${GITHUB_REF_NAME#unyank-pd-host-function-}" | |
| cargo yank --undo --vers "$host_version" pd-host-function | |
| exit 0 | |
| fi | |
| if [[ "$GITHUB_REF_NAME" == publish-crates-*-host-* ]]; then | |
| publish_spec="${GITHUB_REF_NAME#publish-crates-}" | |
| version="${publish_spec%%-host-*}" | |
| host_version="${publish_spec#*-host-}" | |
| if [[ -z "$version" || -z "$host_version" || "$version" == "$publish_spec" ]]; then | |
| echo "invalid publish recovery tag: $GITHUB_REF_NAME" >&2 | |
| exit 1 | |
| fi | |
| INPUT_VERSION="$version" | |
| INPUT_HOST_VERSION="$host_version" | |
| fi | |
| version="${INPUT_VERSION:-${GITHUB_REF_NAME#v}}" | |
| if [[ -z "$version" ]]; then | |
| echo "version is required" >&2 | |
| exit 1 | |
| fi | |
| args=( | |
| --version "$version" | |
| --host-version "${INPUT_HOST_VERSION:-0.22.7}" | |
| ) | |
| if [[ -n "${INPUT_YANK_HOST_VERSION:-}" ]]; then | |
| args+=(--yank-host-version "$INPUT_YANK_HOST_VERSION") | |
| fi | |
| python3 scripts/publish_crates.py "${args[@]}" |