From e2efe30056eebb313f4818c6bd55ddafea1092a2 Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 19:47:26 +0300 Subject: [PATCH 01/12] Add golangci-lint step to go workflow --- .github/workflows/go.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2502756..3de9ec0 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,15 +14,20 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.21.3' + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.3' - - name: Build - run: CGO_ENABLED=0 go build -v -o conflictless cmd/conflictless/main.go + - name: Build + run: CGO_ENABLED=0 go build -v -o conflictless cmd/conflictless/main.go - - name: Test - run: touch c.out && go test -v ./... -coverprofile=c.out && go tool cover -func=c.out + - name: Test + run: touch c.out && go test -v ./... -coverprofile=c.out && go tool cover -func=c.out + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54.1 From a0cd7af55933653a994ba800181ba8353d78298f Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 19:53:12 +0300 Subject: [PATCH 02/12] Run go workflow on push to any branch --- .github/workflows/go.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3de9ec0..25f07ea 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -3,11 +3,7 @@ name: Go -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] +on: push jobs: From 81c5380edd6d1edcdd7332906d81272414f42804 Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:09:25 +0300 Subject: [PATCH 03/12] Add cobertura coverage report to test --- .github/workflows/go.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 25f07ea..9d22968 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -17,11 +17,20 @@ jobs: with: go-version: '1.21.3' + - name: Install dependencies + run: | + go get . + go install github.com/t-yuki/gocover-cobertura@latest + - name: Build run: CGO_ENABLED=0 go build -v -o conflictless cmd/conflictless/main.go - name: Test - run: touch c.out && go test -v ./... -coverprofile=c.out && go tool cover -func=c.out + run: >- + touch c.out + && go test -v ./... -coverprofile=c.out + && go tool cover -func=c.out + && gocover-cobertura < c.out > coverage.xml - name: golangci-lint uses: golangci/golangci-lint-action@v3 From 9fe93754f4328682ca669b6ef03679f2c6982691 Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:29:35 +0300 Subject: [PATCH 04/12] Use another coverage tool --- .github/workflows/go.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9d22968..d67a90f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -20,17 +20,14 @@ jobs: - name: Install dependencies run: | go get . - go install github.com/t-yuki/gocover-cobertura@latest + go install github.com/axw/gocov/gocov@latest + go install github.com/AlekSi/gocov-xml@latest - name: Build run: CGO_ENABLED=0 go build -v -o conflictless cmd/conflictless/main.go - name: Test - run: >- - touch c.out - && go test -v ./... -coverprofile=c.out - && go tool cover -func=c.out - && gocover-cobertura < c.out > coverage.xml + run: gocov test ./... | gocov-xml > coverage.xml - name: golangci-lint uses: golangci/golangci-lint-action@v3 From 6f90c7839dda9d4001eda163b3000b69c64e06c9 Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:31:14 +0300 Subject: [PATCH 05/12] Only install coverage tools --- .github/workflows/go.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d67a90f..953b192 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -17,9 +17,8 @@ jobs: with: go-version: '1.21.3' - - name: Install dependencies + - name: Install coverage tools run: | - go get . go install github.com/axw/gocov/gocov@latest go install github.com/AlekSi/gocov-xml@latest From f2e8e541ee8050754d57d01c88d0956b7d7958c9 Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:43:02 +0300 Subject: [PATCH 06/12] Upload coverage report to Codecov --- .github/workflows/go.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 953b192..a200200 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -28,6 +28,12 @@ jobs: - name: Test run: gocov test ./... | gocov-xml > coverage.xml + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: From a274712385a08dc67dc6a7ed762bc13f913c4a8d Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:50:27 +0300 Subject: [PATCH 07/12] Add goreleaser config --- .goreleaser.yaml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .goreleaser.yaml diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..50862b6 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,48 @@ +--- +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +before: + hooks: + - go mod tidy + +builds: + - id: conflictless + binary: conflictless + main: cmd/conflictless/main.go + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +upx: + - ids: + - conflictless + enabled: true + compress: best + lzma: true + goos: + - darwin + - linux + brute: true + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + conflictless_ + {{- .Version }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + skip: true From 3ce6f69fed006d3772dafaed88b73a467f77b701 Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:22:12 +0300 Subject: [PATCH 08/12] Add json schema hint --- .github/workflows/go.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a200200..01e5897 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,5 +1,5 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Go @@ -28,7 +28,7 @@ jobs: - name: Test run: gocov test ./... | gocov-xml > coverage.xml - - name: Upload coverage reports to Codecov + - name: Upload coverage report to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} From 8c67960106ec8251b89400d9778b8e9db20c818a Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:22:39 +0300 Subject: [PATCH 09/12] Update .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 3b735ec..eea1cb3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,9 @@ # Go workspace file go.work + +# Test coverage. +coverage.xml + +# Gorelease output +dist/ From 1fe3bba3dfeb5314fdb6accf850d0c863029bd2a Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:24:08 +0300 Subject: [PATCH 10/12] Rename goreleaser config --- .goreleaser.yaml => .goreleaser.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) rename .goreleaser.yaml => .goreleaser.yml (82%) diff --git a/.goreleaser.yaml b/.goreleaser.yml similarity index 82% rename from .goreleaser.yaml rename to .goreleaser.yml index 50862b6..a10a999 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yml @@ -26,7 +26,6 @@ upx: goos: - darwin - linux - brute: true archives: - format: tar.gz @@ -46,3 +45,14 @@ archives: changelog: skip: true + +signs: + - artifacts: checksum + args: + - "--batch" + - "-u" + - "{{ .Env.GPG_FINGERPRINT }}" + - "--output" + - "${signature}" + - "--detach-sign" + - "${artifact}" From 91ab857b7d621f4dd24fb7bb6dc4c8816c0c63ae Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:24:55 +0300 Subject: [PATCH 11/12] Add goreleaser workflow --- .github/workflows/goreleaser.yml | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/goreleaser.yml diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..04f2ba4 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,43 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: goreleaser + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.3' + + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} From e9f7bfab5344aa36c88b9fc6d71fca5404e977d1 Mon Sep 17 00:00:00 2001 From: ypjama <3822534+ypjama@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:25:17 +0300 Subject: [PATCH 12/12] Write changes --- changes/go-releaser.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changes/go-releaser.yml diff --git a/changes/go-releaser.yml b/changes/go-releaser.yml new file mode 100644 index 0000000..a36a175 --- /dev/null +++ b/changes/go-releaser.yml @@ -0,0 +1,6 @@ +--- +added: + - Automatic release building with goreleaser + - Golangci-lint step to go workflow + - Codecov step to go workflow +