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

ci: added goreleaser workflow #19

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/workflows/go.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/gorelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Gorelease comments public API changes to pull request.
name: gorelease
on:
push:
branches:
- main

# Cancel the workflow in progress in newer build is about to start.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
GO_VERSION: 1.21.x
jobs:
gorelease:
runs-on: ubuntu-latest
steps:

- name: Install Go stable
if: env.GO_VERSION != 'tip'
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Checkout code
uses: actions/checkout@v4

- name: Gorelease cache
uses: actions/cache@v3
with:
path: |
~/go/bin/gorelease
key: ${{ runner.os }}-gorelease-generic

- name: Gorelease
id: gorelease
run: |
test -e ~/go/bin/gorelease || go install golang.org/x/exp/cmd/gorelease@latest
OUTPUT=$(gorelease 2>&1 || exit 0)
echo "${OUTPUT}"
OUTPUT="${OUTPUT//$'\n'/%0A}"
echo "::set-output name=report::$OUTPUT"

- name: Comment Report
continue-on-error: true
uses: marocchino/sticky-pull-request-comment@v2
with:
header: gorelease
message: |
### Go API Changes

<pre>
${{ steps.gorelease.outputs.report }}
</pre>
59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: test
on:
push:
branches:
- main
jobs:
test:
strategy:
matrix:
go-version: [ 1.16.x, 1.17.x, 1.19.x, 1.20.x, 1.21.x ] # Lowest supported and current stable versions.
runs-on: ubuntu-latest
steps:

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v4

- name: Go cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache

- name: Run gofmt
run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile

- name: golangci-lint
uses: golangci/golangci-lint-action@v3

- name: Run staticcheck
if: matrix.go-version == '1.21.x'
uses: dominikh/[email protected]
with:
version: "2023.1.3"
install-go: false
cache-key: ${{ matrix.go }}

- name: Run go vet
run: |
go vet ./...

- name: Run go test
run: |
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...


- name: Report on code coverage
if: matrix.go-version == '1.21.x'
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea
gocuke.iml
gocuke.iml
48 changes: 48 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
project_name: "gocuke"

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

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

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^MERGE'
- "{{ .Tag }}"

release:
github:
owner: "regen-network"
name: "gocuke"