Skip to content

Commit

Permalink
Merge pull request #1 from ypjama/go-releaser
Browse files Browse the repository at this point in the history
Goreleaser
  • Loading branch information
ypjama authored Oct 16, 2023
2 parents 7db250c + b68e576 commit 138f12e
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 16 deletions.
44 changes: 28 additions & 16 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
on: push

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.3'
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.3'

- name: Build
run: CGO_ENABLED=0 go build -v -o conflictless cmd/conflictless/main.go
- name: Install coverage tools
run: |
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
- name: Test
run: touch c.out && go test -v ./... -coverprofile=c.out && go tool cover -func=c.out
- name: Build
run: CGO_ENABLED=0 go build -v -o conflictless cmd/conflictless/main.go

- name: Test
run: gocov test ./... | gocov-xml > coverage.xml

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.1
43 changes: 43 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: goreleaser

on:
push:
tags:
- 'v*'

permissions:
contents: 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@v4
with:
go-version: '1.21.3'

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@

# Go workspace file
go.work

# Test coverage.
coverage.xml

# Gorelease output
dist/
58 changes: 58 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

before:
hooks:
- go mod tidy

builds:
- id: conflictless
binary: conflictless
main: cmd/conflictless/main.go
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

upx:
- ids:
- conflictless
enabled: true
compress: best
lzma: true
goos:
- darwin
- linux

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

changelog:
skip: true

signs:
- artifacts: checksum
args:
- "--batch"
- "-u"
- "{{ .Env.GPG_FINGERPRINT }}"
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
6 changes: 6 additions & 0 deletions changes/go-releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
added:
- Automatic release building with goreleaser
- Golangci-lint step to go workflow
- Codecov step to go workflow

0 comments on commit 138f12e

Please sign in to comment.