Skip to content

Commit 93f8ce0

Browse files
committed
chore(ci): add GoReleaser configuration and update GitHub Actions workflows for development and release builds
1 parent 1e43115 commit 93f8ce0

File tree

4 files changed

+142
-2
lines changed

4 files changed

+142
-2
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# This workflow will build a golang project
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
33

4-
name: Go
4+
name: Build and Test
55

66
on:
77
push:
88
branches: [ "main" ]
9+
paths-ignore:
10+
- '**.md'
11+
- 'docs/**'
912
pull_request:
1013
branches: [ "main" ]
1114

1215
jobs:
1316

1417
build:
15-
runs-on: windows-latest
18+
runs-on: ubuntu-latest
1619
steps:
1720
- uses: actions/checkout@v4
1821

.github/workflows/dev-build.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Development Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main # or master, depending on your default branch
7+
paths-ignore:
8+
- '**.md'
9+
- 'docs/**'
10+
workflow_dispatch: # Allows manual triggering
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
dev-build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: '1.23'
28+
check-latest: true
29+
30+
- name: Run GoReleaser Snapshot
31+
uses: goreleaser/goreleaser-action@v5
32+
with:
33+
distribution: goreleaser
34+
version: latest
35+
args: release --snapshot --clean
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Create/Update Development Release
40+
uses: softprops/action-gh-release@v1
41+
with:
42+
name: Development Build
43+
tag_name: dev-latest
44+
files: dist/*
45+
prerelease: true
46+
body: |
47+
# Development Build
48+
49+
This is an automated development build from commit ${{ github.sha }}
50+
51+
This build is for testing purposes only and will be overwritten with each push to the main branch.
52+
generate_release_notes: false

.github/workflows/release.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: '1.23'
24+
check-latest: true
25+
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v5
28+
with:
29+
distribution: goreleaser
30+
version: latest
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
5+
builds:
6+
- env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- linux
10+
- windows
11+
- darwin
12+
goarch:
13+
- amd64
14+
- arm64
15+
ldflags:
16+
- -s -w
17+
- -X github.com/hamzabow/co/cmd.Version={{.Version}}
18+
- -X github.com/hamzabow/co/cmd.Commit={{.Commit}}
19+
- -X github.com/hamzabow/co/cmd.Date={{.Date}}
20+
flags:
21+
- -trimpath
22+
main: ./main.go
23+
binary: co
24+
25+
archives:
26+
- format_overrides:
27+
- goos: windows
28+
format: zip
29+
name_template: >-
30+
{{- .ProjectName }}_
31+
{{- title .Os }}_
32+
{{- if eq .Arch "amd64" }}x86_64
33+
{{- else }}{{ .Arch }}{{ end }}
34+
files:
35+
- LICENSE
36+
- README.md
37+
38+
checksum:
39+
name_template: 'checksums.txt'
40+
41+
snapshot:
42+
name_template: "{{ incpatch .Version }}-next+{{.ShortCommit}}"
43+
44+
changelog:
45+
sort: asc
46+
filters:
47+
exclude:
48+
- '^docs:'
49+
- '^test:'
50+
- '^ci:'
51+
- Merge pull request
52+
- Merge branch

0 commit comments

Comments
 (0)