From be1985176b1a01bf7700a28acb870a22f775e658 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 9 Jan 2025 10:03:15 -0300 Subject: [PATCH] ci: update configs --- .github/dependabot.yml | 4 +- .github/workflows/build.yml | 47 +++++++++++--------- .github/workflows/release.yml | 23 ++++++++++ .goreleaser.yml | 81 ++++++++++++++++++----------------- Makefile | 6 +-- 5 files changed, 93 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 022e304..3c8156f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,7 +8,7 @@ updates: labels: - "dependencies" commit-message: - prefix: "feat" + prefix: "chore" include: "scope" - package-ecosystem: "github-actions" directory: "/" @@ -28,5 +28,5 @@ updates: labels: - "dependencies" commit-message: - prefix: "feat" + prefix: "chore" include: "scope" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e457735..358c24e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,39 +4,44 @@ on: push: branches: - "main" - tags: - - "v*" pull_request: jobs: - windowsTest: - runs-on: windows-latest + build: + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 - uses: actions/setup-go@v5 with: go-version: "stable" - - run: go test -v -race -count=1 ./... - goreleaser: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-go@v5 + - uses: goreleaser/goreleaser-action@v6 with: - go-version: "stable" - - run: make ci + install-only: true + - run: goreleaser build --snapshot --clean --snapshot + - run: go test -v -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.out ./... -timeout=5m - uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.out - - uses: goreleaser/goreleaser-action@v6 - if: success() && startsWith(github.ref, 'refs/tags/') + dependabot: + needs: [build] + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}} + steps: + - id: metadata + uses: dependabot/fetch-metadata@v2 with: - version: latest - args: release --clean + github-token: "${{ secrets.GITHUB_TOKEN }}" + - run: | + gh pr review --approve "$PR_URL" + gh pr merge --squash --auto "$PR_URL" env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d8ef312 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: releaese + +on: + push: + tags: + - "v*" + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: "stable" + - uses: goreleaser/goreleaser-action@v6 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 11802b0..3a9f5a8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,50 +1,52 @@ +version: 2 + before: hooks: - - go mod tidy + - go mod tidy gomod: proxy: true builds: -- main: ./cmd/chglog - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - - windows - goarch: - - amd64 - - arm64 - mod_timestamp: '{{ .CommitTimestamp }}' - flags: - - -trimpath - ldflags: - - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser + - main: ./cmd/chglog + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser changelog: sort: asc use: github filters: exclude: - - '^test:' - - '^chore' - - 'merge conflict' - - Merge pull request - - Merge remote-tracking branch - - Merge branch - - go mod tidy + - "^test:" + - "^chore" + - "merge conflict" + - Merge pull request + - Merge remote-tracking branch + - Merge branch + - go mod tidy groups: - title: Dependency updates regexp: "^.*feat\\(deps\\)*:+.*$" order: 300 - - title: 'New Features' + - title: "New Features" regexp: "^.*feat[(\\w)]*:+.*$" order: 100 - - title: 'Bug fixes' + - title: "Bug fixes" regexp: "^.*fix[(\\w)]*:+.*$" order: 200 - - title: 'Documentation updates' + - title: "Documentation updates" regexp: "^.*docs[(\\w)]*:+.*$" order: 400 - title: Other work @@ -59,17 +61,17 @@ archives: {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} brews: - - tap: + - repository: owner: goreleaser name: homebrew-tap - folder: Formula - homepage: https://github.com/goreleaser/chglog + directory: Formula + homepage: https://github.com/goreleaser/chglog description: chglog is a changelog management library and tool test: | system "#{bin}/chglog version" nfpms: - - file_name_template: '{{ .ProjectName }}_{{ .Arch }}' - homepage: https://github.com/goreleaser/chglog + - file_name_template: "{{ .ProjectName }}_{{ .Arch }}" + homepage: https://github.com/goreleaser/chglog description: chglog is a changelog management library and tool maintainer: Dj Gilcrease license: MIT @@ -77,15 +79,14 @@ nfpms: formats: - deb - rpm -scoop: - bucket: - owner: goreleaser - name: scoop-bucket - homepage: https://goreleaser.com - folder: bucket - description: Deliver Go binaries as fast and easily as possible - license: MIT - +scoops: + - repository: + owner: goreleaser + name: scoop-bucket + homepage: https://goreleaser.com + directory: bucket + description: Deliver Go binaries as fast and easily as possible + license: MIT release: footer: | diff --git a/Makefile b/Makefile index bdde37f..82bd429 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,6 @@ SOURCE_FILES?=./... TEST_PATTERN?=. TEST_OPTIONS?= TEST_TIMEOUT?=5m -SEMVER?=0.0.0-$(shell whoami) -CI_COMMIT_SHORT_SHA?=$(shell git log --pretty=format:'%h' -n 1) test: go test $(TEST_OPTIONS) -v -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.out $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=$(TEST_TIMEOUT) @@ -22,9 +20,7 @@ ci: build test .PHONY: ci build: - go build -tags 'release netgo osusergo' \ - -ldflags '$(linker_flags) -s -w -extldflags "-fno-PIC -static" -X main.pkgName=chglog -X main.version=$(SEMVER) -X main.commit=$(CI_COMMIT_SHORT_SHA)' \ - -o chglog ./cmd/chglog/... + goreleaser build --clean --snapshot --single-target -o chglog .PHONY: build .DEFAULT_GOAL := build