From 05dea8beb85e175349c26ee9765a693141b285b2 Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Fri, 20 May 2022 16:13:46 +0300 Subject: [PATCH] Add goreleaser and docker publishing Signed-off-by: Andrew Nikitin --- .github/workflows/build.yml | 11 +++++- .github/workflows/dispatch.yml | 23 +++++++++---- .github/workflows/release.yml | 61 ++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f7715c4..ee99031c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,4 +26,13 @@ jobs: - name: Check docker building working-directory: . - run: docker build -f docker/Dockerfile . + run: docker build -f docker/Dockerfile -t cheqd-did-resolver . + + - name: Save cheqd-did-resolver Docker image + run: docker save -o cheqd-did-resolver.tar cheqd-did-resolver + + - name: Store cheqd-did-resolver artifact + uses: actions/upload-artifact@v3 + with: + name: cheqd-did-resolver.tar + path: cheqd-did-resolver.tar diff --git a/.github/workflows/dispatch.yml b/.github/workflows/dispatch.yml index 11a0c525..50322975 100644 --- a/.github/workflows/dispatch.yml +++ b/.github/workflows/dispatch.yml @@ -7,16 +7,25 @@ concurrency: jobs: - call-lint: - name: "Lint" - uses: ./.github/workflows/lint.yml - +# call-lint: +# name: "Lint" +# uses: ./.github/workflows/lint.yml +# call-build: name: "Build" needs: call-lint uses: ./.github/workflows/build.yml +# +# call-test: +# name: "Tests" +# needs: call-build +# uses: ./.github/workflows/test.yml - call-test: - name: "Tests" + call-release: + name: "Release" +# needs: [call-test, call-build] needs: call-build - uses: ./.github/workflows/test.yml + if: startsWith(github.ref, 'refs/tags/v') + uses: ./.github/workflows/release.yml + with: + RELEASE_VERSION: 1.0.0 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..974298ed --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: "Release" +on: + workflow_call: + inputs: + RELEASE_VERSION: + description: "Release version number" + required: true + type: string +defaults: + run: + shell: bash + + +jobs: + go-releaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-docker: + name: "Publish Docker images" + runs-on: ubuntu-latest + env: + RELEASE_VERSION: ${{ inputs.VERSION }} + + steps: + - name: Download resolver Docker image + uses: actions/download-artifact@v3 + with: + name: cheqd-did-resolver.tar + + - name: Load resolver Docker image + run: docker load -i cheqd-did-resolver.tar + + - name: Login to Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push cheqd-node image + run: | + docker tag cheqd-did-resolver ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }} + docker tag cheqd-did-resolver ghcr.io/${{ github.repository }}:latest + docker push ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }} + docker push ghcr.io/${{ github.repository }}:latest \ No newline at end of file