Skip to content

Commit

Permalink
ci: handle releases with goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbatm committed May 9, 2024
1 parent 70c6ef2 commit e5a6cc6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 27 deletions.
51 changes: 25 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
name: Release Binaries
name: goreleaser

on:
release:
types: [created]
pull_request:
push:
# run only against tags
tags:
- "v*"

permissions:
contents: write
packages: write
contents: write

jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm64]
exclude:
- goarch: "386"
goos: darwin

steps:
- uses: actions/checkout@v4
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.22
extra_files: LICENSE README.md
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.22.x
- name: Run goreleaser
uses: goreleaser/goreleaser-action@v4
with:
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ repl-result-*
# docs
node_modules
docs/.vitepress/cache
docs/.vitepress/dist
docs/.vitepress/dist

# goreleaser
dist/
33 changes: 33 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# 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: 1

project_name: treefmt

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w -X git.numtide.com/numtide/treefmt/build.Version=v{{.Version}}
goos:
- linux
- darwin

changelog:
sort: asc
use: github
filters:
exclude:
- "^chore:"
- "^docs:"
- "^test:"
1 change: 1 addition & 0 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
(with pkgs; [
# golang
go
goreleaser
delve
pprof
graphviz
Expand Down

0 comments on commit e5a6cc6

Please sign in to comment.