Skip to content

Commit

Permalink
ci: update configs (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 authored Jan 9, 2025
1 parent 8c10b87 commit 6e581ac
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ updates:
labels:
- "dependencies"
commit-message:
prefix: "feat"
prefix: "chore"
include: "scope"
- package-ecosystem: "github-actions"
directory: "/"
Expand All @@ -28,5 +28,5 @@ updates:
labels:
- "dependencies"
commit-message:
prefix: "feat"
prefix: "chore"
include: "scope"
47 changes: 26 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
81 changes: 41 additions & 40 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -59,33 +61,32 @@ 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 <[email protected]>
license: MIT
vendor: GoReleaser
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: |
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit 6e581ac

Please sign in to comment.