From 21f30e8988bc2321735399cb7ef7eb1f0dfbaf99 Mon Sep 17 00:00:00 2001 From: Jaime Pillora Date: Tue, 11 Jan 2022 23:41:28 +0000 Subject: [PATCH] auto release binaries --- .github/goreleaser.yml | 32 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/goreleaser.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml new file mode 100644 index 0000000..d4157b8 --- /dev/null +++ b/.github/goreleaser.yml @@ -0,0 +1,32 @@ +# test this file with +# goreleaser --skip-publish --rm-dist --config .github/goreleaser.yml +builds: + - main: . + env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X main.version={{.Version}} + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm + - arm64 + - 386 + goarm: + - 6 + - 7 +archives: + - format: gz + files: + - none* +release: + prerelease: auto +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eb0f9ab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +on: [push, pull_request] +name: CI +jobs: + # ================ + # TEST JOB + # runs on every push and PR + # runs 2x3 times (see matrix) + # ================ + test: + name: Test + strategy: + matrix: + go-version: [1.16.x, 1.17.x] + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Build + run: go build -v . + - name: Test + run: go test -v ./... + # ================ + # RELEASE JOB + # runs after a success test + # only runs on push "v*" tag + # ================ + release: + name: Release + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: goreleaser + if: success() + uses: docker://goreleaser/goreleaser:latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: release --config .github/goreleaser.yml