diff --git a/.github/workflows/runfiles_release.yaml b/.github/workflows/runfiles_release.yaml new file mode 100644 index 0000000000..80064a2e0a --- /dev/null +++ b/.github/workflows/runfiles_release.yaml @@ -0,0 +1,47 @@ +--- +name: Release Runfiles +on: + workflow_dispatch: + push: + branches: + - main + paths: + - rust/runfiles/Cargo.toml + +defaults: + run: + shell: bash + +jobs: + validation: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + # TODO: Unfortunately it's not obvious how to restrict `workflow_dispatch` to a particular branch + # so this step ensures releases are always done off of `main`. + - name: Ensure branch is 'main' + run: | + git fetch origin &> /dev/null + branch="$(git rev-parse --abbrev-ref HEAD)" + if [[ "${branch}" != "main" ]]; then + echo "The release branch must be main. Got '${branch}'' instead." >&2 + exit 1 + else + echo "Branch is '${branch}'" + fi + builds: + needs: validation + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Install rust toolchains for host + run: | + # Detect the current version of rust + version="$(grep 'DEFAULT_RUST_VERSION =' ./rust/private/common.bzl | grep -o '[[:digit:].]\+')" + rustup override set "${version}" + rustup update stable && rustup default stable + - name: Publish to crates.io + run: cargo publish --token ${CRATES_TOKEN} + working-directory: ./rust/runfiles + env: + CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} diff --git a/rust/runfiles/Cargo.toml b/rust/runfiles/Cargo.toml new file mode 100644 index 0000000000..18f7fdede2 --- /dev/null +++ b/rust/runfiles/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "runfiles" +version = "0.1.0" +edition = "2018" +keywords = ["bazel"] +license = "Apache-2.0" +description = "Runfiles lookup library for Bazel-built Rust binaries and tests." +repository = "https://github.com/bazelbuild/rules_rust" + +[lib] +path = "runfiles.rs"