Skip to content

Commit b15df2e

Browse files
vyzoraulk
andauthored
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]>
1 parent 41640c7 commit b15df2e

File tree

3 files changed

+111
-20
lines changed

3 files changed

+111
-20
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,3 @@ jobs:
7171
BUILD_FIL_NETWORK: ${{ matrix.network }}
7272
run: |
7373
cargo run -- -o output/builtin-actors.car
74-
- name: Uploading bundle to Estuary
75-
env:
76-
ESTUARY_TOKEN: ${{ secrets.ESTUARY_TOKEN }}
77-
run: |
78-
BUNDLE_PATH="output/builtin-actors.car"
79-
UPLOAD_AS="builtin-actors-${{ matrix.network }}.car"
80-
curl -k -X POST -F "data=@${BUNDLE_PATH};type=application/octet-stream;filename=\"${UPLOAD_AS}\"" \
81-
-H "Authorization: Bearer $ESTUARY_TOKEN" \
82-
-H "Content-Type: multipart/form-data" \
83-
https://shuttle-4.estuary.tech/content/add > output/upload.json
84-
cat output/upload.json
85-
shasum -a 256 "$BUNDLE_PATH" > "$BUNDLE_PATH".sha256sum
86-
- name: Publishing build artifacts to GitHub
87-
uses: actions/upload-artifact@v2
88-
with:
89-
name: bundle-${{ matrix.network }}
90-
path: |
91-
output/builtin-actors.car
92-
output/builtin-actors.car.sha256sum
93-
output/upload.json

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'release/**'
8+
- 'experimental/**'
9+
10+
env:
11+
RUSTFLAGS: -Dwarnings
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
CARGO_INCREMENTAL: 0
19+
CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }}
20+
strategy:
21+
matrix:
22+
network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet' ]
23+
steps:
24+
- name: Checking out
25+
uses: actions/checkout@v2
26+
- name: Install Rust toolchain
27+
uses: ./.github/actions/rust-cargo-run
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
command: version
32+
- name: Writing bundle
33+
env:
34+
BUILD_FIL_NETWORK: ${{ matrix.network }}
35+
run: |
36+
cargo run -- -o output/builtin-actors.car
37+
- name: Publishing release and uploading bundle to GitHub
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
GITHUB_SHA: ${{ github.sha }}
41+
BUILD_FIL_NETWORK: ${{ matrix.network }}
42+
run: |
43+
./scripts/publish-release.sh

scripts/publish-release.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
die() {
6+
echo "$1"
7+
exit 1
8+
}
9+
10+
# make sure we have a token set, api requests won't work otherwise
11+
if [ -z "$GITHUB_TOKEN" ]; then
12+
die "no GITHUB_TOKEN"
13+
fi
14+
15+
# make sure we have a release tag set
16+
if [ -z "$GITHUB_SHA" ]; then
17+
die "no GITHUB_SHA"
18+
fi
19+
20+
# make sure we have a target set
21+
if [ -z "$BUILD_FIL_NETWORK" ]; then
22+
die "no BUILD_FIL_NETWORK"
23+
fi
24+
25+
26+
release_file=output/builtin-actors.car
27+
release_target=builtin-actors-${BUILD_FIL_NETWORK}.car
28+
release_tag="${GITHUB_SHA:0:16}"
29+
30+
ORG="filecoin-project"
31+
REPO="builtin-actors"
32+
33+
# see if the release already exists by tag
34+
__release_response=`
35+
curl \
36+
--header "Authorization: token $GITHUB_TOKEN" \
37+
"https://api.github.com/repos/$ORG/$REPO/releases/tags/$release_tag"
38+
`
39+
__release_id=`echo $__release_response | jq '.id'`
40+
if [ "$__release_id" = "null" ]; then
41+
echo "creating release $release_tag"
42+
release_data="{
43+
\"tag_name\": \"$release_tag\",
44+
\"target_commitish\": \"$GITHUB_SHA\",
45+
\"name\": \"$release_tag\",
46+
\"body\": \"\"
47+
}"
48+
49+
__release_response=`
50+
curl \
51+
--request POST \
52+
--header "Authorization: token $GITHUB_TOKEN" \
53+
--header "Content-Type: application/json" \
54+
--data "$release_data" \
55+
"https://api.github.com/repos/$ORG/$REPO/releases"
56+
`
57+
else
58+
echo "release $release_tag already exists"
59+
fi
60+
61+
echo "uploading $release_target"
62+
__release_upload_url=`echo $__release_response | jq -r '.upload_url' | cut -d'{' -f1`
63+
curl \
64+
--request POST \
65+
--header "Authorization: token $GITHUB_TOKEN" \
66+
--header "Content-Type: application/octet-stream" \
67+
--data-binary "@$release_file" \
68+
"$__release_upload_url?name=$release_target"

0 commit comments

Comments
 (0)