Skip to content

Commit

Permalink
Set release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepla committed May 6, 2022
1 parent b9988b0 commit 01ba127
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: goreleaser

on:
push:
# run only against tags
tags:
- '*'

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Fetch all tags
run: git fetch --force --tags
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
37 changes: 37 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags:
- -w -s -X main.appVersion={{.Version}} -X main.appRevision={{.ShortCommit}} -X main.appBuildDate={{.Date}}
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
18 changes: 16 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
color "github.com/fatih/color"
)

var (
appVersion = "unknown"
appRevision = "unknown"
appBuildDate = "unknown"
)

type asciiArt string

const (
Expand Down Expand Up @@ -39,11 +45,19 @@ var (

var stdout = bufio.NewWriter(os.Stdout)

var length int
var (
length int
version bool
)

func main() {
flag.IntVar(&length, "l", 10, "length")
flag.IntVar(&length, "l", 10, "length of gopher's body")
flag.BoolVar(&version, "V", false, "show version")
flag.Parse()
if version {
fmt.Printf("v%s-%s\nBuild at %s\n", appVersion, appRevision, appBuildDate)
return
}
printGopher(length)
}

Expand Down

0 comments on commit 01ba127

Please sign in to comment.