Skip to content

CI/CD: Release Pipeline with GoReleaser #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 15, 2024
42 changes: 42 additions & 0 deletions .github/workflow/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: release

on:
push:
tags:
# It will be triggered when a new tag starting with 'v' is pushed
# v1.0.0, v1.0.1, ...
- 'v*'

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.1
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
# Pass the GitHub token to GoReleaser
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 2
project_name: bwuagent

builds:
- id: bwuagent
main: ./cmd/api
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
# Support multiple cpu architectures
- amd64
- arm64
ignore:
# Ignore the arm64 build on windows
- goos: windows
goarch: arm64

archives:
- format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
format_overrides:
- goos: windows
format: zip

checksum:
# Generate checksum files to confirm the integrity of the files.
# `sha256sum <file>`
name_template: 'checksums.txt'
algorithm: sha256

changelog:
sort: asc