From e1af43196bc86495afb1a1bab4728989d6fd688e Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 25 Oct 2021 14:03:38 -0400 Subject: [PATCH 1/7] Update GitHub Actions for builds Signed-off-by: Nicko Guyer --- .github/workflows/docker.yml | 29 ++++++++++++++++++++--------- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3e027a807d..15d3be189b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,10 @@ -name: Docker +name: Docker Main Build on: - release: - types: [published, prereleased] + push: + branches: + - main + - actions jobs: docker: @@ -10,20 +12,29 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set build tag + id: build_tag_generator + run: | + RELEASE_TAG=$(curl https://api.github.com/repos/hyperledger/firefly/releases/latest -s | jq .tag_name -r) + BUILD_TAG=$RELEASE_TAG-$(date +"%Y%m%d")-$GITHUB_RUN_NUMBER + echo ::set-output name=BUILD_TAG::$BUILD_TAG + - name: Build - run: docker build -t ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} . + run: docker build \ + --label commit=$GITHUB_SHA \ + --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --label tag=$BUILD_TAG + --tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} . - name: Tag release - if: github.event.action == 'published' - run: docker tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly:latest + run: docker tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly:head - name: Push docker image run: | echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin docker push ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} - - name: Push latest tag - if: github.event.action == 'published' + - name: Push head tag run: | echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin - docker push ghcr.io/hyperledger/firefly:latest \ No newline at end of file + docker push ghcr.io/hyperledger/firefly:head \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..cce7da1c07 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Docker Release Build + +on: + release: + types: [released, prereleased] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Build + run: docker build \ + --label commit=$GITHUB_SHA \ + --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --label tag=${GITHUB_REF##*/} + --tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} . + + - name: Tag release + if: github.event.action == 'released' + run: docker tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly:latest + + - name: Push docker image + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin + docker push ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} + + - name: Push latest tag + if: github.event.action == 'released' + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin + docker push ghcr.io/hyperledger/firefly:latest \ No newline at end of file From f06430fca977f7dc774359b18c8815725836d2ad Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 25 Oct 2021 14:07:05 -0400 Subject: [PATCH 2/7] Fix docker build command Signed-off-by: Nicko Guyer --- .github/workflows/{docker.yml => docker_main.yml} | 2 +- .github/workflows/{release.yml => docker_release.yml} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{docker.yml => docker_main.yml} (97%) rename .github/workflows/{release.yml => docker_release.yml} (96%) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker_main.yml similarity index 97% rename from .github/workflows/docker.yml rename to .github/workflows/docker_main.yml index 15d3be189b..279cb74ffb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker_main.yml @@ -23,7 +23,7 @@ jobs: run: docker build \ --label commit=$GITHUB_SHA \ --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ - --label tag=$BUILD_TAG + --label tag=$BUILD_TAG \ --tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} . - name: Tag release diff --git a/.github/workflows/release.yml b/.github/workflows/docker_release.yml similarity index 96% rename from .github/workflows/release.yml rename to .github/workflows/docker_release.yml index cce7da1c07..a76f9f512f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/docker_release.yml @@ -14,7 +14,7 @@ jobs: run: docker build \ --label commit=$GITHUB_SHA \ --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ - --label tag=${GITHUB_REF##*/} + --label tag=${GITHUB_REF##*/} \ --tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} . - name: Tag release From c868359332f6a11241db462755671a85dcb2fe44 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 25 Oct 2021 14:09:57 -0400 Subject: [PATCH 3/7] Update GitHub Actions for builds Signed-off-by: Nicko Guyer --- .github/workflows/docker_main.yml | 11 ++++++----- .github/workflows/docker_release.yml | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml index 279cb74ffb..ab660cc6bd 100644 --- a/.github/workflows/docker_main.yml +++ b/.github/workflows/docker_main.yml @@ -20,11 +20,12 @@ jobs: echo ::set-output name=BUILD_TAG::$BUILD_TAG - name: Build - run: docker build \ - --label commit=$GITHUB_SHA \ - --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ - --label tag=$BUILD_TAG \ - --tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} . + run: | + docker build \ + --label commit=$GITHUB_SHA \ + --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --label tag=$BUILD_TAG \ + --tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} . - name: Tag release run: docker tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly:head diff --git a/.github/workflows/docker_release.yml b/.github/workflows/docker_release.yml index a76f9f512f..02a8440a88 100644 --- a/.github/workflows/docker_release.yml +++ b/.github/workflows/docker_release.yml @@ -11,11 +11,12 @@ jobs: - uses: actions/checkout@v2 - name: Build - run: docker build \ - --label commit=$GITHUB_SHA \ - --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ - --label tag=${GITHUB_REF##*/} \ - --tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} . + run: | + docker build \ + --label commit=$GITHUB_SHA \ + --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --label tag=${GITHUB_REF##*/} \ + --tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} . - name: Tag release if: github.event.action == 'released' From a3b3a6c468b3b5b257aff4dba0007979ce372623 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 25 Oct 2021 14:19:09 -0400 Subject: [PATCH 4/7] Update tag on main build Signed-off-by: Nicko Guyer --- .github/workflows/docker_main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml index ab660cc6bd..44e7a8e2c3 100644 --- a/.github/workflows/docker_main.yml +++ b/.github/workflows/docker_main.yml @@ -28,12 +28,12 @@ jobs: --tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} . - name: Tag release - run: docker tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly:head + run: docker tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} ghcr.io/hyperledger/firefly:head - name: Push docker image run: | echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin - docker push ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} + docker push ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} - name: Push head tag run: | From ce22c67d6db2cf3b0eb2cd85760e9f6820f06f33 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 25 Oct 2021 14:33:35 -0400 Subject: [PATCH 5/7] Fix docker build tag label Signed-off-by: Nicko Guyer --- .github/workflows/docker_main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml index 44e7a8e2c3..6d6849ff8b 100644 --- a/.github/workflows/docker_main.yml +++ b/.github/workflows/docker_main.yml @@ -24,7 +24,7 @@ jobs: docker build \ --label commit=$GITHUB_SHA \ --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ - --label tag=$BUILD_TAG \ + --label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \ --tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} . - name: Tag release From d16d316d70a446366df0f2a44354a2b914a971e4 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 25 Oct 2021 15:03:39 -0400 Subject: [PATCH 6/7] Update manifestgen.sh to pull latest commit to main Signed-off-by: Nicko Guyer --- manifestgen.sh | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/manifestgen.sh b/manifestgen.sh index b90239b0f1..a60e9e6c7b 100755 --- a/manifestgen.sh +++ b/manifestgen.sh @@ -19,6 +19,18 @@ # This script will automatically update the manifest.json file with the # latest releases of all FireFly microservice dependencies +USE_HEAD=false + +# If you pass the string "head" as an argument to this script, it will +# get the latest build, straight off the main branch. Otherwise it will +# get the most recent release that is not a pre-release. +if [[ $# -eq 1 ]] ; then + if [[ $1 -eq "head" ]] ; then + echo 'using head' + USE_HEAD=true + fi +fi + rm -f manifest.json SERVICES=( @@ -36,15 +48,28 @@ do echo " \"${SERVICES[$i]}\": {" >> manifest.json echo " \"image\": \"ghcr.io/hyperledger/firefly-${SERVICES[$i]}\"," >> manifest.json - # Query GitHub API the latest release version - TAG=$(curl https://api.github.com/repos/hyperledger/firefly-${SERVICES[$i]}/releases/latest -s | jq .tag_name -r) + if [ $USE_HEAD = false ] ; then + # Query GitHub API the latest release version + TAG=$(curl https://api.github.com/repos/hyperledger/firefly-${SERVICES[$i]}/releases/latest -s | jq .tag_name -r) + else + # Otherwise, pull the newest built image straight off the main branch + TAG="head" + fi # Attempt to pull the image from GitHub Container Repository docker pull ghcr.io/hyperledger/firefly-${SERVICES[$i]}:$TAG # Get the SHA of the downloaded image SHA=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/hyperledger/firefly-${SERVICES[$i]}:$TAG | cut -d ':' -f 2) + # Get the tag / build number name of this image from its label + TAG_LABEL=$(docker inspect --format='{{index .Config.Labels "tag"}}' ghcr.io/hyperledger/firefly-${SERVICES[$i]}:$TAG) + + # If the tag / build number wasn't set in the label, use whatever docker tag we fetched + # This is done for backwards compatability, because not all images have labels yet + if [ -z "$TAG_LABEL" ]; then + TAG_LABEL=$TAG + fi - echo " \"tag\": \"$TAG\"," >> manifest.json + echo " \"tag\": \"$TAG_LABEL\"," >> manifest.json echo " \"sha\": \"$SHA\"" >> manifest.json if [[ $(($i + 1)) -eq ${SERVICE_COUNT} ]] then From 3b925727167a00e8dc22f3767ff88e970ab07312 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 25 Oct 2021 15:10:28 -0400 Subject: [PATCH 7/7] Remove test branch from main build action Signed-off-by: Nicko Guyer --- .github/workflows/docker_main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml index 6d6849ff8b..a6b87279d7 100644 --- a/.github/workflows/docker_main.yml +++ b/.github/workflows/docker_main.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - actions jobs: docker: