Skip to content
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

Goreleaser #1

Merged
merged 12 commits into from
Oct 16, 2023
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

Loading