-
Notifications
You must be signed in to change notification settings - Fork 136
Add release asset validation to Releaser workflow #544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,3 +19,111 @@ jobs: | |||||||||||||
sources: '["version.json"]' | ||||||||||||||
secrets: | ||||||||||||||
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }} | ||||||||||||||
|
||||||||||||||
validate-and-build-missing-assets: | ||||||||||||||
needs: [releaser] | ||||||||||||||
if: fromJSON(needs.releaser.outputs.json)['version.json'] | ||||||||||||||
name: Validate release assets (${{ matrix.runner }}) | ||||||||||||||
runs-on: ${{ matrix.runner }} | ||||||||||||||
strategy: | ||||||||||||||
matrix: | ||||||||||||||
runner: [ | ||||||||||||||
'ubuntu-latest', | ||||||||||||||
['self-hosted', 'linux', 'arm64', 'xlarge'], | ||||||||||||||
'macos-latest' | ||||||||||||||
] | ||||||||||||||
fail-fast: false | ||||||||||||||
steps: | ||||||||||||||
- uses: actions/checkout@v4 | ||||||||||||||
with: | ||||||||||||||
submodules: recursive | ||||||||||||||
- uses: ./.github/actions/configure-environment | ||||||||||||||
- if: runner.os == 'macOS' | ||||||||||||||
run: | | ||||||||||||||
rustup target add x86_64-apple-darwin | ||||||||||||||
cargo fetch | ||||||||||||||
working-directory: rust | ||||||||||||||
- name: Check and build missing release assets | ||||||||||||||
env: | ||||||||||||||
GITHUB_TOKEN: ${{ github.token }} | ||||||||||||||
RELEASE_TAG: >- | ||||||||||||||
${{ fromJSON(needs.releaser.outputs.json)['version.json'].tag }} | ||||||||||||||
RELEASE_ID: >- | ||||||||||||||
${{ fromJSON(needs.releaser.outputs.json)['version.json'].id }} | ||||||||||||||
run: | | ||||||||||||||
# Get release information | ||||||||||||||
RELEASE_URL="https://api.github.com/repos" | ||||||||||||||
RELEASE_URL="$RELEASE_URL/${{ github.repository }}/releases" | ||||||||||||||
RELEASE_INFO=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||||||||||||||
"$RELEASE_URL/$RELEASE_ID") | ||||||||||||||
|
||||||||||||||
if [ "$(echo $RELEASE_INFO | jq '.id')" = "null" ]; then | ||||||||||||||
echo "Release not found for ID $RELEASE_ID" | ||||||||||||||
exit 1 | ||||||||||||||
fi | ||||||||||||||
|
||||||||||||||
echo "Checking assets for release: $RELEASE_TAG" | ||||||||||||||
|
||||||||||||||
# Determine what asset this runner should build | ||||||||||||||
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/} | ||||||||||||||
|
||||||||||||||
if [ "$RUNNER_OS" = "Linux" ] && [ "$RUNNER_ARCH" = "X64" ]; then | ||||||||||||||
EXPECTED_ASSET="${REPOSITORY_NAME}-Linux-x86_64-standard.tar.gz" | ||||||||||||||
BUILD_CMD="./scripts/build-release.sh build --verbose" | ||||||||||||||
BUILD_CMD="$BUILD_CMD --no-default-features" | ||||||||||||||
BUILD_CMD="$BUILD_CMD --features multicore-sdr,opencl,blst-portable" | ||||||||||||||
elif [ "$RUNNER_OS" = "Linux" ] && [ "$RUNNER_ARCH" = "ARM64" ]; then | ||||||||||||||
EXPECTED_ASSET="${REPOSITORY_NAME}-Linux-aarch64-standard.tar.gz" | ||||||||||||||
BUILD_CMD="./scripts/build-release.sh build --verbose" | ||||||||||||||
BUILD_CMD="$BUILD_CMD --no-default-features" | ||||||||||||||
BUILD_CMD="$BUILD_CMD --features multicore-sdr,opencl,blst-portable" | ||||||||||||||
elif [ "$RUNNER_OS" = "macOS" ]; then | ||||||||||||||
EXPECTED_ASSET="${REPOSITORY_NAME}-Darwin-standard.tar.gz" | ||||||||||||||
BUILD_CMD="./scripts/build-release.sh lipo --verbose" | ||||||||||||||
BUILD_CMD="$BUILD_CMD --no-default-features" | ||||||||||||||
BUILD_CMD="$BUILD_CMD --features multicore-sdr,opencl,blst-portable" | ||||||||||||||
else | ||||||||||||||
echo "Unknown runner configuration: $RUNNER_OS $RUNNER_ARCH" | ||||||||||||||
exit 1 | ||||||||||||||
fi | ||||||||||||||
|
||||||||||||||
# Check if this asset already exists | ||||||||||||||
asset_exists=$(echo $RELEASE_INFO | jq -r \ | ||||||||||||||
".assets[] | select(.name == \"$EXPECTED_ASSET\") | .name") | ||||||||||||||
|
||||||||||||||
if [ -n "$asset_exists" ]; then | ||||||||||||||
Comment on lines
+92
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The asset existence check could be simplified and made more robust by using jq's
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
echo "Asset $EXPECTED_ASSET already exists - skipping" | ||||||||||||||
exit 0 | ||||||||||||||
fi | ||||||||||||||
|
||||||||||||||
echo "Asset $EXPECTED_ASSET is missing - building it" | ||||||||||||||
|
||||||||||||||
# Build the asset | ||||||||||||||
cd rust | ||||||||||||||
|
||||||||||||||
if [ "$RUNNER_OS" = "Linux" ]; then | ||||||||||||||
TARBALL_PATH="/tmp/$EXPECTED_ASSET" | ||||||||||||||
|
||||||||||||||
$BUILD_CMD | ||||||||||||||
./scripts/package-release.sh $TARBALL_PATH | ||||||||||||||
|
||||||||||||||
# Upload using the publish-release script | ||||||||||||||
API_URL="https://api.github.com/repos" | ||||||||||||||
RELEASE_URL="$API_URL/${{ github.repository }}/releases/$RELEASE_ID" | ||||||||||||||
export GITHUB_RELEASE_URL="$RELEASE_URL" | ||||||||||||||
./scripts/publish-release.sh $TARBALL_PATH $EXPECTED_ASSET | ||||||||||||||
|
||||||||||||||
elif [ "$RUNNER_OS" = "macOS" ]; then | ||||||||||||||
TARBALL_PATH="/tmp/$EXPECTED_ASSET" | ||||||||||||||
|
||||||||||||||
$BUILD_CMD | ||||||||||||||
./scripts/package-release.sh $TARBALL_PATH | ||||||||||||||
|
||||||||||||||
# Upload using the publish-release script | ||||||||||||||
API_URL="https://api.github.com/repos" | ||||||||||||||
RELEASE_URL="$API_URL/${{ github.repository }}/releases/$RELEASE_ID" | ||||||||||||||
export GITHUB_RELEASE_URL="$RELEASE_URL" | ||||||||||||||
./scripts/publish-release.sh $TARBALL_PATH $EXPECTED_ASSET | ||||||||||||||
fi | ||||||||||||||
Comment on lines
+104
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The Linux and macOS build/upload logic is identical and duplicated. This should be extracted to eliminate code duplication - the conditional logic could be moved after the platform-specific asset name and build command determination. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
|
||||||||||||||
echo "Successfully built and uploaded: $EXPECTED_ASSET" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks for the string 'null' but jq returns the literal null value. This should be
if [ "$(echo $RELEASE_INFO | jq '.id')" = "null" ]; then
or better yet, useif [ "$(echo $RELEASE_INFO | jq -r '.id')" = "null" ]; then
to get the raw output.Copilot uses AI. Check for mistakes.