From 9c56be0a4cf2cdab54aec631de6c142a744c636c Mon Sep 17 00:00:00 2001 From: FabioPinheiro Date: Thu, 28 Nov 2024 13:17:42 +0000 Subject: [PATCH 1/3] build: cleanup & improve release-docker-hub job Signed-off-by: FabioPinheiro --- .github/workflows/build.yml | 88 ------------------------ .github/workflows/release-docker-hub.yml | 27 +++++++- .github/workflows/release.yml | 75 -------------------- 3 files changed, 26 insertions(+), 164 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f1301b86..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Build and Publish Revision - -concurrency: - group: release - -on: - workflow_dispatch: - push: - branches: - - "main" - paths: - - "mediator/**" - - "*.sbt" - - "project/**" - - "webapp/**" - -jobs: - build: - if: ${{ !contains(github.event.head_commit.message, 'chore(release)') }} - runs-on: ubuntu-latest - env: - GITHUB_ACTOR: "hyperledger-bot" - GITHUB_ACTOR_EMAIL: "hyperledger-bot@hyperledger.org" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true - SBT_OPTS: -Xmx2G - - permissions: - contents: write - packages: write - - steps: - - uses: actions/checkout@v4 - - - name: Setup Java and Scala - uses: olafurpg/setup-scala@v14 - with: - java-version: openjdk@1.11 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: "lts/*" - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ env.GITHUB_ACTOR }} - password: ${{ env.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Get short commit hash - run: echo "COMMIT_HASH=${GITHUB_SHA::7}" >> $GITHUB_ENV - - - name: Set build number - run: echo "BUILD_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - - - name: Extract version from version.sbt - id: get_version - run: | - VERSION=$(grep -Eo 'version := "[^"]+"' version.sbt | sed 's/version := "//; s/"//; s/-SNAPSHOT//') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Set build version - run: echo "BUILD_VERSION=${{ env.VERSION }}-${{ env.BUILD_NUMBER }}-${{ env.COMMIT_HASH }}" >> $GITHUB_ENV - - - name: Build and push Docker image - env: - NODE_OPTIONS: --openssl-legacy-provider - run: | - sbt -J-Xmx5120m "set ThisBuild / version := \"${{ env.BUILD_VERSION }}\"" "docker:stage" - docker buildx build --platform=linux/arm64,linux/amd64 --push -t ghcr.io/hyperledger/identus-mediator:${{ env.BUILD_VERSION}} ./mediator/target/docker/stage - - - - name: Trigger helm chart update - uses: peter-evans/repository-dispatch@v3 - with: - token: ${{ secrets.ATALA_GITHUB_TOKEN }} - repository: input-output-hk/atala-prism-helm-charts - event-type: build-chart-package - client-payload: '{"version": "${{ env.BUILD_VERSION }}", "chart": "mediator"}' diff --git a/.github/workflows/release-docker-hub.yml b/.github/workflows/release-docker-hub.yml index 3084fcd6..74949ef3 100644 --- a/.github/workflows/release-docker-hub.yml +++ b/.github/workflows/release-docker-hub.yml @@ -3,19 +3,38 @@ name: Release to Docker Hub # updated: 2024/11/25 # How to test: # > git tag v9.9.9 -# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN -j build-and-push-docker-images schedule # > git tag --delete v9.9.9 +# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN -j build-and-push-docker-images schedule +# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" \ +# --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN \ +# --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN \ +# workflow_dispatch --workflows '.github/workflows/release-docker-hub.yml' --eventpath \ +# <( jq -n '{ inputs: { DEPLOYMENT_BRANCH: "v1.0.0" } }' ) + +# How to push old images from another repo: +# > docker login docker.io -u fmgp -p $DOCKERHUB_FMGP_TOKEN +# > docker login docker.io -u identus -p $DOCKERHUB_IDENTUS_TOKEN +# > OLD_TAG=ghcr.io/hyperledger/identus-mediator:1.0.0; NEW_TAG=docker.io/identus/identus-mediator:1.0.0; docker buildx imagetools create --tag "$NEW_TAG" "$OLD_TAG" + + concurrency: group: release on: workflow_dispatch: + # inputs: + # DEPLOYMENT_BRANCH: + # description: branch that needs to be deployed + # type: string + # required: false schedule: - cron: '0 0 * * *' # Run every day at midnight UTC push: tags: - v* + branches: + - 'main' permissions: contents: read @@ -32,6 +51,8 @@ jobs: SBT_OPTS: -Xmx2G steps: - uses: actions/checkout@v4 + # with: + # ref: ${{ inputs.DEPLOYMENT_BRANCH }} - name: Setup Java and Scala uses: olafurpg/setup-scala@v14 @@ -46,6 +67,9 @@ jobs: with: node-version: "lts/*" + - name: Setup Scala.JS + uses: japgolly/setup-scalajs@v1 + - name: Build Binaries env: NODE_OPTIONS: --openssl-legacy-provider @@ -73,6 +97,7 @@ jobs: password_name: DOCKERHUB_IDENTUS_TOKEN tags_noschedule: | type=semver,pattern={{version}} + type=sha,format=long type=raw,value=latest,enable={{is_default_branch}} # type=raw,value=${{needs.pick-build-version.outputs.build_version}} tags_schedule: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5fba7a7b..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Release - -concurrency: - group: release - -on: - workflow_dispatch: - -jobs: - release: - runs-on: ubuntu-latest - env: - GITHUB_ACTOR: "hyperledger-bot" - GITHUB_ACTOR_EMAIL: "hyperledger-bot@hyperledger.org" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - - permissions: - contents: write - packages: write - - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.IDENTUS_CI }} - - - name: Setup Java and Scala - uses: olafurpg/setup-scala@v14 - with: - java-version: openjdk@1.11 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: "lts/*" - - - name: Setup Scala.JS - uses: japgolly/setup-scalajs@v1 - - - name: Cache sbt - uses: coursier/cache-action@v6.3 - - - uses: crazy-max/ghaction-import-gpg@v6 - id: import_gpg - with: - gpg_private_key: ${{ secrets.HYP_BOT_GPG_PRIVATE }} - passphrase: ${{ secrets.HYP_BOT_GPG_PASSWORD }} - git_user_signingkey: true - git_commit_gpgsign: true - git_config_global: true - git_tag_gpgsign: false - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ env.GITHUB_ACTOR }} - password: ${{ env.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Release - env: - GIT_AUTHOR_EMAIL: ${{ steps.import_gpg.outputs.email }} - GIT_COMMITTER_EMAIL: ${{ steps.import_gpg.outputs.email }} - GIT_AUTHOR_NAME: ${{ steps.import_gpg.outputs.name }} - GIT_COMMITTER_NAME: ${{ steps.import_gpg.outputs.name }} - GITHUB_TOKEN: ${{ secrets.IDENTUS_CI }} - run: | - npm install - npx semantic-release From bb75ce53e639d89f742aa77e87e90c6756d78f87 Mon Sep 17 00:00:00 2001 From: FabioPinheiro Date: Thu, 28 Nov 2024 15:33:43 +0000 Subject: [PATCH 2/3] Same more fixes Signed-off-by: FabioPinheiro --- .github/workflows/release-docker-hub.yml | 28 +++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release-docker-hub.yml b/.github/workflows/release-docker-hub.yml index 74949ef3..5050a083 100644 --- a/.github/workflows/release-docker-hub.yml +++ b/.github/workflows/release-docker-hub.yml @@ -5,6 +5,7 @@ name: Release to Docker Hub # > git tag v9.9.9 # > git tag --delete v9.9.9 # > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN -j build-and-push-docker-images schedule +# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN --workflows '.github/workflows/release-docker-hub.yml' push # > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" \ # --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN \ # --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN \ @@ -98,20 +99,20 @@ jobs: tags_noschedule: | type=semver,pattern={{version}} type=sha,format=long - type=raw,value=latest,enable={{is_default_branch}} - # type=raw,value=${{needs.pick-build-version.outputs.build_version}} + type=edge,branch=main + type=raw,value=latest,enable=${{ !startsWith(github.ref, 'refs/tags/v') }} tags_schedule: | type=schedule,pattern=nightly,enable={{is_default_branch}} - - # fmgp # My presonal acount also for testing - registry: docker.io - repository: ${{vars.DOCKERHUB_FMGP_USERNAME}} - username: ${{vars.DOCKERHUB_FMGP_USERNAME}} - password_name: DOCKERHUB_FMGP_TOKEN - tags_noschedule: | - type=semver,pattern={{version}},enable={{is_default_branch}} - type=raw,value=latest,enable={{is_default_branch}} - tags_schedule: | - type=schedule,enable={{is_default_branch}} + # - # fmgp # My presonal acount also for testing + # registry: docker.io + # repository: ${{vars.DOCKERHUB_FMGP_USERNAME}} + # username: ${{vars.DOCKERHUB_FMGP_USERNAME}} + # password_name: DOCKERHUB_FMGP_TOKEN + # tags_noschedule: | + # type=semver,pattern={{version}},enable={{is_default_branch}} + # type=raw,value=latest,enable={{is_default_branch}} + # tags_schedule: | + # type=schedule,enable={{is_default_branch}} steps: - name: Set test variable @@ -119,11 +120,8 @@ jobs: echo "META_CONFIG<> $GITHUB_ENV if [ ${{ github.event_name }} == 'schedule' ]; then echo "${{matrix.docker.tags_schedule}}" >> $GITHUB_ENV; - # type=semver,pattern={{version}} - # type=sha,prefix={{branch}}- else echo "${{matrix.docker.tags_noschedule}}" >> $GITHUB_ENV; - # type=schedule,pattern={{date 'YYYYMMDD'}} fi echo "EOF" >> $GITHUB_ENV From 1df461a1b9881fb75749ccaf7433f2d493fbc0a1 Mon Sep 17 00:00:00 2001 From: FabioPinheiro Date: Fri, 29 Nov 2024 13:19:54 +0000 Subject: [PATCH 3/3] cleanup Signed-off-by: FabioPinheiro --- .github/workflows/release-docker-hub.yml | 30 +++++++++--------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release-docker-hub.yml b/.github/workflows/release-docker-hub.yml index 5050a083..90ad33e6 100644 --- a/.github/workflows/release-docker-hub.yml +++ b/.github/workflows/release-docker-hub.yml @@ -24,11 +24,6 @@ concurrency: on: workflow_dispatch: - # inputs: - # DEPLOYMENT_BRANCH: - # description: branch that needs to be deployed - # type: string - # required: false schedule: - cron: '0 0 * * *' # Run every day at midnight UTC push: @@ -52,8 +47,6 @@ jobs: SBT_OPTS: -Xmx2G steps: - uses: actions/checkout@v4 - # with: - # ref: ${{ inputs.DEPLOYMENT_BRANCH }} - name: Setup Java and Scala uses: olafurpg/setup-scala@v14 @@ -81,8 +74,7 @@ jobs: with: name: docker-directory-artifact path: ./mediator/target/docker/stage - - + build-and-push-docker-images: name: Build and Push Docker images runs-on: ubuntu-latest @@ -103,16 +95,16 @@ jobs: type=raw,value=latest,enable=${{ !startsWith(github.ref, 'refs/tags/v') }} tags_schedule: | type=schedule,pattern=nightly,enable={{is_default_branch}} - # - # fmgp # My presonal acount also for testing - # registry: docker.io - # repository: ${{vars.DOCKERHUB_FMGP_USERNAME}} - # username: ${{vars.DOCKERHUB_FMGP_USERNAME}} - # password_name: DOCKERHUB_FMGP_TOKEN - # tags_noschedule: | - # type=semver,pattern={{version}},enable={{is_default_branch}} - # type=raw,value=latest,enable={{is_default_branch}} - # tags_schedule: | - # type=schedule,enable={{is_default_branch}} + - # fmgp # My presonal acount also for testing + registry: docker.io + repository: ${{vars.DOCKERHUB_FMGP_USERNAME}} + username: ${{vars.DOCKERHUB_FMGP_USERNAME}} + password_name: DOCKERHUB_FMGP_TOKEN + tags_noschedule: | + type=semver,pattern={{version}},enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + tags_schedule: | + type=schedule,enable={{is_default_branch}} steps: - name: Set test variable