1--- 2name: Release Cargo-bazel 3on: 4 workflow_dispatch: 5 push: 6 branches: 7 - main 8 paths: 9 - crate_universe/version.bzl 10 11defaults: 12 run: 13 shell: bash 14 15jobs: 16 validation: 17 runs-on: ubuntu-20.04 18 steps: 19 - uses: actions/checkout@v3 20 # TODO: Unfortunately it's not obvious how to restrict `workflow_dispatch` to a particular branch 21 # so this step ensures releases are always done off of `main`. 22 - name: Ensure branch is 'main' 23 run: | 24 git fetch origin &> /dev/null 25 branch="$(git rev-parse --abbrev-ref HEAD)" 26 if [[ "${branch}" != "main" ]]; then 27 echo "The release branch must be main. Got '${branch}'' instead." >&2 28 exit 1 29 else 30 echo "Branch is '${branch}'" 31 fi 32 builds: 33 needs: validation 34 runs-on: ubuntu-20.04 35 steps: 36 - uses: actions/checkout@v3 37 - name: Install rust toolchains for host 38 run: | 39 # Detect the current version of rust 40 version="$(grep 'DEFAULT_RUST_VERSION =' ./rust/private/common.bzl | grep -o '[[:digit:].]\+')" 41 rustup override set "${version}" 42 rustup update stable && rustup default stable 43 - name: Publish to crates.io 44 run: cargo publish --token ${CRATES_TOKEN} 45 working-directory: ./crate_universe 46 env: 47 CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} 48