From c4b2bdf077b1cc8263078a5f371deb27de9f0943 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Thu, 7 Dec 2023 10:23:56 +0100 Subject: [PATCH 01/10] Fix Docker workflow triggers --- .github/workflows/build-docker.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index e2fc5a6719..37351110c3 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -1,10 +1,13 @@ name: Docker Build on: # Keep in mind the Docker tagging on the "metadata" step if you add new triggers + workflow_dispatch: # In case a repo contributor needs a specific docker tag built. push: branches: [main] release: - types: [created] # GITHUB_REF == tag pushed with the release + # Release logic: + # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=unpublished#release + types: [published, released, prereleased, created, edited ] # GITHUB_REF == tag pushed with the release pull_request: paths: - ".github/workflows/build-docker.yml" From 083f46741d4c88f7bda6bf07ba4b38854fa12973 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Mon, 11 Dec 2023 14:11:06 +0100 Subject: [PATCH 02/10] try updating relase notes --- .github/workflows/build-docker.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 37351110c3..441486b73c 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -80,6 +80,14 @@ jobs: repository: centrifuge/centrifuge-chain short-description: ${{ github.event.repository.description }} enable-url-completion: true + + - name: Update GitHub release + if: github.event_name == 'release' + uses: softprops/action-gh-release@v1 + with: + append_body: true + body: | + Docker Image: [`${{ steps.meta.outputs.tags[0] }}`](https://hub.docker.com/layers/centrifugeio/centrifuge-chain/${{ steps.meta.outputs.tags[0] }}) - if: failure() name: Check available space after build failed From 2ee7e0ef7f1d574d623af62ba435d700635c77cc Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Mon, 11 Dec 2023 14:33:10 +0100 Subject: [PATCH 03/10] avoid multiple triggers on release --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 441486b73c..1864988ece 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -7,7 +7,7 @@ on: release: # Release logic: # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=unpublished#release - types: [published, released, prereleased, created, edited ] # GITHUB_REF == tag pushed with the release + types: [published, released, edited ] # GITHUB_REF == tag pushed with the release pull_request: paths: - ".github/workflows/build-docker.yml" From 10485396c54f1217fe526c1221f462349f90f866 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Mon, 11 Dec 2023 14:34:45 +0100 Subject: [PATCH 04/10] update release only for one of the docker builds --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 1864988ece..3488ab30e5 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -82,7 +82,7 @@ jobs: enable-url-completion: true - name: Update GitHub release - if: github.event_name == 'release' + if: github.event_name == 'release' && matrix.target == 'release' uses: softprops/action-gh-release@v1 with: append_body: true From 61d9cfb7cc7af8a3b4c13b70cd9ec3bb67f371ee Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Mon, 11 Dec 2023 14:41:47 +0100 Subject: [PATCH 05/10] test updating release --- .github/workflows/build-docker.yml | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 3488ab30e5..d3317a0b8a 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -21,6 +21,8 @@ jobs: matrix: target: [ release, test ] runs-on: ubuntu-latest-8-cores + permissions: + contents: write steps: - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4 with: @@ -54,22 +56,22 @@ jobs: core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Build and push centrifugeio/centrifuge-chain - uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5 - with: - context: . - file: ./docker/centrifuge-chain/Dockerfile - build-args: | - FEATURES=${{ matrix.target == 'test' && 'fast-runtime' || '' }} - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - # Cache options: - # https://docs.docker.com/build/ci/github-actions/cache/ - cache-from: type=gha - # cache-from: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }} - # https://docs.docker.com/build/cache/backends/inline/ - cache-to: type=gha, mode=max - # cache-to: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }}, mode=max + # - name: Build and push centrifugeio/centrifuge-chain + # uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5 + # with: + # context: . + # file: ./docker/centrifuge-chain/Dockerfile + # build-args: | + # FEATURES=${{ matrix.target == 'test' && 'fast-runtime' || '' }} + # push: ${{ github.event_name != 'pull_request' }} + # tags: ${{ steps.meta.outputs.tags }} + # # Cache options: + # # https://docs.docker.com/build/ci/github-actions/cache/ + # cache-from: type=gha + # # cache-from: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }} + # # https://docs.docker.com/build/cache/backends/inline/ + # cache-to: type=gha, mode=max + # # cache-to: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }}, mode=max - name: Update DockerHub descriptions if: contains(github.ref, 'refs/tags/release-v') From 6f355d21c2be5eefe831bec4dd2a52fe6885ad57 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Mon, 11 Dec 2023 14:53:48 +0100 Subject: [PATCH 06/10] Update release comments --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index d3317a0b8a..ed6dbdf0f8 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -89,7 +89,7 @@ jobs: with: append_body: true body: | - Docker Image: [`${{ steps.meta.outputs.tags[0] }}`](https://hub.docker.com/layers/centrifugeio/centrifuge-chain/${{ steps.meta.outputs.tags[0] }}) + Docker tags updated: ${{ steps.meta.outputs.tags }} - if: failure() name: Check available space after build failed From 4566495e4053e5a6fc84c9cf2c3c2bdae0bce020 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Mon, 11 Dec 2023 14:58:53 +0100 Subject: [PATCH 07/10] final version --- .github/workflows/build-docker.yml | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index ed6dbdf0f8..716d1c51f3 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -56,22 +56,22 @@ jobs: core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - # - name: Build and push centrifugeio/centrifuge-chain - # uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5 - # with: - # context: . - # file: ./docker/centrifuge-chain/Dockerfile - # build-args: | - # FEATURES=${{ matrix.target == 'test' && 'fast-runtime' || '' }} - # push: ${{ github.event_name != 'pull_request' }} - # tags: ${{ steps.meta.outputs.tags }} - # # Cache options: - # # https://docs.docker.com/build/ci/github-actions/cache/ - # cache-from: type=gha - # # cache-from: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }} - # # https://docs.docker.com/build/cache/backends/inline/ - # cache-to: type=gha, mode=max - # # cache-to: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }}, mode=max + - name: Build and push centrifugeio/centrifuge-chain + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5 + with: + context: . + file: ./docker/centrifuge-chain/Dockerfile + build-args: | + FEATURES=${{ matrix.target == 'test' && 'fast-runtime' || '' }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + # Cache options: + # https://docs.docker.com/build/ci/github-actions/cache/ + cache-from: type=gha + # cache-from: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }} + # https://docs.docker.com/build/cache/backends/inline/ + cache-to: type=gha, mode=max + # cache-to: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }}, mode=max - name: Update DockerHub descriptions if: contains(github.ref, 'refs/tags/release-v') @@ -89,7 +89,8 @@ jobs: with: append_body: true body: | - Docker tags updated: ${{ steps.meta.outputs.tags }} + **Docker tags:** + ${{ steps.meta.outputs.tags }} - if: failure() name: Check available space after build failed From 6e1bdcd3c081a5a59cd8dc21e6378245827fbf51 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Mon, 11 Dec 2023 16:10:33 +0100 Subject: [PATCH 08/10] create a docker tag on release creation only --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 716d1c51f3..032cff5ade 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -7,7 +7,7 @@ on: release: # Release logic: # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=unpublished#release - types: [published, released, edited ] # GITHUB_REF == tag pushed with the release + types: [ created ] # GITHUB_REF == tag pushed with the release pull_request: paths: - ".github/workflows/build-docker.yml" From e49d0d2ce46480b6ef638708813ccd5d50eca138 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 8 May 2024 18:52:51 +0200 Subject: [PATCH 09/10] better docker build for releases --- .github/workflows/build-docker.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 7b453835ca..af5547231c 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -3,11 +3,12 @@ on: # Keep in mind the Docker tagging on the "metadata" step if you add new triggers workflow_dispatch: # In case a repo contributor needs a specific docker tag built. push: - branches: [main] + tags: ['v*.*.*'] release: # Release logic: # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=unpublished#release - types: [ created ] # GITHUB_REF == tag pushed with the release + # + types: [ released ] # GITHUB_REF == tag pushed with the release pull_request: paths: - ".github/workflows/build-docker.yml" @@ -56,6 +57,11 @@ jobs: images: | ghcr.io/centrifuge/centrifuge-chain ${{ github.event_name != 'pull_request' && 'centrifugeio/centrifuge-chain' || ''}} + # TAGS: + # v.X.Y.Z when pushing a git tag (or a release) + # latest when triggered by a release + # PRXYZ when triggered from a PR (testing) + # {BRANCH_NAME} when triggered from branch push tags: | type=semver,pattern={{raw}},prefix=${{ matrix.target == 'test' && 'test-' || '' }} type=raw,value=latest,enable=${{ github.event_name == 'release' }} @@ -105,12 +111,12 @@ jobs: enable-url-completion: true - name: Update GitHub release - if: github.event_name == 'release' && matrix.target == 'release' + if: github.event_name == 'release' && github.event.action == 'released' && matrix.target == 'release' uses: softprops/action-gh-release@v1 with: append_body: true body: | - **Docker tags:** + **Docker tags (${{ env.NOW }}):** ${{ steps.meta.outputs.tags }} - if: failure() From 216a029a59e82ef86140e52de62837bbae43adcc Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 8 May 2024 19:22:03 +0200 Subject: [PATCH 10/10] push to DH on tag and release --- .github/workflows/build-docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index af5547231c..76b3cda392 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -4,6 +4,7 @@ on: workflow_dispatch: # In case a repo contributor needs a specific docker tag built. push: tags: ['v*.*.*'] + branches: [main] release: # Release logic: # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=unpublished#release @@ -56,7 +57,7 @@ jobs: with: images: | ghcr.io/centrifuge/centrifuge-chain - ${{ github.event_name != 'pull_request' && 'centrifugeio/centrifuge-chain' || ''}} + ${{ (github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))) && 'centrifugeio/centrifuge-chain' || ''}} # TAGS: # v.X.Y.Z when pushing a git tag (or a release) # latest when triggered by a release