From 96800f05b9dcb4e81abac12e1b109cb829009e1f Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 15:12:38 +0300 Subject: [PATCH 01/13] Switch to release binary in ci pipeline --- .github/workflows/node-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 32700f2c7..de040060c 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -59,13 +59,15 @@ jobs: fetch-depth: 0 # FIXME: Starport requires full repository - name: Build - run: starport chain build + run: | + starport chain build --release + tar xzvf release/cheqd-node_linux_amd64.tar.gz - name: Store artifact uses: actions/upload-artifact@v2 with: name: cheqd-noded - path: /home/runner/go/bin/cheqd-noded + path: cheqd-noded build-deb-package: name: Build deb package From 0066887f83f6f66971d1b537327ef7c3a8da0973 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 15:20:33 +0300 Subject: [PATCH 02/13] Merge debug and release docker files into one --- docker/cheqd_node/Dockerfile | 5 ++- docker/cheqd_node/Dockerfile.release | 59 ---------------------------- 2 files changed, 3 insertions(+), 61 deletions(-) delete mode 100644 docker/cheqd_node/Dockerfile.release diff --git a/docker/cheqd_node/Dockerfile b/docker/cheqd_node/Dockerfile index f6bd62ad3..1bd3bba03 100644 --- a/docker/cheqd_node/Dockerfile +++ b/docker/cheqd_node/Dockerfile @@ -29,7 +29,8 @@ COPY go.sum . # Required by starport COPY .git . -RUN starport chain build +RUN starport chain build --release +RUN tar xzvf release/cheqd-node_linux_amd64.tar.gz ##### Run container ##### @@ -37,7 +38,7 @@ RUN starport chain build FROM ubuntu:focal # Node binary -COPY --from=builder /go/bin/cheqd-noded /bin +COPY --from=builder /app/cheqd-noded /bin # Runner script COPY docker/cheqd_node/node-runner.sh /bin/node-runner diff --git a/docker/cheqd_node/Dockerfile.release b/docker/cheqd_node/Dockerfile.release deleted file mode 100644 index 234474682..000000000 --- a/docker/cheqd_node/Dockerfile.release +++ /dev/null @@ -1,59 +0,0 @@ -##### Build container ##### - -FROM golang:buster as builder - -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - # Common - curl \ - # Protoc - protobuf-compiler \ - libprotobuf-dev \ - wget - -# Starport -# RUN curl https://get.starport.network/starport! | bash -# There is an issue with the latest starport, especially 0.18 version -RUN wget -qO- https://github.com/tendermint/starport/releases/download/v0.18.6/starport_0.18.6_linux_amd64.tar.gz | tar xvz -C /tmp/ && cp /tmp/starport /usr/bin - -# App -WORKDIR /app - -ARG STARPORT_RELEASE_PARAMS - -COPY app ./app -COPY cmd ./cmd -COPY proto ./proto -COPY vue ./vue -COPY x ./x -COPY go.mod . -COPY go.sum . -# Required by starport -COPY .git . - -RUN starport chain build $STARPORT_RELEASE_PARAMS - -# It looks ugly cause starport chain build --release creates archive without version. -RUN tar xzvf release/cheqd-node_linux_amd64.tar.gz -##### Run container ##### - -FROM ubuntu:focal - -# Node binary -COPY --from=builder /app/cheqd-noded /bin - -# Runner script -COPY docker/cheqd_node/node-runner.sh /bin/node-runner -RUN chmod +x /bin/node-runner - -RUN groupadd --system --gid 1000 cheqd && \ - useradd --system --create-home --home-dir /cheqd --shell /bin/bash --gid cheqd --uid 1000 cheqd -RUN chown -R cheqd /cheqd - -WORKDIR /cheqd -USER cheqd - -EXPOSE 26656 26657 -STOPSIGNAL SIGTERM - -ENTRYPOINT [ "cheqd-noded" ] From d27879af4399376e6e737635ed110724e35b19e8 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 15:28:15 +0300 Subject: [PATCH 03/13] Reuse build steps from ci pipeline --- .github/workflows/release.yml | 279 +++++++++++++++++++++++----------- 1 file changed, 194 insertions(+), 85 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93cebd2e9..67256a21c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,11 +2,6 @@ name: Release on: push: - paths-ignore: - - '**.md' - - 'docs/**' - - 'architecture/**' - - '.gitbook/**' tags: - "v*" @@ -28,57 +23,10 @@ jobs: echo "::set-output name=GITHUB_REPOSITORY_NAME::$(echo ${GITHUB_REPOSITORY,,})" echo "::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}" - publish-images: - name: "Publish docker images" - # Reference to workflow-setup job is required to access its various outputs. + build-binary: + name: Build binary + runs-on: ubuntu-20.04 needs: setup-workflow - runs-on: ubuntu-latest - env: - GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} - VERSION: ${{ needs.setup-workflow.outputs.VERSION }} - TESTNET_IMAGE_NAME: "cheqd-testnet" - STARPORT_RELEASE_PARAMS: "--release" - steps: - - name: Git checkout - uses: actions/checkout@v2 - - - name: Login to docker - run: | - echo ${{ secrets.GH_PAT }} | docker login ghcr.io --username ${{ secrets.GH_USER }} --password-stdin - - - name: Build node image - run: | - docker build -f docker/cheqd_node/Dockerfile.release \ - --no-cache \ - --build-arg STARPORT_RELEASE_PARAMS=${{ env.STARPORT_RELEASE_PARAMS }} \ - -t cheqd-node . - - name: Build testnet image - run: | - docker build -f docker/single_image_testnet/Dockerfile --no-cache -t cheqd-testnet . - - name: Push node image - run: | - docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} - docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest - docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} - docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest - - name: Push testnet image - run: | - docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} - docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest - docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} - docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest - - publish-release: - name: "Publish release" - needs: [setup-workflow, publish-images] - runs-on: "ubuntu-latest" - env: - GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} - VERSION: ${{ needs.setup-workflow.outputs.VERSION }} - OUTPUT_DIR: "output" - PACKAGE_NAME: "cheqd-node" - RELEASE_TAG: ${{ needs.setup-workflow.outputs.VERSION }} - STARPORT_RELEASE_PARAMS: "--release" steps: - name: Set up Go 1.17 uses: actions/setup-go@v2 @@ -86,56 +34,217 @@ jobs: go-version: 1.17 # There is an issue with the latest starport, especially 0.18 version - - name: Install starport - run: wget -qO- https://github.com/tendermint/starport/releases/download/v0.18.6/starport_0.18.6_linux_amd64.tar.gz \ - | tar xvz -C /tmp/ && sudo cp /tmp/starport /usr/bin + - name: Download and install starport + run: wget -qO- https://github.com/tendermint/starport/releases/download/v0.18.6/starport_0.18.6_linux_amd64.tar.gz | tar xvz -C /tmp/ && sudo cp /tmp/starport /usr/bin - - name: Git checkout - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # FIXME: Starport requires full repository - name: Build - run: starport chain build ${{ env.STARPORT_RELEASE_PARAMS }} + run: | + starport chain build --release + tar xzvf release/cheqd-node_linux_amd64.tar.gz - # It looks ugly cause starport chain build --release creates archive without version. - - name: Untar release - run: tar xzvf release/cheqd-node_linux_amd64.tar.gz && cp cheqd-noded /home/runner/go/bin/ + - name: Store artifact + uses: actions/upload-artifact@v2 + with: + name: cheqd-noded + path: cheqd-noded - - name: Changing version for deb packaging - run: | - echo "VERSION=$(echo ${{ env.VERSION }} | sed 's/v//')" >> $GITHUB_ENV + build-deb-package: + name: Build deb package + runs-on: ubuntu-20.04 + needs: build-binary + steps: + - uses: actions/checkout@v2 + + - name: Load binary artifact + uses: actions/download-artifact@v2 + with: + name: cheqd-noded + path: /home/runner/go/bin + + - name: Restore binary permissions + run: sudo chmod +x /home/runner/go/bin/cheqd-noded - name: Make archive - run: | - ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} working-directory: ./build_tools - - - name: Upload archive - uses: actions/upload-artifact@v2 - with: - name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz - path: build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + run: | + ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential sudo gem install --no-document fpm - - name: Create deb package + - name: Build deb run: | ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} working-directory: ./build_tools - - name: Upload deb + - name: Store deb package artifact uses: actions/upload-artifact@v2 with: name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - path: build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + path: build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + + build-node-image: + name: Build cheqd-node image + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # FIXME: Starport requires full repository + + - name: Build + run: docker build -f docker/cheqd_node/Dockerfile --no-cache -t cheqd-node --build-arg UID=$(id -u) --build-arg GID=$(id -g) . # TODO: Get rid of UID and GID - - uses: "marvinpinto/action-automatic-releases@latest" + - name: Save + run: docker save -o cheqd-node.tar cheqd-node + + - name: Store artifact + uses: actions/upload-artifact@v2 + with: + name: cheqd-node.tar + path: cheqd-node.tar + + build-testnet-image: + name: Build cheqd-testnet image + runs-on: ubuntu-20.04 + needs: build-node-image + steps: + - name: Check out + uses: actions/checkout@v2 + + - name: Download node image + uses: actions/download-artifact@v2 + with: + name: cheqd-node.tar + + - name: Load node image + run: docker load -i cheqd-node.tar + + - name: Build + run: docker build -f docker/single_image_testnet/Dockerfile --no-cache -t cheqd-testnet . + + - name: Save + run: docker save -o cheqd-testnet.tar cheqd-testnet + + - name: Store artifact + uses: actions/upload-artifact@v2 with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "${{ env.RELEASE_TAG }}" - prerelease: false - files: | - build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + name: cheqd-testnet.tar + path: cheqd-testnet.tar + +# publish-images: +# name: "Publish docker images" +# # Reference to workflow-setup job is required to access its various outputs. +# needs: setup-workflow +# runs-on: ubuntu-latest +# env: +# GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} +# VERSION: ${{ needs.setup-workflow.outputs.VERSION }} +# TESTNET_IMAGE_NAME: "cheqd-testnet" +# STARPORT_RELEASE_PARAMS: "--release" +# steps: +# - name: Git checkout +# uses: actions/checkout@v2 +# +# - name: Login to docker +# run: | +# echo ${{ secrets.GH_PAT }} | docker login ghcr.io --username ${{ secrets.GH_USER }} --password-stdin +# +# - name: Build node image +# run: | +# docker build -f docker/cheqd_node/Dockerfile.release \ +# --no-cache \ +# --build-arg STARPORT_RELEASE_PARAMS=${{ env.STARPORT_RELEASE_PARAMS }} \ +# -t cheqd-node . +# - name: Build testnet image +# run: | +# docker build -f docker/single_image_testnet/Dockerfile --no-cache -t cheqd-testnet . +# - name: Push node image +# run: | +# docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} +# docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest +# docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} +# docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest +# - name: Push testnet image +# run: | +# docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} +# docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest +# docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} +# docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest +# +# publish-release: +# name: "Publish release" +# needs: [setup-workflow, publish-images] +# runs-on: "ubuntu-latest" +# env: +# GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} +# VERSION: ${{ needs.setup-workflow.outputs.VERSION }} +# OUTPUT_DIR: "output" +# PACKAGE_NAME: "cheqd-node" +# RELEASE_TAG: ${{ needs.setup-workflow.outputs.VERSION }} +# STARPORT_RELEASE_PARAMS: "--release" +# steps: +# - name: Set up Go 1.17 +# uses: actions/setup-go@v2 +# with: +# go-version: 1.17 +# +# # There is an issue with the latest starport, especially 0.18 version +# - name: Install starport +# run: wget -qO- https://github.com/tendermint/starport/releases/download/v0.18.6/starport_0.18.6_linux_amd64.tar.gz \ +# | tar xvz -C /tmp/ && sudo cp /tmp/starport /usr/bin +# +# - name: Git checkout +# uses: actions/checkout@v2 +# +# - name: Build +# run: starport chain build ${{ env.STARPORT_RELEASE_PARAMS }} +# +# # It looks ugly cause starport chain build --release creates archive without version. +# - name: Untar release +# run: tar xzvf release/cheqd-node_linux_amd64.tar.gz && cp cheqd-noded /home/runner/go/bin/ +# +# - name: Changing version for deb packaging +# run: | +# echo "VERSION=$(echo ${{ env.VERSION }} | sed 's/v//')" >> $GITHUB_ENV +# +# - name: Make archive +# run: | +# ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} +# working-directory: ./build_tools +# +# - name: Upload archive +# uses: actions/upload-artifact@v2 +# with: +# name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz +# path: build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz +# +# - name: Install fpm +# run: | +# sudo apt-get install ruby ruby-dev rubygems build-essential +# sudo gem install --no-document fpm +# +# - name: Create deb package +# run: | +# ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} +# working-directory: ./build_tools +# +# - name: Upload deb +# uses: actions/upload-artifact@v2 +# with: +# name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb +# path: build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb +# +# - uses: "marvinpinto/action-automatic-releases@latest" +# with: +# repo_token: "${{ secrets.GITHUB_TOKEN }}" +# automatic_release_tag: "${{ env.RELEASE_TAG }}" +# prerelease: false +# files: | +# build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb +# build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz From d947ae9c8fc83d31c1fe96004ca0aa66bc9a3a25 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 16:24:11 +0300 Subject: [PATCH 04/13] Move tar build into separate job --- .github/workflows/node-ci.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index de040060c..c1b60c5bc 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -69,7 +69,7 @@ jobs: name: cheqd-noded path: cheqd-noded - build-deb-package: + build-tar-archive: name: Build deb package runs-on: ubuntu-20.04 needs: build-binary @@ -90,6 +90,28 @@ jobs: run: | ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + - name: Store tar artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + path: build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + + build-deb-package: + name: Build deb package + runs-on: ubuntu-20.04 + needs: build-binary + steps: + - uses: actions/checkout@v2 + + - name: Load binary artifact + uses: actions/download-artifact@v2 + with: + name: cheqd-noded + path: /home/runner/go/bin + + - name: Restore binary permissions + run: sudo chmod +x /home/runner/go/bin/cheqd-noded + - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential @@ -97,7 +119,7 @@ jobs: - name: Build deb run: | - ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} working-directory: ./build_tools - name: Store deb package artifact From 3183377324a9f356c92b5ea599e8b38a854c6c6a Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 16:25:14 +0300 Subject: [PATCH 05/13] Fix job name --- .github/workflows/node-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index c1b60c5bc..660040606 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -70,7 +70,7 @@ jobs: path: cheqd-noded build-tar-archive: - name: Build deb package + name: Build tar archive runs-on: ubuntu-20.04 needs: build-binary steps: From 46521232a7dd8f93d8dfffd7b1285400510dba6f Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 16:27:59 +0300 Subject: [PATCH 06/13] Debug release pipeline --- .github/workflows/release.yml | 60 +++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 67256a21c..52ee4aace 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,11 @@ jobs: run: | # Exposes org_name/repository_name in lower case. Required by docker. echo "::set-output name=GITHUB_REPOSITORY_NAME::$(echo ${GITHUB_REPOSITORY,,})" - echo "::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}" + + # Version is tag without `v` prefix. Reuired by deb package. + TAG=${GITHUB_REF/refs\/tags\//} + VERSION=$($echo TAG | sed 's/v//') + echo "::set-output name=VERSION::$VERSION" build-binary: name: Build binary @@ -52,10 +56,13 @@ jobs: name: cheqd-noded path: cheqd-noded - build-deb-package: - name: Build deb package + build-tar-archive: + name: Build tar archive runs-on: ubuntu-20.04 needs: build-binary + env: + PACKAGE_NAME: "cheqd-node" + VERSION: ${{ needs.setup-workflow.outputs.VERSION }} steps: - uses: actions/checkout@v2 @@ -73,6 +80,31 @@ jobs: run: | ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + - name: Store tar artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + path: build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + + build-deb-package: + name: Build deb package + runs-on: ubuntu-20.04 + needs: build-binary + env: + PACKAGE_NAME: "cheqd-node" + VERSION: ${{ needs.setup-workflow.outputs.VERSION }} + steps: + - uses: actions/checkout@v2 + + - name: Load binary artifact + uses: actions/download-artifact@v2 + with: + name: cheqd-noded + path: /home/runner/go/bin + + - name: Restore binary permissions + run: sudo chmod +x /home/runner/go/bin/cheqd-noded + - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential @@ -176,7 +208,7 @@ jobs: # docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest # docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} # docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest -# + # publish-release: # name: "Publish release" # needs: [setup-workflow, publish-images] @@ -187,27 +219,7 @@ jobs: # OUTPUT_DIR: "output" # PACKAGE_NAME: "cheqd-node" # RELEASE_TAG: ${{ needs.setup-workflow.outputs.VERSION }} -# STARPORT_RELEASE_PARAMS: "--release" # steps: -# - name: Set up Go 1.17 -# uses: actions/setup-go@v2 -# with: -# go-version: 1.17 -# -# # There is an issue with the latest starport, especially 0.18 version -# - name: Install starport -# run: wget -qO- https://github.com/tendermint/starport/releases/download/v0.18.6/starport_0.18.6_linux_amd64.tar.gz \ -# | tar xvz -C /tmp/ && sudo cp /tmp/starport /usr/bin -# -# - name: Git checkout -# uses: actions/checkout@v2 -# -# - name: Build -# run: starport chain build ${{ env.STARPORT_RELEASE_PARAMS }} -# -# # It looks ugly cause starport chain build --release creates archive without version. -# - name: Untar release -# run: tar xzvf release/cheqd-node_linux_amd64.tar.gz && cp cheqd-noded /home/runner/go/bin/ # # - name: Changing version for deb packaging # run: | From c7f0efa1a62b2613d564d1199250e75efb09baa4 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 16:31:05 +0300 Subject: [PATCH 07/13] Debug workflows --- .github/workflows/node-ci.yml | 22 +++------------------- .github/workflows/release.yml | 25 +++---------------------- 2 files changed, 6 insertions(+), 41 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 660040606..48202918c 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -69,8 +69,8 @@ jobs: name: cheqd-noded path: cheqd-noded - build-tar-archive: - name: Build tar archive + build-deb-package: + name: Build deb package runs-on: ubuntu-20.04 needs: build-binary steps: @@ -96,28 +96,12 @@ jobs: name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz path: build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz - build-deb-package: - name: Build deb package - runs-on: ubuntu-20.04 - needs: build-binary - steps: - - uses: actions/checkout@v2 - - - name: Load binary artifact - uses: actions/download-artifact@v2 - with: - name: cheqd-noded - path: /home/runner/go/bin - - - name: Restore binary permissions - run: sudo chmod +x /home/runner/go/bin/cheqd-noded - - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential sudo gem install --no-document fpm - - name: Build deb + - name: Build deb # Depends on tar archive run: | ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} working-directory: ./build_tools diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52ee4aace..467d13a87 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,8 +56,8 @@ jobs: name: cheqd-noded path: cheqd-noded - build-tar-archive: - name: Build tar archive + build-deb-package: + name: Build deb package runs-on: ubuntu-20.04 needs: build-binary env: @@ -86,31 +86,12 @@ jobs: name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz path: build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz - build-deb-package: - name: Build deb package - runs-on: ubuntu-20.04 - needs: build-binary - env: - PACKAGE_NAME: "cheqd-node" - VERSION: ${{ needs.setup-workflow.outputs.VERSION }} - steps: - - uses: actions/checkout@v2 - - - name: Load binary artifact - uses: actions/download-artifact@v2 - with: - name: cheqd-noded - path: /home/runner/go/bin - - - name: Restore binary permissions - run: sudo chmod +x /home/runner/go/bin/cheqd-noded - - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential sudo gem install --no-document fpm - - name: Build deb + - name: Build deb # Depends on tar archive run: | ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} working-directory: ./build_tools From 48208d276daff5e5eaff508706866e8b4bccaa31 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 16:33:31 +0300 Subject: [PATCH 08/13] Fix release pipeline --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 467d13a87..2ded158c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: # Version is tag without `v` prefix. Reuired by deb package. TAG=${GITHUB_REF/refs\/tags\//} - VERSION=$($echo TAG | sed 's/v//') + VERSION="${TAG:1}" # Remove first character echo "::set-output name=VERSION::$VERSION" build-binary: From f026855e0b1bb994313a55d7195fff87a82412ac Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 16:39:47 +0300 Subject: [PATCH 09/13] Debug release pipeline --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ded158c4..db967f01a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,6 @@ jobs: build-binary: name: Build binary runs-on: ubuntu-20.04 - needs: setup-workflow steps: - name: Set up Go 1.17 uses: actions/setup-go@v2 @@ -59,7 +58,7 @@ jobs: build-deb-package: name: Build deb package runs-on: ubuntu-20.04 - needs: build-binary + needs: [build-binary, setup-workflow] env: PACKAGE_NAME: "cheqd-node" VERSION: ${{ needs.setup-workflow.outputs.VERSION }} From c7419afa098d016b54b4b6b1b93bb96b50c3f7c5 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 17:28:09 +0300 Subject: [PATCH 10/13] Debug pipelines --- .github/workflows/node-ci.yml | 40 +++---- .github/workflows/release.yml | 195 +++++++++++++++------------------- 2 files changed, 104 insertions(+), 131 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 48202918c..3bbb043e5 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -85,17 +85,11 @@ jobs: - name: Restore binary permissions run: sudo chmod +x /home/runner/go/bin/cheqd-noded - - name: Make archive + - name: Make intermediate archive working-directory: ./build_tools run: | ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} - - name: Store tar artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz - path: build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz - - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential @@ -124,13 +118,13 @@ jobs: run: docker build -f docker/cheqd_node/Dockerfile --no-cache -t cheqd-node --build-arg UID=$(id -u) --build-arg GID=$(id -g) . # TODO: Get rid of UID and GID - name: Save - run: docker save -o cheqd-node.tar cheqd-node + run: docker save -o cheqd-node-image.tar cheqd-node - name: Store artifact uses: actions/upload-artifact@v2 with: - name: cheqd-node.tar - path: cheqd-node.tar + name: cheqd-node-image.tar + path: cheqd-node-image.tar build-testnet-image: name: Build cheqd-testnet image @@ -143,22 +137,22 @@ jobs: - name: Download node image uses: actions/download-artifact@v2 with: - name: cheqd-node.tar + name: cheqd-node-image.tar - name: Load node image - run: docker load -i cheqd-node.tar + run: docker load -i cheqd-node-image.tar - name: Build run: docker build -f docker/single_image_testnet/Dockerfile --no-cache -t cheqd-testnet . - name: Save - run: docker save -o cheqd-testnet.tar cheqd-testnet + run: docker save -o cheqd-testnet-image.tar cheqd-testnet - name: Store artifact uses: actions/upload-artifact@v2 with: - name: cheqd-testnet.tar - path: cheqd-testnet.tar + name: cheqd-testnet-image.tar + path: cheqd-testnet-image.tar test-new-node-setup-from-deb: name: Test new node setup from deb @@ -176,10 +170,10 @@ jobs: - name: Download node image uses: actions/download-artifact@v2 with: - name: cheqd-node.tar + name: cheqd-node-image.tar - name: Load node image - run: docker load -i cheqd-node.tar + run: docker load -i cheqd-node-image.tar - name: Check out uses: actions/checkout@v2 @@ -233,10 +227,10 @@ jobs: - name: Download node image uses: actions/download-artifact@v2 with: - name: cheqd-node.tar + name: cheqd-node-image.tar - name: Load node image - run: docker load -i cheqd-node.tar + run: docker load -i cheqd-node-image.tar - uses: actions/checkout@v2 @@ -271,10 +265,10 @@ jobs: - name: Download testnet image uses: actions/download-artifact@v2 with: - name: cheqd-testnet.tar + name: cheqd-testnet-image.tar - name: Load testnet image - run: docker load -i cheqd-testnet.tar + run: docker load -i cheqd-testnet-image.tar - name: Run test net container run: | @@ -313,10 +307,10 @@ jobs: - name: Download testnet image uses: actions/download-artifact@v2 with: - name: cheqd-testnet.tar + name: cheqd-testnet-image.tar - name: Load testnet image - run: docker load -i cheqd-testnet.tar + run: docker load -i cheqd-testnet-image.tar - name: Run test net container run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index db967f01a..9efde0b97 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest outputs: GITHUB_REPOSITORY_NAME: ${{ steps.cache.outputs.GITHUB_REPOSITORY_NAME }} + TAG: ${{ steps.cache.outputs.TAG }} VERSION: ${{ steps.cache.outputs.VERSION }} steps: - name: Git checkout @@ -24,6 +25,8 @@ jobs: # Version is tag without `v` prefix. Reuired by deb package. TAG=${GITHUB_REF/refs\/tags\//} + echo "::set-output name=TAG::$TAG" + VERSION="${TAG:1}" # Remove first character echo "::set-output name=VERSION::$VERSION" @@ -58,7 +61,7 @@ jobs: build-deb-package: name: Build deb package runs-on: ubuntu-20.04 - needs: [build-binary, setup-workflow] + needs: [ build-binary, setup-workflow ] env: PACKAGE_NAME: "cheqd-node" VERSION: ${{ needs.setup-workflow.outputs.VERSION }} @@ -74,17 +77,11 @@ jobs: - name: Restore binary permissions run: sudo chmod +x /home/runner/go/bin/cheqd-noded - - name: Make archive + - name: Make intermediate archive working-directory: ./build_tools run: | ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} - - name: Store tar artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz - path: build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz - - name: Install fpm run: | sudo apt-get install ruby ruby-dev rubygems build-essential @@ -113,13 +110,13 @@ jobs: run: docker build -f docker/cheqd_node/Dockerfile --no-cache -t cheqd-node --build-arg UID=$(id -u) --build-arg GID=$(id -g) . # TODO: Get rid of UID and GID - name: Save - run: docker save -o cheqd-node.tar cheqd-node + run: docker save -o cheqd-node-image.tar cheqd-node - name: Store artifact uses: actions/upload-artifact@v2 with: - name: cheqd-node.tar - path: cheqd-node.tar + name: cheqd-node-image.tar + path: cheqd-node-image.tar build-testnet-image: name: Build cheqd-testnet image @@ -132,111 +129,93 @@ jobs: - name: Download node image uses: actions/download-artifact@v2 with: - name: cheqd-node.tar + name: cheqd-node-image.tar - name: Load node image - run: docker load -i cheqd-node.tar + run: docker load -i cheqd-node-image.tar - name: Build run: docker build -f docker/single_image_testnet/Dockerfile --no-cache -t cheqd-testnet . - name: Save - run: docker save -o cheqd-testnet.tar cheqd-testnet + run: docker save -o cheqd-testnet-image.tar cheqd-testnet - name: Store artifact uses: actions/upload-artifact@v2 with: - name: cheqd-testnet.tar - path: cheqd-testnet.tar - -# publish-images: -# name: "Publish docker images" -# # Reference to workflow-setup job is required to access its various outputs. -# needs: setup-workflow -# runs-on: ubuntu-latest -# env: -# GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} -# VERSION: ${{ needs.setup-workflow.outputs.VERSION }} -# TESTNET_IMAGE_NAME: "cheqd-testnet" -# STARPORT_RELEASE_PARAMS: "--release" -# steps: -# - name: Git checkout -# uses: actions/checkout@v2 -# -# - name: Login to docker -# run: | -# echo ${{ secrets.GH_PAT }} | docker login ghcr.io --username ${{ secrets.GH_USER }} --password-stdin -# -# - name: Build node image -# run: | -# docker build -f docker/cheqd_node/Dockerfile.release \ -# --no-cache \ -# --build-arg STARPORT_RELEASE_PARAMS=${{ env.STARPORT_RELEASE_PARAMS }} \ -# -t cheqd-node . -# - name: Build testnet image -# run: | -# docker build -f docker/single_image_testnet/Dockerfile --no-cache -t cheqd-testnet . -# - name: Push node image -# run: | -# docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} -# docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest -# docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} -# docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest -# - name: Push testnet image -# run: | -# docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} -# docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest -# docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} -# docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest - -# publish-release: -# name: "Publish release" -# needs: [setup-workflow, publish-images] -# runs-on: "ubuntu-latest" -# env: -# GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} -# VERSION: ${{ needs.setup-workflow.outputs.VERSION }} -# OUTPUT_DIR: "output" -# PACKAGE_NAME: "cheqd-node" -# RELEASE_TAG: ${{ needs.setup-workflow.outputs.VERSION }} -# steps: -# -# - name: Changing version for deb packaging -# run: | -# echo "VERSION=$(echo ${{ env.VERSION }} | sed 's/v//')" >> $GITHUB_ENV -# -# - name: Make archive -# run: | -# ./build_tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} -# working-directory: ./build_tools -# -# - name: Upload archive -# uses: actions/upload-artifact@v2 -# with: -# name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz -# path: build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz -# -# - name: Install fpm -# run: | -# sudo apt-get install ruby ruby-dev rubygems build-essential -# sudo gem install --no-document fpm -# -# - name: Create deb package -# run: | -# ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} -# working-directory: ./build_tools -# -# - name: Upload deb -# uses: actions/upload-artifact@v2 -# with: -# name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb -# path: build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb -# -# - uses: "marvinpinto/action-automatic-releases@latest" -# with: -# repo_token: "${{ secrets.GITHUB_TOKEN }}" -# automatic_release_tag: "${{ env.RELEASE_TAG }}" -# prerelease: false -# files: | -# build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb -# build_tools/${{ env.OUTPUT_DIR }}/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + name: cheqd-testnet-image.tar + path: cheqd-testnet-image.tar + + publish: + name: "Publish docker images" + # Reference to workflow-setup job is required to access its various outputs. + needs: [ setup-workflow, build-node-image, build-testnet-image, build-deb-package ] + runs-on: ubuntu-latest + env: + GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }} + TAG: ${{ needs.setup-workflow.outputs.TAG }} + VERSION: ${{ needs.setup-workflow.outputs.VERSION }} + PACKAGE_NAME: "cheqd-node" + TESTNET_IMAGE_NAME: "cheqd-testnet" + steps: + - name: Git checkout + uses: actions/checkout@v2 + + - name: Download node image + uses: actions/download-artifact@v2 + with: + name: cheqd-node-image.tar + + - name: Load node image + run: docker load -i cheqd-node-image.tar + + - name: Download testnet image + uses: actions/download-artifact@v2 + with: + name: cheqd-testnet-image.tar + + - name: Load testnet image + run: docker load -i cheqd-testnet-image.tar + + - name: Login to docker + run: | + echo ${{ secrets.GH_PAT }} | docker login ghcr.io --username ${{ secrets.GH_USER }} --password-stdin + + - name: Push node image + run: | + docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} + docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest + docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }} + docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest + + - name: Push testnet image + run: | + docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} + docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest + docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }} + docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest + + - name: Download deb + uses: actions/download-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + + - name: Load binary artifact + uses: actions/download-artifact@v2 + with: + name: cheqd-noded + + - name: Restore binary permissions + run: sudo chmod +x cheqd-noded + + - name: Make tar archive + run: tar -zcvf ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz cheqd-noded + + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "${{ env.TAG }}" + prerelease: true + files: | + build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz From dc91efe8369a540e3eea53785a716a1dbf0ef940 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 17:34:57 +0300 Subject: [PATCH 11/13] Debug --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9efde0b97..4d70d866f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -216,6 +216,6 @@ jobs: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "${{ env.TAG }}" prerelease: true - files: | - build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + files: | + build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz From a67c4d138301531c4c459ced6b060304b6458739 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 17:39:15 +0300 Subject: [PATCH 12/13] Fix job name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4d70d866f..2570b454f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -147,7 +147,7 @@ jobs: path: cheqd-testnet-image.tar publish: - name: "Publish docker images" + name: "Publish images and release" # Reference to workflow-setup job is required to access its various outputs. needs: [ setup-workflow, build-node-image, build-testnet-image, build-deb-package ] runs-on: ubuntu-latest From 92d8e713417039d09abeef77aeed25f86eb2e818 Mon Sep 17 00:00:00 2001 From: Alexandr Kolesov Date: Tue, 7 Dec 2021 17:44:15 +0300 Subject: [PATCH 13/13] Fix artifacts uploading --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2570b454f..98f1a3af2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -217,5 +217,5 @@ jobs: automatic_release_tag: "${{ env.TAG }}" prerelease: true files: | - build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - build_tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz + ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz