|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | +name: "ZXC: Build & Publish Hedera State Validator Uber JAR" |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + ref: |
| 8 | + description: "Branch, tag, or commit to build" |
| 9 | + required: false |
| 10 | + type: string |
| 11 | + workflow_call: |
| 12 | + inputs: |
| 13 | + ref: |
| 14 | + description: "Branch, tag, or commit to build" |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + outputs: |
| 18 | + gcs-uri: |
| 19 | + description: "GCS URI of the published uber JAR" |
| 20 | + value: ${{ jobs.build-publish.outputs.gcs-uri }} |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + id-token: write |
| 25 | + |
| 26 | +defaults: |
| 27 | + run: |
| 28 | + shell: bash |
| 29 | + |
| 30 | +jobs: |
| 31 | + build-publish: |
| 32 | + name: Build & Publish State Validator Uber JAR |
| 33 | + runs-on: hiero-citr-linux-medium |
| 34 | + |
| 35 | + outputs: |
| 36 | + gcs-uri: ${{ steps.upload.outputs.gcs_uri || '' }} |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Harden Runner |
| 40 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 41 | + with: |
| 42 | + egress-policy: audit |
| 43 | + |
| 44 | + - name: Checkout Code |
| 45 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + ref: ${{ inputs.ref || github.sha }} |
| 49 | + |
| 50 | + - name: Set up Java |
| 51 | + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 |
| 52 | + with: |
| 53 | + distribution: temurin |
| 54 | + java-version: "21" |
| 55 | + |
| 56 | + - name: Set up Gradle |
| 57 | + uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d1993974129d # v4.3.0 |
| 58 | + with: |
| 59 | + gradle-home-cache-cleanup: true |
| 60 | + |
| 61 | + - name: Build State Validator Uber shadowJar |
| 62 | + run: | |
| 63 | + ./gradlew --no-daemon --stacktrace :hedera-state-validator:shadowJar |
| 64 | +
|
| 65 | + - name: Determine version and artifact |
| 66 | + id: version-and-artifact |
| 67 | + run: | |
| 68 | + set -euo pipefail |
| 69 | + FULL_VER=$(./gradlew --no-daemon :hedera-state-validator:properties | grep '^version:' | cut -d ' ' -f2) |
| 70 | + # Remove -SNAPSHOT suffix if present |
| 71 | + VER_WITHOUT_SNAPSHOT=${FULL_VER%-SNAPSHOT} |
| 72 | + # Extract major.minor (first two segments) |
| 73 | + MAJOR_MINOR=$(echo "$VER_WITHOUT_SNAPSHOT" | cut -d '.' -f1-2) |
| 74 | +
|
| 75 | + # Locate the Shadow (uber) JAR built by the module |
| 76 | + # Shadow defaults to "-all" classifier; pick the most recent matching jar |
| 77 | + ART_DIR="hedera-state-validator/build/libs" |
| 78 | + if [[ ! -d "${ART_DIR}" ]]; then |
| 79 | + echo "Artifact directory not found: ${ART_DIR}" >&2; exit 1 |
| 80 | + fi |
| 81 | + JAR_PATH="$(ls -1t "${ART_DIR}"/*-all.jar 2>/dev/null | head -n1 || true)" |
| 82 | + if [[ -z "${JAR_PATH}" ]]; then |
| 83 | + # fallback to any jar if classifier is customized |
| 84 | + JAR_PATH="$(ls -1t "${ART_DIR}"/*.jar 2>/dev/null | head -n1 || true)" |
| 85 | + fi |
| 86 | + if [[ -z "${JAR_PATH}" ]]; then |
| 87 | + echo "No jar found in ${ART_DIR}" >&2; exit 1 |
| 88 | + fi |
| 89 | +
|
| 90 | + DEST_NAME="hedera-state-validator-${MAJOR_MINOR}.jar" |
| 91 | + echo "full_ver=${FULL_VER}" >> "${GITHUB_OUTPUT}" |
| 92 | + echo "major_minor=${MAJOR_MINOR}" >> "${GITHUB_OUTPUT}" |
| 93 | + echo "jar_path=${JAR_PATH}" >> "${GITHUB_OUTPUT}" |
| 94 | + echo "dest_name=${DEST_NAME}" >> "${GITHUB_OUTPUT}" |
| 95 | +
|
| 96 | + - name: Authenticate to Google Cloud |
| 97 | + id: gcloud-auth |
| 98 | + uses: step-security/google-github-auth@40f6deebd366f16c782d7a0ad0844e3b96a032a6 # v2.1.10 |
| 99 | + with: |
| 100 | + workload_identity_provider: "projects/235822363393/locations/global/workloadIdentityPools/hedera-builds-pool/providers/hedera-builds-gh-actions" |
| 101 | + service_account: "[email protected]" |
| 102 | + token_format: "access_token" |
| 103 | + create_credentials_file: true |
| 104 | + |
| 105 | + - name: Setup Google Cloud SDK |
| 106 | + id: setup-gcloud |
| 107 | + uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4 |
| 108 | + with: |
| 109 | + version: "latest" |
| 110 | + install_components: "gsutil" |
| 111 | + |
| 112 | + - name: Upload to GCS |
| 113 | + id: upload |
| 114 | + env: |
| 115 | + SRC: ${{ steps.version-and-artifact.outputs.jar_path }} |
| 116 | + DEST_NAME: ${{ steps.version-and-artifact.outputs.dest_name }} |
| 117 | + BUCKET_PATH: "gs://hedera-ci-ephemeral-artifacts/hedera/hedera-state-validator" |
| 118 | + run: | |
| 119 | + set -euo pipefail |
| 120 | + echo "Source: ${SRC}" |
| 121 | + echo "Destination: ${BUCKET_PATH}/${DEST_NAME}" |
| 122 | + gsutil -m cp "${SRC}" "${BUCKET_PATH}/${DEST_NAME}" |
| 123 | + echo "gcs_uri=${BUCKET_PATH}/${DEST_NAME}" >> "${GITHUB_OUTPUT}" |
| 124 | +
|
| 125 | + - name: Summary |
| 126 | + run: | |
| 127 | + echo "### Published Hedera State Validator Uber JAR" >> "${GITHUB_STEP_SUMMARY}" |
| 128 | + echo "Version: ${{ steps.version-and-artifact.outputs.full_ver }}" >> "${GITHUB_STEP_SUMMARY}" |
| 129 | + echo "File: ${{ steps.version-and-artifact.outputs.dest_name }}" >> "${GITHUB_STEP_SUMMARY}" |
| 130 | + echo "GCS URI: ${{ steps.upload.outputs.gcs_uri }}" >> "${GITHUB_STEP_SUMMARY}" |
0 commit comments