|
| 1 | +name: Presto Stable Release - Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + RELEASE_VERSION: |
| 7 | + description: 'Release version (e.g., 0.290)' |
| 8 | + required: true |
| 9 | + create_release_tag: |
| 10 | + description: 'Create release tag' |
| 11 | + type: boolean |
| 12 | + default: true |
| 13 | + required: false |
| 14 | + release-notes-commit: |
| 15 | + description: 'Commit SHA of release notes(required when create_release_tag is checked)' |
| 16 | + required: false |
| 17 | + publish_maven: |
| 18 | + description: 'Publish Maven artifacts' |
| 19 | + type: boolean |
| 20 | + default: true |
| 21 | + required: false |
| 22 | + publish_docker: |
| 23 | + description: 'Publish Docker images' |
| 24 | + type: boolean |
| 25 | + default: true |
| 26 | + required: false |
| 27 | + publish_native_docker: |
| 28 | + description: 'Publish Native Docker images' |
| 29 | + type: boolean |
| 30 | + default: true |
| 31 | + required: false |
| 32 | + tag_image_as_latest: |
| 33 | + description: 'Tag the image as latest version' |
| 34 | + type: boolean |
| 35 | + default: true |
| 36 | + required: false |
| 37 | + dependency_image: |
| 38 | + description: 'Dependency image(e.g., prestodb/presto-native-dependency:0.290-20241014120930-e1fc090)' |
| 39 | + required: false |
| 40 | + default: '' |
| 41 | + |
| 42 | +env: |
| 43 | + VERSION: ${{ github.event.inputs.RELEASE_VERSION }} |
| 44 | + DOCKER_REPO: ${{ github.repository }} |
| 45 | + ORG_NAME: ${{ github.repository_owner }} |
| 46 | + IMAGE_NAME: presto-native |
| 47 | + RELEASE_BRANCH: release-${{ github.event.inputs.RELEASE_VERSION }} |
| 48 | + RELEASE_TAG: ${{ github.event.inputs.RELEASE_VERSION }} |
| 49 | + RELEASE_NOTES_COMMIT: ${{ github.event.inputs.release-notes-commit }} |
| 50 | + |
| 51 | +jobs: |
| 52 | + tag-release: |
| 53 | + if: ${{ github.event.inputs.create_release_tag == 'true' }} |
| 54 | + runs-on: ubuntu-latest |
| 55 | + environment: release |
| 56 | + steps: |
| 57 | + - name: Validate release notes commit |
| 58 | + if: ${{ github.event.inputs.release-notes-commit == '' }} |
| 59 | + run: | |
| 60 | + echo "Error: release-notes-commit is required when create_release_tag is true" |
| 61 | + exit 1 |
| 62 | +
|
| 63 | + - name: Checkout repository |
| 64 | + uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + ref: ${{ env.RELEASE_BRANCH }} |
| 67 | + token: ${{ secrets.PRESTODB_CI_TOKEN }} |
| 68 | + fetch-depth: 0 |
| 69 | + fetch-tags: true |
| 70 | + show-progress: false |
| 71 | + |
| 72 | + - name: Configure Git |
| 73 | + run: | |
| 74 | + git config --global user.email "[email protected]" |
| 75 | + git config --global user.name "prestodb-ci" |
| 76 | + git config pull.rebase false |
| 77 | +
|
| 78 | + - name: Cherry-pick release notes |
| 79 | + run: | |
| 80 | + git cherry-pick ${{ env.RELEASE_NOTES_COMMIT }} |
| 81 | +
|
| 82 | + - name: Delete existing release tag |
| 83 | + run: | |
| 84 | + git push origin :${{ env.RELEASE_TAG }} || true |
| 85 | + git tag -d ${{ env.RELEASE_TAG }} || true |
| 86 | +
|
| 87 | + - name: Create new release tag |
| 88 | + run: | |
| 89 | + git tag -a ${{ env.RELEASE_TAG }} -m "release ${{ env.RELEASE_TAG }}" |
| 90 | + git push origin ${{ env.RELEASE_BRANCH }} --tags |
| 91 | +
|
| 92 | + publish-maven-artifacts: |
| 93 | + needs: tag-release |
| 94 | + if: | |
| 95 | + (github.event.inputs.publish_maven == 'true' || github.event.inputs.publish_docker == 'true') && |
| 96 | + (github.event.inputs.create_release_tag != 'true' || success()) |
| 97 | + runs-on: ubuntu-latest |
| 98 | + environment: release |
| 99 | + timeout-minutes: 60 |
| 100 | + |
| 101 | + env: |
| 102 | + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} |
| 103 | + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Setup JDK 11 |
| 107 | + uses: actions/setup-java@v4 |
| 108 | + with: |
| 109 | + java-version: '11' |
| 110 | + distribution: 'temurin' |
| 111 | + overwrite-settings: true |
| 112 | + gpg-private-key: ${{ secrets.GPG_SECRET }} |
| 113 | + gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} |
| 114 | + |
| 115 | + - name: Install dependencies |
| 116 | + run: | |
| 117 | + sudo apt-get update |
| 118 | + sudo apt-get install -y build-essential git gpg python3 python3-venv |
| 119 | +
|
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + with: |
| 123 | + ref: ${{ env.VERSION }} |
| 124 | + token: ${{ secrets.PRESTODB_CI_TOKEN }} |
| 125 | + fetch-depth: 0 |
| 126 | + fetch-tags: true |
| 127 | + |
| 128 | + - name: Configure Git |
| 129 | + run: | |
| 130 | + git config --global user.email "[email protected]" |
| 131 | + git config --global user.name "prestodb-ci" |
| 132 | + git config pull.rebase false |
| 133 | +
|
| 134 | + - name: Create Maven Settings |
| 135 | + run: | |
| 136 | + cat > ${{ github.workspace }}/settings.xml << 'EOL' |
| 137 | + <settings> |
| 138 | + <servers> |
| 139 | + <server> |
| 140 | + <id>sonatype-nexus-snapshots</id> |
| 141 | + <username>${env.NEXUS_USERNAME}</username> |
| 142 | + <password>${env.NEXUS_PASSWORD}</password> |
| 143 | + </server> |
| 144 | + <server> |
| 145 | + <id>sonatype.snapshots</id> |
| 146 | + <username>${env.NEXUS_USERNAME}</username> |
| 147 | + <password>${env.NEXUS_PASSWORD}</password> |
| 148 | + </server> |
| 149 | + <server> |
| 150 | + <id>ossrh</id> |
| 151 | + <username>${env.NEXUS_USERNAME}</username> |
| 152 | + <password>${env.NEXUS_PASSWORD}</password> |
| 153 | + </server> |
| 154 | + </servers> |
| 155 | + <profiles> |
| 156 | + <profile> |
| 157 | + <id>nexus</id> |
| 158 | + </profile> |
| 159 | + </profiles> |
| 160 | + <activeProfiles> |
| 161 | + <activeProfile>nexus</activeProfile> |
| 162 | + </activeProfiles> |
| 163 | + </settings> |
| 164 | + EOL |
| 165 | +
|
| 166 | + - name: Maven build |
| 167 | + run: mvn clean install -DskipTests |
| 168 | + |
| 169 | + - name: Upload artifacts |
| 170 | + uses: actions/upload-artifact@v4 |
| 171 | + with: |
| 172 | + name: presto-artifacts-${{ env.VERSION }} |
| 173 | + retention-days: 1 |
| 174 | + path: | |
| 175 | + presto-server/target/presto-server-*.tar.gz |
| 176 | + presto-cli/target/presto-cli-*-executable.jar |
| 177 | +
|
| 178 | + - name: Set up GPG key |
| 179 | + run: | |
| 180 | + echo "${{ secrets.GPG_SECRET }}" > ${{ env.GPG_KEY_FILE }} |
| 181 | + chmod 600 ${{ env.GPG_KEY_FILE }} |
| 182 | + gpg --import --batch ${{ env.GPG_KEY_FILE }} |
| 183 | + gpg --batch --yes --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --sign ${{ env.GPG_KEY_FILE }} |
| 184 | + env: |
| 185 | + GPG_TTY: $(tty) |
| 186 | + GPG_KEY_FILE: /tmp/gpg-key.txt |
| 187 | + |
| 188 | + - name: Release Maven Artifacts |
| 189 | + if: ${{ github.event.inputs.publish_maven == 'true' }} |
| 190 | + run: | |
| 191 | + unset MAVEN_CONFIG |
| 192 | + ./mvnw -s ${{ github.workspace }}/settings.xml -V -B -U -e -T1C deploy \ |
| 193 | + -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" \ |
| 194 | + -Dmaven.wagon.http.retryHandler.count=8 \ |
| 195 | + -DskipTests \ |
| 196 | + -DstagingProfileId=28a0d8c4350ed \ |
| 197 | + -DkeepStagingRepositoryOnFailure=true \ |
| 198 | + -DkeepStagingRepositoryOnCloseRuleFailure=true \ |
| 199 | + -DautoReleaseAfterClose=true \ |
| 200 | + -DstagingProgressTimeoutMinutes=60 \ |
| 201 | + -Poss-release \ |
| 202 | + -Pdeploy-to-ossrh \ |
| 203 | + -pl '!presto-test-coverage' |
| 204 | + env: |
| 205 | + GPG_TTY: $(tty) |
| 206 | + |
| 207 | + publish-docker-images: |
| 208 | + if: ${{ github.event.inputs.publish_docker == 'true' && always() }} |
| 209 | + needs: publish-maven-artifacts |
| 210 | + runs-on: ubuntu-latest |
| 211 | + environment: release |
| 212 | + timeout-minutes: 150 |
| 213 | + permissions: |
| 214 | + packages: write |
| 215 | + contents: read |
| 216 | + steps: |
| 217 | + - name: Checkout |
| 218 | + uses: actions/checkout@v4 |
| 219 | + with: |
| 220 | + ref: ${{ env.VERSION }} |
| 221 | + |
| 222 | + - name: Download artifacts |
| 223 | + uses: actions/download-artifact@v4 |
| 224 | + with: |
| 225 | + name: presto-artifacts-${{ env.VERSION }} |
| 226 | + path: ./ |
| 227 | + |
| 228 | + - name: Login to dockerhub |
| 229 | + |
| 230 | + with: |
| 231 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 232 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 233 | + |
| 234 | + - name: Login to gitHub container registry |
| 235 | + |
| 236 | + with: |
| 237 | + registry: ghcr.io |
| 238 | + username: ${{ github.actor }} |
| 239 | + password: ${{ secrets.PRESTODB_CI_TOKEN }} |
| 240 | + |
| 241 | + - name: Set up qemu |
| 242 | + uses: docker/setup-qemu-action@v3 |
| 243 | + |
| 244 | + - name: Set up docker buildx |
| 245 | + |
| 246 | + |
| 247 | + - name: Create and use builder |
| 248 | + run: | |
| 249 | + docker buildx create --name container --use |
| 250 | + docker buildx inspect --bootstrap |
| 251 | +
|
| 252 | + - name: Move artifacts to docker directory |
| 253 | + run: | |
| 254 | + mv ./presto-server/target/presto-server-*.tar.gz docker/ |
| 255 | + mv ./presto-cli/target/presto-cli-*-executable.jar docker/ |
| 256 | +
|
| 257 | + - name: Build docker image and publish |
| 258 | + uses: docker/build-push-action@v6 |
| 259 | + with: |
| 260 | + context: docker |
| 261 | + platforms: linux/amd64,linux/arm64,linux/ppc64le |
| 262 | + file: docker/Dockerfile |
| 263 | + push: true |
| 264 | + build-args: | |
| 265 | + PRESTO_VERSION=${{ env.VERSION }} |
| 266 | + JMX_PROMETHEUS_JAVAAGENT_VERSION=0.20.0 |
| 267 | + tags: | |
| 268 | + ${{ env.DOCKER_REPO }}:${{ env.VERSION }} |
| 269 | + ${{ github.event.inputs.tag_image_as_latest == 'true' && format('{0}:latest', env.DOCKER_REPO) || '' }} |
| 270 | + ghcr.io/${{ github.repository }}:${{ env.VERSION }} |
| 271 | + ${{ github.event.inputs.tag_image_as_latest == 'true' && format('ghcr.io/{0}:latest', github.repository) || '' }} |
| 272 | +
|
| 273 | + publish-native-images: |
| 274 | + needs: tag-release |
| 275 | + if: | |
| 276 | + github.event.inputs.publish_native_docker == 'true' && |
| 277 | + (github.event.inputs.create_release_tag != 'true' || success()) |
| 278 | + runs-on: ubuntu-latest |
| 279 | + permissions: |
| 280 | + contents: read |
| 281 | + packages: write |
| 282 | + attestations: write |
| 283 | + id-token: write |
| 284 | + environment: release |
| 285 | + timeout-minutes: 300 |
| 286 | + steps: |
| 287 | + - name: Checkout |
| 288 | + uses: actions/checkout@v4 |
| 289 | + with: |
| 290 | + ref: ${{ env.VERSION }} |
| 291 | + submodules: true |
| 292 | + |
| 293 | + - name: Initialize Prestissimo submodules |
| 294 | + run: | |
| 295 | + cd presto-native-execution && make submodules |
| 296 | + echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 297 | +
|
| 298 | + - name: Login to DockerHub |
| 299 | + |
| 300 | + with: |
| 301 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 302 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 303 | + |
| 304 | + - name: Login to GitHub Container Registry |
| 305 | + |
| 306 | + with: |
| 307 | + registry: ghcr.io |
| 308 | + username: ${{ github.actor }} |
| 309 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 310 | + |
| 311 | + - name: Set dependency image tag |
| 312 | + run: | |
| 313 | + if [[ -n "${{ github.event.inputs.dependency_image }}" ]]; then |
| 314 | + echo "DEPENDENCY_IMAGE=${{ github.event.inputs.dependency_image }}" >> $GITHUB_ENV |
| 315 | + else |
| 316 | + echo "DEPENDENCY_IMAGE=ghcr.io/${{ github.repository_owner }}/presto-native-dependency:${{ env.VERSION }}-${{ env.COMMIT_SHA }}" >> $GITHUB_ENV |
| 317 | + fi |
| 318 | +
|
| 319 | + - name: Build Dependency Image |
| 320 | + working-directory: presto-native-execution |
| 321 | + run: | |
| 322 | + if docker pull ${{ env.DEPENDENCY_IMAGE }}; then |
| 323 | + echo "Using dependency image ${{ env.DEPENDENCY_IMAGE }}" |
| 324 | + docker tag ${{ env.DEPENDENCY_IMAGE }} presto/prestissimo-dependency:centos9 |
| 325 | + else |
| 326 | + echo "Building new depedency image" |
| 327 | + docker compose build centos-native-dependency |
| 328 | + docker tag presto/prestissimo-dependency:centos9 ghcr.io/${{ github.repository_owner }}/presto-native-dependency:${{ env.VERSION }}-${{ env.COMMIT_SHA }} |
| 329 | + docker push ghcr.io/${{ github.repository_owner }}/presto-native-dependency:${{ env.VERSION }}-${{ env.COMMIT_SHA }} |
| 330 | + fi |
| 331 | + docker images |
| 332 | +
|
| 333 | + - name: Build Runtime Image |
| 334 | + working-directory: presto-native-execution |
| 335 | + run: | |
| 336 | + if docker pull ghcr.io/${{ github.repository_owner }}/presto-native:${{ env.VERSION }}-${{ env.COMMIT_SHA }}; then |
| 337 | + docker tag ghcr.io/${{ github.repository_owner }}/presto-native:${{ env.VERSION }}-${{ env.COMMIT_SHA }} docker.io/presto/prestissimo-runtime:centos9 |
| 338 | + else |
| 339 | + docker compose build centos-native-runtime |
| 340 | + docker tag presto/prestissimo-runtime:centos9 ghcr.io/${{ github.repository_owner }}/presto-native:${{ env.VERSION }}-${{ env.COMMIT_SHA }} |
| 341 | + docker push ghcr.io/${{ github.repository_owner }}/presto-native:${{ env.VERSION }}-${{ env.COMMIT_SHA }} |
| 342 | + fi |
| 343 | +
|
| 344 | + - name: Add release tag |
| 345 | + working-directory: presto-native-execution |
| 346 | + run: | |
| 347 | + docker tag presto/prestissimo-runtime:centos9 ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |
| 348 | + if [[ "${{ github.event.inputs.tag_image_as_latest }}" == "true" ]]; then |
| 349 | + docker tag presto/prestissimo-runtime:centos9 ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:latest |
| 350 | + fi |
| 351 | +
|
| 352 | + - name: Push to DockerHub |
| 353 | + run: | |
| 354 | + docker push ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |
| 355 | + if [[ "${{ github.event.inputs.tag_image_as_latest }}" == "true" ]]; then |
| 356 | + docker tag ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:latest |
| 357 | + docker push ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:latest |
| 358 | + fi |
| 359 | +
|
| 360 | + - name: Tag and push to GitHub Packages |
| 361 | + run: | |
| 362 | + docker tag ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |
| 363 | + docker push ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |
| 364 | + if [[ "${{ github.event.inputs.tag_image_as_latest }}" == "true" ]]; then |
| 365 | + docker tag ${{ env.ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest |
| 366 | + docker push ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest |
| 367 | + fi |
0 commit comments