Skip to content

Commit 43b039a

Browse files
authored
Added crates.io publishing for the Runfiles library (#3913)
closes #1592 closes #3830
1 parent 2088b06 commit 43b039a

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Release Runfiles
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- rust/runfiles/Cargo.toml
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
validation:
17+
runs-on: ubuntu-22.04
18+
steps:
19+
- uses: actions/checkout@v4
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-22.04
35+
steps:
36+
- uses: actions/checkout@v4
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: ./rust/runfiles
46+
env:
47+
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

rust/runfiles/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "runfiles"
3+
version = "0.1.0"
4+
edition = "2018"
5+
keywords = ["bazel"]
6+
license = "Apache-2.0"
7+
description = "Runfiles lookup library for Bazel-built Rust binaries and tests."
8+
repository = "https://github.com/bazelbuild/rules_rust"
9+
10+
[lib]
11+
path = "runfiles.rs"

0 commit comments

Comments
 (0)