Skip to content

Commit

Permalink
ci: publish assets to draft github releases
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Aug 5, 2024
1 parent 63d1939 commit dd6b34e
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 92 deletions.
68 changes: 1 addition & 67 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
push:
branches:
- master
tags:
- v*
workflow_dispatch:
inputs:
save:
Expand Down Expand Up @@ -115,7 +113,7 @@ jobs:
cd $(mktemp -d)
go install github.com/filecoin-project/go-paramfetch/paramfetch@latest
$GOPATH/bin/paramfetch 2048 "${DIR}/parameters.json" "${DIR}/srs-inner-product.json"
- if: runner.os == 'Linux' && ((github.event == 'push' && !startsWith(github.ref, 'refs/tags/')) || github.event.inputs.save == 'true')
- if: runner.os == 'Linux' && (github.event == 'push' || github.event.inputs.save == 'true')
uses: actions/cache/save@v3
with:
key: v28-proof-params-${{ runner.os }}-${{ runner.arch }}
Expand Down Expand Up @@ -147,67 +145,3 @@ jobs:
ref: ${{ github.event.inputs.ref }}
- name: Build project with `FFI_USE_CUDA_SUPRASEAL=1`
run: FFI_BUILD_FROM_SOURCE=1 FFI_USE_CUDA_SUPRASEAL=1 make
publish:
needs: [check, cgo-bindings, supraseal]
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event.inputs.publish == 'true'
name: Publish the static library (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: ['ubuntu-latest', ['self-hosted', 'linux', 'arm64', 'xlarge'], 'macos-latest']
fail-fast: false
steps:
- run: echo "Running on $RUNNER_OS $RUNNER_ARCH"
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/actions/configure-environment
- if: github.event.inputs.ref != ''
uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ github.event.inputs.ref }}
- if: runner.os == 'macOS'
run: |
cd rust && rustup target add x86_64-apple-darwin
cd rust && cargo fetch
- if: runner.os == 'Linux'
name: Build and publish the standard release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard.tar.gz"
RELEASE_NAME="${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
- if: runner.os == 'Linux'
name: Build the optimized release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${CIRCLE_PROJECT_REPONAME}-$(uname)-$(uname -m)-optimized.tar.gz"
RUSTFLAGS="-C target-feature=$(cat rustc-target-features-optimized.json | jq -r '.[].rustc_target_feature' | tr '\n' ',')"
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl
./scripts/package-release.sh $TARBALL_PATH
- if: runner.os == 'macOS'
name: Build and publish the universal standard release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
RELEASE_NAME="${CIRCLE_PROJECT_REPONAME}-$(uname)-standard"
TARBALL_PATH="/tmp/${RELEASE_NAME}.tar.gz"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh lipo --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
63 changes: 63 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,66 @@ jobs:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
with:
sources: '["version.json"]'
upload-release-assets:
needs: [release-check]
if: fromJSON(needs.release-check.outputs.json)['version.json']
name: Publish the static library (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: ['ubuntu-latest', ['self-hosted', 'linux', 'arm64', 'xlarge'], 'macos-latest']
fail-fast: false
steps:
- run: echo "Running on $RUNNER_OS $RUNNER_ARCH"
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/actions/configure-environment
- if: runner.os == 'macOS'
run: |
cd rust && rustup target add x86_64-apple-darwin
cd rust && cargo fetch
- if: runner.os == 'Linux'
name: Build and publish the standard release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard.tar.gz"
RELEASE_NAME="${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
- if: runner.os == 'Linux'
name: Build the optimized release
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
TARBALL_PATH="/tmp/${REPOSITORY_NAME}-$(uname)-$(uname -m)-optimized.tar.gz"
RUSTFLAGS="-C target-feature=$(cat rustc-target-features-optimized.json | jq -r '.[].rustc_target_feature' | tr '\n' ',')"
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl
./scripts/package-release.sh $TARBALL_PATH
- if: runner.os == 'macOS'
name: Build and publish the universal standard release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cd rust
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
RELEASE_NAME="${REPOSITORY_NAME}-$(uname)-standard"
TARBALL_PATH="/tmp/${RELEASE_NAME}.tar.gz"
# Note: the blst dependency uses the portable configuration for maximum compatibility
./scripts/build-release.sh lipo --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
./scripts/package-release.sh $TARBALL_PATH
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
50 changes: 25 additions & 25 deletions rust/scripts/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,46 @@ main() {
fi

local __release_file=$1
local __release_name=$2
local __release_tag="${CIRCLE_SHA1:0:16}"
local __release_url="${GITHUB_RELEASE_URL}"
local __release_target="$(basename $__release_file)"

# make sure we have a token set, api requests won't work otherwise
if [ -z $GITHUB_TOKEN ]; then
(>&2 echo "[publish-release/main] \$GITHUB_TOKEN not set, publish failed")
exit 1
fi

# make sure we have a release url set
if [ -z "$GITHUB_RELEASE_URL" ]; then
(>&2 echo "[publish-release/main] \$GITHUB_RELEASE_URL not set, publish failed")
exit 1
fi

# see if the release already exists by tag
local __release_response=`
curl \
--header "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases/tags/$__release_tag"
"$__release_url"
`

local __release_id=`echo $__release_response | jq '.id'`

if [ "$__release_id" = "null" ]; then
(>&2 echo '[publish-release/main] creating release')

RELEASE_DATA="{
\"tag_name\": \"$__release_tag\",
\"target_commitish\": \"$CIRCLE_SHA1\",
\"name\": \"$__release_tag\",
\"body\": \"\"
}"

# create it if it doesn't exist yet
#
__release_response=`
curl \
--request POST \
--header "Authorization: token $GITHUB_TOKEN" \
--header "Content-Type: application/json" \
--data "$RELEASE_DATA" \
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases"
`
else
(>&2 echo '[publish-release/main] release already exists')
(>&2 echo '[publish-release/main] release does not exist')
exit 1
fi

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

if [ -n "$__release_target_asset" ]; then
(>&2 echo "[publish-release/main] $__release_target_asset already exists, deleting")

__release_target_asset_url=`echo $__release_target_asset | jq -r '.url'`

curl \
--request DELETE \
--header "Authorization: token $GITHUB_TOKEN" \
"$__release_target_asset_url"
fi

__release_upload_url=`echo $__release_response | jq -r '.upload_url' | cut -d'{' -f1`
Expand All @@ -65,7 +65,7 @@ main() {
--header "Authorization: token $GITHUB_TOKEN" \
--header "Content-Type: application/octet-stream" \
--data-binary "@$__release_file" \
"$__release_upload_url?name=$(basename $__release_file)"
"$__release_upload_url?name=$__release_target"

(>&2 echo '[publish-release/main] release file uploaded')
}
Expand Down

0 comments on commit dd6b34e

Please sign in to comment.