Skip to content

Commit

Permalink
ci: upload release assets to the draft
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Jul 25, 2024
1 parent 0744dbc commit fc7fce7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 47 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,36 @@ jobs:
uses: ipdxco/unified-github-workflows/.github/workflows/release-check.yml@v1.0
with:
sources: '["Cargo.toml"]'
upload-release-assets:
needs: [release-check]
if: fromJSON(needs.release-check.outputs.json)['Cargo.toml']
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_INCREMENTAL: 0
CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }}
RUSTFLAGS: -Dwarnings
strategy:
matrix:
network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs' ]
steps:
- name: Checking out
uses: actions/checkout@v4
- name: Setting up cache
uses: pl-strflt/rust-sccache-action@v1
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ github.workspace }}/.cache/sccache
CACHE_SKIP_SAVE: true
- name: Writing bundle
env:
BUILD_FIL_NETWORK: ${{ matrix.network }}
run: |
cargo run --locked -- -o output/builtin-actors.car
- name: Upload release assets to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_RELEASE_URL: ${{ fromJSON(needs.release-check.outputs.json)['Cargo.toml'].url }}
BUILD_FIL_NETWORK: ${{ matrix.network }}
run: |
./scripts/upload-release-assets.sh
40 changes: 0 additions & 40 deletions .github/workflows/release.yml

This file was deleted.

34 changes: 27 additions & 7 deletions scripts/publish-release.sh → scripts/upload-release-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ if [ -z "$GITHUB_TOKEN" ]; then
die "no GITHUB_TOKEN"
fi

# make sure we have a release tag set
if [ -z "$GITHUB_REF" ]; then
die "no GITHUB_REF"
# make sure we have a release url set
if [ -z "$GITHUB_RELEASE_URL" ]; then
die "no GITHUB_RELEASE_URL"
fi

# make sure we have a target set
Expand All @@ -28,8 +28,6 @@ release_target=builtin-actors-${BUILD_FIL_NETWORK}.car
release_target_hash=builtin-actors-${BUILD_FIL_NETWORK}.sha256
release_file=output/$release_target
release_file_hash=output/$release_target_hash
# the ref is of the form refs/tags/<tag>; drop the prefix to get the actual release tag
release_tag="${GITHUB_REF:10}"

# prepare artifacts
pushd output
Expand All @@ -45,16 +43,27 @@ REPO="builtin-actors"
__release_response=`
curl \
--header "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$ORG/$REPO/releases/tags/$release_tag"
"$GITHUB_RELEASE_URL"
`
__release_id=`echo $__release_response | jq '.id'`
if [ "$__release_id" = "null" ]; then
echo "release $release_tag does not exist"
echo "release does not exist"
exit 1
fi

__release_upload_url=`echo $__release_response | jq -r '.upload_url' | cut -d'{' -f1`

__release_target_asset=`echo $__release_response | jq -r ".assets | .[] | select(.name == \"$release_target\")"`

if [ -n "$__release_target_asset" ]; then
echo "deleting $release_target"
__release_target_asset_url=`echo $__release_target_asset | jq -r '.url'`
curl \
--request DELETE \
--header "Authorization: token $GITHUB_TOKEN" \
"$__release_target_asset_url"
fi

echo "uploading $release_target"
curl \
--request POST \
Expand All @@ -63,6 +72,17 @@ curl \
--data-binary "@$release_file" \
"$__release_upload_url?name=$release_target"

__release_target_hash_asset=`echo $__release_response | jq -r ".assets | .[] | select(.name == \"$release_target_hash\")"`

if [ -n "$__release_target_hash_asset" ]; then
echo "deleting $release_target_hash"
__release_target_hash_asset_url=`echo $__release_target_hash_asset | jq -r '.url'`
curl \
--request DELETE \
--header "Authorization: token $GITHUB_TOKEN" \
"$__release_target_hash_asset_url"
fi

echo "uploading $release_target_hash"
curl \
--request POST \
Expand Down

0 comments on commit fc7fce7

Please sign in to comment.