From 5ad07c4d1031eedc70e38dbad62b0330a9cd720c Mon Sep 17 00:00:00 2001 From: Tom Sellman Date: Wed, 4 Dec 2024 11:16:08 +0000 Subject: [PATCH] Headless release: alternative single script workflow in `build.yml` --- .github/scripts/deploy-plugins-to-github.sh | 0 .github/scripts/deploy-plugins-to-maven.sh | 0 .github/scripts/deploy-to-docker.sh | 0 .github/scripts/deploy-to-github.sh | 0 .github/scripts/deploy-to-maven.sh | 0 .github/scripts/deploy-to-s3.sh | 0 .github/scripts/publish-release.sh | 0 .github/scripts/release.sh | 28 ++ .github/scripts/tag-release.sh | 0 .github/scripts/update-plugins-index.sh | 0 .github/workflows/build.yml | 70 ++++- .github/workflows/release.yml | 307 -------------------- 12 files changed, 96 insertions(+), 309 deletions(-) mode change 100644 => 100755 .github/scripts/deploy-plugins-to-github.sh mode change 100644 => 100755 .github/scripts/deploy-plugins-to-maven.sh mode change 100644 => 100755 .github/scripts/deploy-to-docker.sh mode change 100644 => 100755 .github/scripts/deploy-to-github.sh mode change 100644 => 100755 .github/scripts/deploy-to-maven.sh mode change 100644 => 100755 .github/scripts/deploy-to-s3.sh mode change 100644 => 100755 .github/scripts/publish-release.sh create mode 100644 .github/scripts/release.sh mode change 100644 => 100755 .github/scripts/tag-release.sh mode change 100644 => 100755 .github/scripts/update-plugins-index.sh delete mode 100644 .github/workflows/release.yml diff --git a/.github/scripts/deploy-plugins-to-github.sh b/.github/scripts/deploy-plugins-to-github.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/deploy-plugins-to-maven.sh b/.github/scripts/deploy-plugins-to-maven.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/deploy-to-docker.sh b/.github/scripts/deploy-to-docker.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/deploy-to-github.sh b/.github/scripts/deploy-to-github.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/deploy-to-maven.sh b/.github/scripts/deploy-to-maven.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/deploy-to-s3.sh b/.github/scripts/deploy-to-s3.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/publish-release.sh b/.github/scripts/publish-release.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh new file mode 100644 index 0000000000..78310b866f --- /dev/null +++ b/.github/scripts/release.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -e + +# build artifacts +make distribution + +# tag release +./tag-release.sh + +# deploy to maven +./deploy-to-maven.sh + +# deploy to S3 +./deploy-to-s3.sh + +# deploy to docker +./deploy-to-docker.sh + +# deploy to github +./deploy-to-github.sh + +# deploy plugins +./deploy-plugins-to-maven.sh +./deploy-plugins-to-github.sh +./update-plugins-index.sh + +# finally, publish the distribution +./publish-release.sh diff --git a/.github/scripts/tag-release.sh b/.github/scripts/tag-release.sh old mode 100644 new mode 100755 diff --git a/.github/scripts/update-plugins-index.sh b/.github/scripts/update-plugins-index.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f602c3d75..1a77e9e0f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -244,6 +244,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.AUTOMATION_GITHUB_TOKEN }} GRADLE_OPTS: '-Dorg.gradle.daemon=false' + # -------------------------------------------------- + # job: release + # -------------------------------------------------- release: name: Release if: ${{ contains(needs.build.outputs.commit_message,'[release]') }} @@ -251,13 +254,76 @@ jobs: needs: build timeout-minutes: 10 steps: + # setup steps - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 submodules: true + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + architecture: x64 + + - name: Setup AWS + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: eu-west-1 + aws-access-key-id: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }} + + - name: Login to Docker hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_ID }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + + - name: Login to Seqera registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.SEQERA_PUBLIC_CR_URL }} + username: ${{ secrets.SEQERA_PUBLIC_CR_USER }} + password: ${{ secrets.SEQERA_PUBLIC_CR_PASSWORD }} + + # release step - name: Release - run: gh workflow run release.yml --ref ${{ github.ref }} + run: bash .github/scripts/release.sh env: - GH_TOKEN: ${{ secrets.AUTOMATION_GITHUB_TOKEN }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }} + GH_ORG: ${{ vars.PLUGINS_GITHUB_ORG }} + GH_USER: ${{ vars.DEPLOY_GITHUB_USER }} + GH_USER_EMAIL: ${{ vars.DEPLOY_GITHUB_EMAIL }} + GH_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }} + MAVEN_PUBLISH_URL: ${{ vars.MAVEN_PLUGINS_PUBLISH_URL }} + PLUGINS_INDEX_JSON: ${{ vars.PLUGINS_INDEX_JSON }} + S3_RELEASE_BUCKET: ${{ vars.S3_RELEASE_BUCKET }} + SEQERA_REGISTRY: ${{ vars.SEQERA_PUBLIC_CR_URL }} + + # upload steps + - name: Upload artifacts (libs) + uses: actions/upload-artifact@v4 + with: + retention-days: 3 + name: libs + path: modules/*/build/libs/ + + - name: Upload artifacts (distribution) + uses: actions/upload-artifact@v4 + with: + retention-days: 3 + name: distribution + path: build/releases/ + + - name: Upload artifacts (plugins) + uses: actions/upload-artifact@v4 + with: + retention-days: 3 + compression-level: 0 + name: plugins + path: | + plugins/build/libs/ + plugins/*/build/libs/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index c802cab2ac..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,307 +0,0 @@ -name: Release - -on: - workflow_dispatch: - -env: - JAVA_VERSION: 17 - -jobs: - # -------------------------------------------------- - # job: assemble - # -------------------------------------------------- - assemble: - name: Assemble - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - - name: Setup Java - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: 'temurin' - architecture: x64 - cache: gradle - - # build steps - - name: Compile - run: make distribution - - # upload steps - - name: Upload artifacts (libs) - uses: actions/upload-artifact@v4 - with: - retention-days: 3 - name: libs - path: modules/*/build/libs/ - - - name: Upload artifacts (distribution) - uses: actions/upload-artifact@v4 - with: - retention-days: 3 - name: distribution - path: build/releases/ - - - name: Upload artifacts (plugins) - uses: actions/upload-artifact@v4 - with: - retention-days: 3 - compression-level: 0 - name: plugins - path: | - plugins/build/libs/ - plugins/*/build/libs/ - - # -------------------------------------------------- - # job: tag - # -------------------------------------------------- - tag: - name: Tag - runs-on: ubuntu-latest - timeout-minutes: 15 - needs: assemble - permissions: - contents: write - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - # execute steps - - name: Tag - run: bash .github/scripts/tag-release.sh - - # -------------------------------------------------- - # job: deploy-maven - # -------------------------------------------------- - deploy-maven: - name: Deploy to Maven - runs-on: ubuntu-latest - needs: tag - timeout-minutes: 15 - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - - name: Setup Java - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: 'temurin' - architecture: x64 - cache: gradle - - - name: Download artifacts (libs) - uses: actions/download-artifact@v4 - with: - name: libs - path: modules - - # deploy step - - name: Deploy to maven - run: bash .github/scripts/deploy-to-maven.sh - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }} - MAVEN_PUBLISH_URL: ${{ vars.MAVEN_PUBLISH_URL }} - - # -------------------------------------------------- - # job: deploy-s3 - # -------------------------------------------------- - deploy-s3: - name: Deploy to S3 - runs-on: ubuntu-latest - needs: tag - timeout-minutes: 15 - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - - name: Setup AWS - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - aws-access-key-id: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }} - - - name: Download artifacts (distribution) - uses: actions/download-artifact@v4 - with: - name: distribution - path: build/releases - - # deploy step - - name: Deploy to S3 - run: bash .github/scripts/deploy-to-s3.sh - env: - S3_RELEASE_BUCKET: ${{ vars.S3_RELEASE_BUCKET }} - - # -------------------------------------------------- - # job: deploy-docker - # -------------------------------------------------- - deploy-docker: - name: Deploy to Docker - runs-on: ubuntu-latest - needs: - - tag - - deploy-s3 - timeout-minutes: 15 - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - - name: Login to Docker hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_HUB_ID }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - - name: Login to Seqera registry - uses: docker/login-action@v3 - with: - registry: ${{ vars.SEQERA_PUBLIC_CR_URL }} - username: ${{ secrets.SEQERA_PUBLIC_CR_USER }} - password: ${{ secrets.SEQERA_PUBLIC_CR_PASSWORD }} - - # deploy step - - name: Deploy to docker - run: bash .github/scripts/deploy-to-docker.sh - env: - SEQERA_REGISTRY: ${{ vars.SEQERA_PUBLIC_CR_URL }} - - # -------------------------------------------------- - # job: deploy-github - # -------------------------------------------------- - deploy-github: - name: Deploy to Github - runs-on: ubuntu-latest - needs: tag - timeout-minutes: 15 - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - - name: Download artifacts (distribution) - uses: actions/download-artifact@v4 - with: - name: distribution - path: build/releases - - # deploy steps - - name: Create github release - run: bash .github/scripts/deploy-to-github.sh - env: - GH_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }} - - # -------------------------------------------------- - # job: deploy-plugins - # -------------------------------------------------- - deploy-plugins: - name: Deploy Plugins - runs-on: ubuntu-latest - needs: tag - timeout-minutes: 15 - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - - name: Setup Java - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: 'temurin' - architecture: x64 - cache: gradle - - - name: Download artifacts (plugins) - uses: actions/download-artifact@v4 - with: - name: plugins - path: plugins - - # deploy steps - - name: Deploy plugins to maven - run: bash .github/scripts/deploy-plugins-to-maven.sh - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }} - MAVEN_PUBLISH_URL: ${{ vars.MAVEN_PLUGINS_PUBLISH_URL }} - - - name: Deploy plugins to github - run: bash .github/scripts/deploy-plugins-to-github.sh - env: - GH_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }} - GH_ORG: ${{ vars.PLUGINS_GITHUB_ORG }} - - - name: Update plugins index - run: bash .github/scripts/update-plugins-index.sh - env: - GH_ORG: ${{ vars.PLUGINS_GITHUB_ORG }} - GH_USER: ${{ vars.DEPLOY_GITHUB_USER }} - GH_USER_EMAIL: ${{ vars.DEPLOY_GITHUB_EMAIL }} - GH_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }} - PLUGINS_INDEX_JSON: ${{ vars.PLUGINS_INDEX_JSON }} - - - # -------------------------------------------------- - # job: publish - # -------------------------------------------------- - publish: - name: Publish release - runs-on: ubuntu-latest - needs: - - deploy-s3 - - deploy-docker - - deploy-maven - - deploy-github - timeout-minutes: 15 - steps: - # setup steps - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - submodules: true - - - name: Setup AWS - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - aws-access-key-id: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }} - - # deploy steps - - name: Publish release - run: bash .github/scripts/publish-release.sh - env: - S3_RELEASE_BUCKET: ${{ vars.S3_RELEASE_BUCKET }}