-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add workflow to publish release bundles (#244)
* add workflow to publish release bundles on certain branches master, release/*, and experimental/* are the blessed ones * keep the build step in the default workflow * apply suggestions from code review Co-authored-by: raulk <[email protected]>
- Loading branch information
Showing
3 changed files
with
111 additions
and
20 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
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,43 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'release/**' | ||
- 'experimental/**' | ||
|
||
env: | ||
RUSTFLAGS: -Dwarnings | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CARGO_INCREMENTAL: 0 | ||
CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }} | ||
strategy: | ||
matrix: | ||
network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet' ] | ||
steps: | ||
- name: Checking out | ||
uses: actions/checkout@v2 | ||
- name: Install Rust toolchain | ||
uses: ./.github/actions/rust-cargo-run | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
command: version | ||
- name: Writing bundle | ||
env: | ||
BUILD_FIL_NETWORK: ${{ matrix.network }} | ||
run: | | ||
cargo run -- -o output/builtin-actors.car | ||
- name: Publishing release and uploading bundle to GitHub | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_SHA: ${{ github.sha }} | ||
BUILD_FIL_NETWORK: ${{ matrix.network }} | ||
run: | | ||
./scripts/publish-release.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
die() { | ||
echo "$1" | ||
exit 1 | ||
} | ||
|
||
# make sure we have a token set, api requests won't work otherwise | ||
if [ -z "$GITHUB_TOKEN" ]; then | ||
die "no GITHUB_TOKEN" | ||
fi | ||
|
||
# make sure we have a release tag set | ||
if [ -z "$GITHUB_SHA" ]; then | ||
die "no GITHUB_SHA" | ||
fi | ||
|
||
# make sure we have a target set | ||
if [ -z "$BUILD_FIL_NETWORK" ]; then | ||
die "no BUILD_FIL_NETWORK" | ||
fi | ||
|
||
|
||
release_file=output/builtin-actors.car | ||
release_target=builtin-actors-${BUILD_FIL_NETWORK}.car | ||
release_tag="${GITHUB_SHA:0:16}" | ||
|
||
ORG="filecoin-project" | ||
REPO="builtin-actors" | ||
|
||
# see if the release already exists by tag | ||
__release_response=` | ||
curl \ | ||
--header "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/repos/$ORG/$REPO/releases/tags/$release_tag" | ||
` | ||
__release_id=`echo $__release_response | jq '.id'` | ||
if [ "$__release_id" = "null" ]; then | ||
echo "creating release $release_tag" | ||
release_data="{ | ||
\"tag_name\": \"$release_tag\", | ||
\"target_commitish\": \"$GITHUB_SHA\", | ||
\"name\": \"$release_tag\", | ||
\"body\": \"\" | ||
}" | ||
|
||
__release_response=` | ||
curl \ | ||
--request POST \ | ||
--header "Authorization: token $GITHUB_TOKEN" \ | ||
--header "Content-Type: application/json" \ | ||
--data "$release_data" \ | ||
"https://api.github.com/repos/$ORG/$REPO/releases" | ||
` | ||
else | ||
echo "release $release_tag already exists" | ||
fi | ||
|
||
echo "uploading $release_target" | ||
__release_upload_url=`echo $__release_response | jq -r '.upload_url' | cut -d'{' -f1` | ||
curl \ | ||
--request POST \ | ||
--header "Authorization: token $GITHUB_TOKEN" \ | ||
--header "Content-Type: application/octet-stream" \ | ||
--data-binary "@$release_file" \ | ||
"$__release_upload_url?name=$release_target" |