-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from sacherjj/ci_changes_and_crates_publish
Setup crates.io and cleaning up other CI
- Loading branch information
Showing
4 changed files
with
89 additions
and
3 deletions.
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,23 @@ | ||
--- | ||
name: publish-casper-event-sidecar-crates | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
publish-crates: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2 | ||
- uses: actions-rs/toolchain@v1 | ||
|
||
- name: update toolchain | ||
run: rustup update nightly | ||
|
||
- name: Publish Crates | ||
env: | ||
CARGO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | ||
run: ./ci/publish_to_crates_io.sh |
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
Empty file.
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,65 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
CRATES_URL=https://crates.io/api/v1/crates | ||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd)" | ||
|
||
run_curl() { | ||
set +e | ||
CURL_OUTPUT=$(curl -s $1) | ||
set -e | ||
local EXIT_CODE=$? | ||
if [[ $EXIT_CODE -ne 0 ]]; then | ||
printf "curl -s %s failed with exit code %d\n\n" $1 $EXIT_CODE | ||
exit 1 | ||
fi | ||
} | ||
|
||
max_version_in_crates_io() { | ||
local CRATE=$1 | ||
printf "Max published version: " | ||
run_curl "$CRATES_URL/$CRATE" | ||
if [[ "$CURL_OUTPUT" == "{\"errors\":[{\"detail\":\"Not Found\"}]}" ]]; then | ||
CRATES_IO_VERSION="N/A (not found in crates.io)" | ||
else | ||
CRATES_IO_VERSION=$(echo "$CURL_OUTPUT" | jq -r .crate.max_version) | ||
fi | ||
printf "%s\n" "$CRATES_IO_VERSION" | ||
} | ||
|
||
publish() { | ||
CRATE_DIR="$1" | ||
local CRATE_DIR | ||
pushd "$ROOT_DIR/$CRATE_DIR" >/dev/null | ||
|
||
CRATE_NAME=$(cargo read-manifest | jq -r '.name' | tr -d '\n') | ||
local CRATE_NAME | ||
printf "%s\n" "$CRATE_NAME" | ||
|
||
max_version_in_crates_io "$CRATE_NAME" | ||
|
||
printf "Local version: " | ||
LOCAL_VERSION=$(cargo read-manifest | jq -r '.version' | tr -d '\n') | ||
printf "%s\n$LOCAL_VERSION" | ||
|
||
if [[ "$LOCAL_VERSION" == "$CRATES_IO_VERSION" ]]; then | ||
printf "Skipping\n" | ||
else | ||
printf "Publishing...\n" | ||
set +u | ||
cargo publish "${@:2}" --token "${CARGO_TOKEN}" | ||
set -u | ||
printf "Published version %s\n$LOCAL_VERSION" | ||
printf "Sleeping for 60 seconds...\n" | ||
sleep 60 | ||
fi | ||
printf "================================================================================\n\n" | ||
popd >/dev/null | ||
} | ||
|
||
# These are the subdirs of casper-node which contain packages for publishing. They should remain ordered from | ||
# least-dependent to most. | ||
publish types | ||
publish listener | ||
publish sidecar |