|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + gradle_args: |
| 10 | + description: "Extra Gradle args for the release run, for example: --stacktrace" |
| 11 | + required: false |
| 12 | + default: "" |
| 13 | + type: string |
| 14 | + gradle_log_level: |
| 15 | + description: "Gradle log level used by workflow Gradle invocations" |
| 16 | + required: false |
| 17 | + default: info |
| 18 | + type: choice |
| 19 | + options: |
| 20 | + - quiet |
| 21 | + - warn |
| 22 | + - lifecycle |
| 23 | + - info |
| 24 | + - debug |
| 25 | + skip_tests: |
| 26 | + description: "Skip verification tasks before release" |
| 27 | + required: false |
| 28 | + default: false |
| 29 | + type: boolean |
| 30 | + |
| 31 | +permissions: |
| 32 | + contents: write |
| 33 | + packages: write |
| 34 | + |
| 35 | +concurrency: |
| 36 | + group: release-master |
| 37 | + cancel-in-progress: false |
| 38 | + |
| 39 | +jobs: |
| 40 | + release: |
| 41 | + if: >- |
| 42 | + github.event_name == 'workflow_dispatch' || |
| 43 | + ( |
| 44 | + !contains(github.event.head_commit.message, '[Gradle Release Plugin]') && |
| 45 | + !contains(github.event.head_commit.message, '[skip ci]') && |
| 46 | + !contains(github.event.head_commit.message, '[ci skip]') && |
| 47 | + !contains(github.event.head_commit.message, '[no ci]') && |
| 48 | + !contains(github.event.head_commit.message, '[skip actions]') && |
| 49 | + !contains(github.event.head_commit.message, '[actions skip]') && |
| 50 | + !contains(github.event.head_commit.message, 'skip-checks:true') |
| 51 | + ) |
| 52 | + runs-on: ubuntu-latest |
| 53 | + timeout-minutes: 180 |
| 54 | + |
| 55 | + env: |
| 56 | + GRADLE_OPTS: >- |
| 57 | + -Dorg.gradle.daemon=false |
| 58 | + -Dorg.gradle.internal.http.connectionTimeout=120000 |
| 59 | + -Dorg.gradle.internal.http.socketTimeout=300000 |
| 60 | + EXTRA_GRADLE_ARGS: ${{ github.event.inputs.gradle_args || '' }} |
| 61 | + GRADLE_LOG_LEVEL: ${{ github.event.inputs.gradle_log_level || 'info' }} |
| 62 | + SKIP_TESTS: ${{ github.event.inputs.skip_tests || 'false' }} |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + fetch-depth: 0 |
| 69 | + token: ${{ secrets.RELEASE_GITHUB_TOKEN }} |
| 70 | + |
| 71 | + - name: Set up JDK 17 |
| 72 | + uses: actions/setup-java@v4 |
| 73 | + with: |
| 74 | + distribution: temurin |
| 75 | + java-version: '17' |
| 76 | + |
| 77 | + - name: Set up Gradle |
| 78 | + uses: gradle/actions/setup-gradle@v4 |
| 79 | + with: |
| 80 | + cache-read-only: false |
| 81 | + |
| 82 | + - name: Cache Jib |
| 83 | + uses: actions/cache@v4 |
| 84 | + with: |
| 85 | + path: | |
| 86 | + ~/.cache/google-cloud-tools-java/jib |
| 87 | + ~/.gradle/caches/jib |
| 88 | + key: jib-${{ runner.os }}-${{ hashFiles('app/build.gradle.kts', 'build.gradle.kts', 'gradle.properties') }} |
| 89 | + restore-keys: | |
| 90 | + jib-${{ runner.os }}- |
| 91 | +
|
| 92 | + - name: Configure git |
| 93 | + run: | |
| 94 | + git config user.name "github-actions[bot]" |
| 95 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 96 | +
|
| 97 | + - name: Verify build |
| 98 | + if: env.SKIP_TESTS != 'true' |
| 99 | + run: | |
| 100 | + ./gradlew --no-configuration-cache check --stacktrace "--$GRADLE_LOG_LEVEL" |
| 101 | +
|
| 102 | + - name: Write signing key |
| 103 | + env: |
| 104 | + SIGNING_KEY_ASC: ${{ secrets.SIGNING_KEY_ASC }} |
| 105 | + run: | |
| 106 | + printf '%s' "$SIGNING_KEY_ASC" > "$RUNNER_TEMP/signing-key.asc" |
| 107 | +
|
| 108 | + - name: Capture release metadata |
| 109 | + run: | |
| 110 | + release_version="$(awk -F= '/^[[:space:]]*version[[:space:]]*=/{gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2); print $2; exit}' gradle.properties)" |
| 111 | + if [ -z "$release_version" ]; then |
| 112 | + echo "Could not read version from gradle.properties" >&2 |
| 113 | + exit 1 |
| 114 | + fi |
| 115 | + release_version="${release_version%-SNAPSHOT}" |
| 116 | + echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV" |
| 117 | +
|
| 118 | + - name: Run release |
| 119 | + id: run_release |
| 120 | + timeout-minutes: 150 |
| 121 | + env: |
| 122 | + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} |
| 123 | + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} |
| 124 | + SIGNING_KEY_FILE: ${{ runner.temp }}/signing-key.asc |
| 125 | + SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} |
| 126 | + JIB_TO_IMAGE: ghcr.io/openprojectx/yarn-log-api |
| 127 | + JIB_TO_USERNAME: ${{ github.actor }} |
| 128 | + JIB_TO_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + run: | |
| 130 | + skip_test_args=() |
| 131 | + if [ "$SKIP_TESTS" = "true" ]; then |
| 132 | + skip_test_args=(-x test) |
| 133 | + fi |
| 134 | + ./gradlew --no-configuration-cache release --stacktrace "--$GRADLE_LOG_LEVEL" "${skip_test_args[@]}" $EXTRA_GRADLE_ARGS |
| 135 | +
|
| 136 | + - name: Upload diagnostics |
| 137 | + if: failure() |
| 138 | + uses: actions/upload-artifact@v4 |
| 139 | + with: |
| 140 | + name: release-diagnostics-${{ github.run_id }}-${{ github.run_attempt }} |
| 141 | + path: | |
| 142 | + **/build/reports/ |
| 143 | + **/build/test-results/ |
| 144 | + if-no-files-found: ignore |
| 145 | + retention-days: 14 |
| 146 | + |
| 147 | + - name: Write release publish summary |
| 148 | + if: always() && env.RELEASE_VERSION != '' |
| 149 | + env: |
| 150 | + RELEASE_OUTCOME: ${{ steps.run_release.outcome }} |
| 151 | + run: | |
| 152 | + group_id="org.openprojectx.hadoop.yarn.log.api" |
| 153 | + version="${RELEASE_VERSION}" |
| 154 | + artifacts=( |
| 155 | + "core" |
| 156 | + "yarn-log-api-spring-boot-autoconfigure" |
| 157 | + "yarn-log-api-spring-boot-starter" |
| 158 | + ) |
| 159 | +
|
| 160 | + { |
| 161 | + if [ "$RELEASE_OUTCOME" = "success" ]; then |
| 162 | + echo "## Release publish summary" |
| 163 | + else |
| 164 | + echo "## Release publish attempt" |
| 165 | + fi |
| 166 | + echo |
| 167 | + echo "- Version: \`${version}\`" |
| 168 | + echo "- Release result: \`${RELEASE_OUTCOME}\`" |
| 169 | + echo "- Maven group: \`${group_id}\`" |
| 170 | + echo "- Container image: \`ghcr.io/openprojectx/yarn-log-api:${version}\`" |
| 171 | + echo |
| 172 | + if [ "$RELEASE_OUTCOME" != "success" ]; then |
| 173 | + echo "> The release step did not complete successfully. The artifacts below are the planned Maven Central coordinates; check the Gradle log to confirm whether any partial uploads happened before the failure." |
| 174 | + echo |
| 175 | + fi |
| 176 | + echo "| Artifact | Maven coordinate | Maven Central |" |
| 177 | + echo "|---|---|---|" |
| 178 | + for artifact in "${artifacts[@]}"; do |
| 179 | + coordinate="${group_id}:${artifact}:${version}" |
| 180 | + central_url="https://central.sonatype.com/artifact/${group_id}/${artifact}/${version}" |
| 181 | + echo "| \`${artifact}\` | \`${coordinate}\` | [artifact](${central_url}) |" |
| 182 | + done |
| 183 | + echo |
| 184 | + echo "> Maven Central search can lag for a short time after Sonatype release completes." |
| 185 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments