From 47e6ba642a32e9fd9de0c345e85a25f24ec6d131 Mon Sep 17 00:00:00 2001 From: Johan Siebens Date: Mon, 14 Feb 2022 15:35:44 +0100 Subject: [PATCH] chore: use goreleaser --- .github/workflows/ci-only.yaml | 4 +-- .github/workflows/release.yaml | 35 +++++++++++------- .goreleaser.yaml | 65 ++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/ci-only.yaml b/.github/workflows/ci-only.yaml index 989808d..ae6b852 100644 --- a/.github/workflows/ci-only.yaml +++ b/.github/workflows/ci-only.yaml @@ -2,7 +2,7 @@ name: ci-only on: push: - branches: [ master ] + branches: [ '*' ] pull_request: branches: [ master ] @@ -25,4 +25,4 @@ jobs: restore-keys: | ${{ runner.os }}-go- - - run: make dist + - run: go build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3d2c401..6f2715a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,25 +1,36 @@ name: release on: - release: - types: [ created ] + push: + tags: + - '*' + +permissions: + contents: write + packages: write + id-token: write jobs: - build: + release: runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v2 + - name: Checkout + uses: actions/checkout@v2 with: - go-version: ^1.16 + fetch-depth: 0 - - uses: actions/checkout@v2.3.4 + - name: Set up Go + uses: actions/setup-go@v2 with: - fetch-depth: 1 + go-version: ^1.16 - - run: make dist hash + - name: Install cosign + uses: sigstore/cosign-installer@v2.0.0 - - uses: skx/github-action-publish-binaries@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 with: - args: "./dist/*" + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..697b120 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,65 @@ +project_name: hashi-up + +before: + hooks: + - go mod tidy + +builds: + - id: default + env: [ CGO_ENABLED=0 ] + goos: + - linux + - windows + goarch: + - amd64 + ldflags: + - -s -w -X github.com/jsiebens/hashi-up/cmd.Version={{.Version}} -X github.com/jsiebens/hashi-up/cmd.GitCommit={{.ShortCommit}} + - id: arm + env: [ CGO_ENABLED=0 ] + goos: + - linux + goarch: + - arm64 + - arm + ldflags: + - -s -w -X github.com/jsiebens/hashi-up/cmd.Version={{.Version}} -X github.com/jsiebens/hashi-up/cmd.GitCommit={{.ShortCommit}} + - id: darwin + env: [ CGO_ENABLED=0 ] + goos: + - darwin + goarch: + - amd64 + ldflags: + - -s -w -X github.com/jsiebens/hashi-up/cmd.Version={{.Version}} -X github.com/jsiebens/hashi-up/cmd.GitCommit={{.ShortCommit}} + +archives: + - id: default + builds: + - default + format: binary + name_template: "{{ .ProjectName }}" + - id: darwin + builds: + - darwin + format: binary + name_template: "{{ .ProjectName }}-{{ .Os }}" + - id: arm + builds: + - arm + format: binary + name_template: "{{ .ProjectName }}-{{ .Arch }}{{ if .Arm }}hf{{ end }}" + +checksum: + name_template: "checksums.txt" + +signs: + - cmd: cosign + env: + - COSIGN_EXPERIMENTAL=1 + certificate: '${artifact}.pem' + args: + - sign-blob + - '--output-certificate=${certificate}' + - '--output-signature=${signature}' + - '${artifact}' + artifacts: checksum \ No newline at end of file