-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added github action to publish cargo-bazel binaries. (#2134)
closes #2131
- Loading branch information
1 parent
0a1e587
commit ea4282f
Showing
4 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
name: Release Cargo-bazel | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- crate_universe/version.bzl | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
validation: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# 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-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- 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: ./crate_universe | ||
env: | ||
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//! A small test binary for ensuring the version of the rules matches the binary version | ||
|
||
use std::fs::File; | ||
use std::io::{BufRead, BufReader}; | ||
use std::path::PathBuf; | ||
|
||
#[test] | ||
fn test_cargo_and_bazel_versions() { | ||
// Parse the version field from the `cargo-bazel` Cargo.toml file | ||
let cargo_version = { | ||
let cargo_path = PathBuf::from(env!("CARGO_TOML")); | ||
let file = File::open(cargo_path).expect("Failed to load Cargo.toml file"); | ||
BufReader::new(file) | ||
.lines() | ||
.flatten() | ||
.find(|line| line.contains("version = ")) | ||
.map(|line| { | ||
line.trim() | ||
.replace("version = ", "") | ||
.trim_matches('\"') | ||
.to_owned() | ||
}) | ||
.expect("The version.bzl file should have a line with `version = `") | ||
}; | ||
|
||
// Parse the version global from the Bazel module | ||
let bazel_version = { | ||
let bazel_path = PathBuf::from(env!("VERSION_BZL")); | ||
let file = File::open(bazel_path).expect("Failed to load versions.bzl file"); | ||
BufReader::new(file) | ||
.lines() | ||
.flatten() | ||
.find(|line| line.contains("VERSION = ")) | ||
.map(|line| { | ||
line.trim() | ||
.replace("VERSION = ", "") | ||
.trim_matches('\"') | ||
.to_owned() | ||
}) | ||
.expect("The version.bzl file should have a line with `VERSION = `") | ||
}; | ||
|
||
assert_eq!(cargo_version, bazel_version, "make sure `//crate_universe:version.bzl` and `//crate_universe:Cargo.toml` have matching versions."); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
""" Version info for the `cargo-bazel` repository """ | ||
|
||
VERSION = "0.8.0" | ||
VERSION = "0.9.0" |