Skip to content

Commit

Permalink
[ci] add go releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
capcom6 committed Oct 28, 2024
1 parent 593527e commit d3841f2
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# .github/workflows/release.yml
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
- "v*"

permissions:
contents: write
# packages: write
# issues: 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@v5
with:
go-version: stable
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- main: ./cmd/smsgate
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags:
- -s -w -X main.version={{.Version}}

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- 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

# dockers:
# - image_templates:
# - "capcom6/labeled-storage:{{ .Tag }}"
# - "capcom6/labeled-storage:v{{ .Major }}"
# - "capcom6/labeled-storage:v{{ .Major }}.{{ .Minor }}"
# - "capcom6/labeled-storage:latest"
# dockerfile: Dockerfile
# build_flag_templates:
# - "--label=org.opencontainers.image.created={{ .Date }}"
# - "--label=org.opencontainers.image.title={{ .ProjectName }}"
# - "--label=org.opencontainers.image.revision={{ .FullCommit }}"
# - "--label=org.opencontainers.image.version={{ .Version }}"
# skip_push: false

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

0 comments on commit d3841f2

Please sign in to comment.