Skip to content

ci: generic bundle builder workflow #4

ci: generic bundle builder workflow

ci: generic bundle builder workflow #4

Workflow file for this run

name: Build CoreEval
on:
workflow_dispatch:
inputs:
package:
description: 'Package name'
required: true
type: string
default: 'portfolio-deploy'
branch:
description: 'Branch name to checkout'
required: false
type: string
default: 'master'
pull_request:
jobs:
build-bundle:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || 'fraz/test-ymax-deploy' }}
submodules: 'true'
- name: Clean repository
run: |
git clean -xdf
git submodule foreach --recursive git clean -xdf
- uses: ./.github/actions/restore-node
with:
node-version: 'node-new'
- name: Build CoreEval bundle
id: build-bundle
working-directory: packages/${{ inputs.package }}
run: |
set -o pipefail
# Capture all output to a log file
{
pwd
echo "=== Running yarn build ==="
yarn build
echo ""
echo "=== Running yarn build:bundle ==="
yarn build:bundle
echo ""
} 2>&1 | tee ../../build-output.log
echo "Bundle build completed"
- name: Extract bundle IDs
id: extract-bundle-ids
working-directory: packages/${{ inputs.package }}/dist
run: |
echo "=== Extracting Bundle IDs ===" | tee -a ../../build-output.log
BUNDLE_IDS=""
# Find all JSON files that are not meta.json files
for json_file in *.json; do
if [[ "$json_file" == *meta.json ]]; then
continue
fi
if [[ -f "$json_file" ]]; then
echo "Processing: $json_file" | tee -a ../../build-output.log
# Extract hash and prepend with b1-
HASH=$(jq -r .endoZipBase64Sha512 "$json_file")
BUNDLE_ID="b1-${HASH}"
echo " Bundle ID: $BUNDLE_ID" | tee -a ../../build-output.log
echo "" | tee -a ../../build-output.log
# Collect bundle IDs for output
if [ -z "$BUNDLE_IDS" ]; then
BUNDLE_IDS="$BUNDLE_ID"
else
BUNDLE_IDS="$BUNDLE_IDS, $BUNDLE_ID"
fi
fi
done
echo "bundle_ids=$BUNDLE_IDS" >> $GITHUB_OUTPUT
- name: Upload build logs
if: always()
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ github.run_number }}
path: build-output.log
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: coreeval-artifacts-${{ inputs.package }}-${{ github.run_number }}
path: packages/${{ inputs.package }}/dist/
- name: Summary
if: success()
run: |
echo "## Build Successful ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Package: \`${{ inputs.package }}\`" >> $GITHUB_STEP_SUMMARY
echo "### Branch: \`${{ inputs.branch }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY
echo "1. Download the artifacts from the Actions artifacts section" >> $GITHUB_STEP_SUMMARY
echo "2. The dist folder contains:" >> $GITHUB_STEP_SUMMARY
echo " - Bundle JSON files (\`bundle-*.json\`)" >> $GITHUB_STEP_SUMMARY
echo " - Contract bundle files (\`*.bundle.js\`)" >> $GITHUB_STEP_SUMMARY
echo " - Metadata files (\`*.meta.json\`)" >> $GITHUB_STEP_SUMMARY
echo "3. Use the bundle ID to identify the correct bundle version for deployment" >> $GITHUB_STEP_SUMMARY
echo "4. Deploy the bundles to relevant network via cosgov.org" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Artifacts:" >> $GITHUB_STEP_SUMMARY
echo "- **Build Logs**: \`build-logs-${{ github.run_number }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Dist Folder**: \`coreeval-artifacts-${{ inputs.package }}-${{ github.run_number }}\`" >> $GITHUB_STEP_SUMMARY