From 5d715136cc46cfc9f8345345d9e727edcb335a9a Mon Sep 17 00:00:00 2001 From: Lazar Travica Date: Thu, 6 Jan 2022 10:21:42 +0100 Subject: [PATCH] GitHub Releases (#316) * Release procedure. * Setting the slack channel for releases. * Update Dockerfile.release Co-authored-by: Victor Castell * Update .goreleaser.yml Co-authored-by: Victor Castell * Update .github/workflows/release.yml Co-authored-by: Victor Castell Co-authored-by: Victor Castell --- .github/workflows/release.yml | 58 +++++++++++++++ .gitignore | 1 + .goreleaser.yml | 128 ++++++++++++++++++++++++++++++++++ Dockerfile.release | 10 +++ 4 files changed, 197 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml create mode 100644 Dockerfile.release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..7ef683e56b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Release + +on: + push: + branches-ignore: + - '**' + tags: + - 'v*.*.*' + # to be used by fork patch-releases ^^ + - 'v*.*.*-*' + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@master + with: + go-version: 1.16.x + + - name: Prepare + id: prepare + run: | + TAG=${GITHUB_REF#refs/tags/} + echo ::set-output name=tag_name::${TAG} + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Run GoReleaser + run: | + docker run \ + --rm \ + --privileged \ + -e CGO_ENABLED=1 \ + -e GITHUB_TOKEN \ + -e DOCKER_USERNAME \ + -e DOCKER_PASSWORD \ + -e SLACK_WEBHOOK \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -w /go/src/$(PACKAGE_NAME) \ + ghcr.io/troian/golang-cross:${GOLANG_CROSS_VERSION} \ + --rm-dist --skip-validate + env: + PACKAGE_NAME: github.com/0xPolygon/polygon-sdk + GOLANG_CROSS_VERSION: v1.17.2 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ steps.prepare.outputs.tag_name }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + if: github.actor == 'lazartravica' diff --git a/.gitignore b/.gitignore index 3b0fd49a66..e887b40cfb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ test-chain* .idea # Exclude the build .exe file from version control +dist/ main.exe main diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000000..27743212a0 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,128 @@ +project_name: polygon-sdk + +release: + disable: false + draft: true + prerelease: auto + +builds: + - id: darwin-amd64 + main: ./main.go + binary: polygon-sdk + goos: + - darwin + goarch: + - amd64 + env: + - CC=o64-clang + - CXX=o64-clang++ + ldflags: + -s -w + + - id: darwin-arm64 + main: ./main.go + binary: polygon-sdk + goos: + - darwin + goarch: + - arm64 + env: + - CC=oa64-clang + - CXX=oa64-clang++ + ldflags: + -s -w + + - id: linux-amd64 + main: ./main.go + binary: polygon-sdk + goos: + - linux + goarch: + - amd64 + env: + - CC=gcc + - CXX=g++ + ldflags: + # We need to build a static binary because we are building in a glibc based system and running in a musl container + -s -w -linkmode external -extldflags "-static" + + - id: linux-arm64 + main: ./main.go + binary: polygon-sdk + goos: + - linux + goarch: + - arm64 + env: + - CC=aarch64-linux-gnu-gcc + - CXX=aarch64-linux-gnu-g++ + ldflags: + # We need to build a static binary because we are building in a glibc based system and running in a musl container + -s -w -linkmode external -extldflags "-static" + +#nfpms: +# - vendor: 0xPolygon +# homepage: https://polygon.technology +# maintainer: Polygon SDK Team +# description: A Framework for Building Ethereum-compatible Blockchain Networks +# license: GPLv3 LGPLv3 +# +# formats: +# - apk +# - deb +# - rpm +# +# contents: +# - src: polygon-sdk.service +# dst: /lib/systemd/system/polygon-sdk.service +# type: config +# +# overrides: +# rpm: +# replacements: +# amd64: x86_64 + +snapshot: + name_template: "{{ .Tag }}.next" + +dockers: + - image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 + dockerfile: Dockerfile.release + use: buildx + goarch: amd64 + ids: + - linux-amd64 + build_flag_templates: + - --platform=linux/amd64 + skip_push: false + + - image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + dockerfile: Dockerfile.release + use: buildx + goarch: arm64 + ids: + - linux-arm64 + build_flag_templates: + - --platform=linux/arm64 + skip_push: false + +docker_manifests: + - name_template: 0xpolygon/{{ .ProjectName }}:{{ .Version }} + image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 + - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + skip_push: false + + - name_template: 0xpolygon/{{ .ProjectName }}:latest + image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 + - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + skip_push: false + +announce: + slack: + enabled: true + # The name of the channel that the user selected as a destination for webhook messages. + channel: "{{ .Env.SLACK_CHANNEL }}" diff --git a/Dockerfile.release b/Dockerfile.release new file mode 100644 index 0000000000..5239db054d --- /dev/null +++ b/Dockerfile.release @@ -0,0 +1,10 @@ +FROM alpine:3.14 + +RUN set -x \ + && apk add --update --no-cache \ + ca-certificates \ + && rm -rf /var/cache/apk/* +COPY polygon-sdk /usr/local/bin/ + +EXPOSE 8545 9632 1478 +ENTRYPOINT ["polygon-sdk"]