diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 32700f2c7..3bbb043e5 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 @@ -83,7 +85,7 @@ 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 }} @@ -93,9 +95,9 @@ jobs: 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 }} + ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} working-directory: ./build_tools - name: Store deb package artifact @@ -116,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 @@ -135,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 @@ -168,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 @@ -225,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 @@ -263,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: | @@ -305,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 93cebd2e9..98f1a3af2 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*" @@ -16,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 @@ -26,41 +22,172 @@ 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\//}" - publish-images: - name: "Publish docker images" + # 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" + + build-binary: + name: Build binary + runs-on: ubuntu-20.04 + 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: 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 + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # FIXME: Starport requires full repository + + - name: 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: cheqd-noded + + build-deb-package: + name: Build deb package + runs-on: ubuntu-20.04 + needs: [ build-binary, setup-workflow ] + 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: Make intermediate archive + working-directory: ./build_tools + 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: Build deb # Depends on tar archive + run: | + ./build_deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }} + working-directory: ./build_tools + + - name: Store deb package artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ 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 + + - name: Save + run: docker save -o cheqd-node-image.tar cheqd-node + + - name: Store artifact + uses: actions/upload-artifact@v2 + with: + name: cheqd-node-image.tar + path: cheqd-node-image.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-image.tar + + - name: Load node image + 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-image.tar cheqd-testnet + + - name: Store artifact + uses: actions/upload-artifact@v2 + with: + name: cheqd-testnet-image.tar + path: cheqd-testnet-image.tar + + publish: + name: "Publish images and release" # Reference to workflow-setup job is required to access its various outputs. - needs: setup-workflow + 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" - STARPORT_RELEASE_PARAMS: "--release" 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: 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 }} @@ -68,74 +195,27 @@ jobs: 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 + - name: Download deb + uses: actions/download-artifact@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: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb - - name: Upload archive - uses: actions/upload-artifact@v2 + - name: Load binary artifact + uses: actions/download-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: cheqd-noded - - name: Install fpm - run: | - sudo apt-get install ruby ruby-dev rubygems build-essential - sudo gem install --no-document fpm + - name: Restore binary permissions + run: sudo chmod +x cheqd-noded - - 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 + - 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.RELEASE_TAG }}" - prerelease: false + automatic_release_tag: "${{ env.TAG }}" + prerelease: true 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 + ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb + ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz 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" ]