Skip to content

Commit

Permalink
ci: configure goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Feb 7, 2021
1 parent b6d53fd commit fc91a27
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 3 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: goreleaser

on:
push:
tags:
- 'v*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/testout/
/.testdata*/
/.examples/
.idea/
.idea/
/dist/
25 changes: 25 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
before:
hooks:
- go mod download
builds:
- id: cxgo
main: ./cmd/cxgo
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- 386
- amd64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-dev"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^examples:'
- '^test:'
- '^ci:'
29 changes: 27 additions & 2 deletions cmd/cxgo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,39 @@ import (
)

var Root = &cobra.Command{
Use: "cxgo",
RunE: run,
Use: "cxgo",
Short: "transpile a C project to Go",
RunE: run,
}

const (
version = "dev"
commit = ""
date = ""
)

var configPath = "cxgo.yml"

func printVersion() {
vers := version
if s := commit; s != "" {
vers = fmt.Sprintf("%s (%s)", vers, s[:8])
}
fmt.Printf("version: %s\n", vers)
if date != "" {
fmt.Printf("built: %s\n", date)
}
}

func init() {
Root.Flags().StringVarP(&configPath, "config", "c", configPath, "config file path")
Root.AddCommand(&cobra.Command{
Use: "version",
Short: "print cxgo version",
Run: func(cmd *cobra.Command, args []string) {
printVersion()
},
})
}

func main() {
Expand Down

0 comments on commit fc91a27

Please sign in to comment.