Skip to content

Commit

Permalink
Merge pull request #2 from nabeken/go-releaser
Browse files Browse the repository at this point in the history
Go releaser
  • Loading branch information
nabeken authored Aug 8, 2020
2 parents 61af1de + 393407a commit 5c52b14
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,19 @@ jobs:
go-version: '^1.14.1'
id: go

- name: Install goxc
run: go get github.com/laher/goxc

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

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Build release binaries
run: |
goxc -tasks='xc archive' -bc="freebsd,amd64 linux,amd64 windows,386 darwin,amd64" -d .
- name: Show binaries
run: ls -alh snapshot

- name: Release
uses: softprops/action-gh-release@v1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
files: |
snapshot/go-github-apps_*.zip
snapshot/go-github-apps_*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
go-github-apps
dist
27 changes: 27 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
18 changes: 18 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,30 @@ import (
"github.com/bradleyfalzon/ghinstallation"
)

var (
version = "dev"
commit = "none"
date = "unknown"
)

func versionInfo() {
fmt.Fprintf(os.Stderr, "Version: %s\nCommit: %s\nBuiltAt: %s\n", version, commit, date)
}

func main() {
appID := flag.Int64("app-id", 0, "App ID")
instID := flag.Int64("inst-id", 0, "Installation ID")
export := flag.Bool("export", false, "show token as 'export GITHUB_TOKEN=...'")
flag.Parse()

origUsage := flag.Usage
flag.Usage = func() {
origUsage()
fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "== Build Info ==\n")
versionInfo()
}

if *appID == 0 || *instID == 0 {
fmt.Fprintf(os.Stderr, "App ID and Installation ID are required.\n\n")
flag.Usage()
Expand Down

0 comments on commit 5c52b14

Please sign in to comment.