Skip to content

Commit

Permalink
Add CI and goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Mar 11, 2022
1 parent 87bc203 commit 363d5c1
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 15 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release

on:
push:
branches:
- "!**/*"
tags:
- "v*"

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Go
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
go:
- 1.16
- 1.17
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build & Test
run: |
make test
47 changes: 47 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
id: nopaste
main: cmd/nopaste/main.go
goos:
- darwin
- linux
goarch:
- amd64
- arm64
- env:
- CGO_ENABLED=0
id: irc-msgr
main: cmd/irc-msgr/main.go
goos:
- darwin
- linux
goarch:
- amd64
- arm64
- env:
- CGO_ENABLED=0
id: nopaste-cli
main: cmd/nopaste-cli/nopaste-cli.go
goos:
- darwin
- linux
goarch:
- amd64
- arm64
archives:
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
20 changes: 5 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@ GIT_VER := $(shell git describe --tags)
DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
export GO111MODULE := on

.PHONY: test get-deps binary install clean
.PHONY: test build clean client
test:
go test

get-deps:
go get -t -d -v .

binary:
cd cmd/nopaste && gox -os="linux darwin" -arch="amd64" -output "../../pkg/{{.Dir}}-${GIT_VER}-{{.OS}}-{{.Arch}}" -ldflags "-X main.version=${GIT_VER} -X main.buildDate=${DATE}"
cd cmd/irc-msgr && gox -os="linux darwin" -arch="amd64" -output "../../pkg/{{.Dir}}-${GIT_VER}-{{.OS}}-{{.Arch}}" -ldflags "-X main.version=${GIT_VER} -X main.buildDate=${DATE}"
cd cmd/nopaste-cli && gox -os="linux darwin" -arch="amd64" -output "../../pkg/{{.Dir}}-${GIT_VER}-{{.OS}}-{{.Arch}}" -ldflags "-X main.version=${GIT_VER} -X main.buildDate=${DATE} -X main.Endpoint=$(ENDPOINT)"
cd pkg && find . -name "*${GIT_VER}*" -type f -exec zip {}.zip {} \;
build:
goreleaser build --snapshot --rm-dist

clean:
rm -f pkg/*

all:
cd cmd/nopaste && go build
cd cmd/irc-msgr && go build
rm -rf dist/*

client:
cd cmd/nopaste-cli && go build -ldflags "-X main.Endpoint=$(ENDPOINT)"
cd cmd/nopaste-cli && go build -ldflags "-X main.Endpoint=$(ENDPOINT)" .

0 comments on commit 363d5c1

Please sign in to comment.