Skip to content

Commit 99df164

Browse files
committed
feat: first release
1 parent 0f6a216 commit 99df164

File tree

8 files changed

+108
-66
lines changed

8 files changed

+108
-66
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,29 @@
1-
name: Build and Release
1+
name: Release
22

33
on:
44
push:
55
tags:
6-
- 'v*.*.*'
6+
- "v*"
77

88
jobs:
9-
build:
9+
goreleaser:
1010
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
goos: [linux, darwin, windows]
14-
goarch: [amd64]
1511
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Go
18-
uses: actions/setup-go@v2
19-
with:
20-
go-version: 1.16
21-
- name: Build Binary
22-
run: |
23-
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o gin-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
24-
- name: Upload Artifact
25-
uses: actions/upload-artifact@v2
12+
- name: Checkout
13+
uses: actions/checkout@v3
2614
with:
27-
name: gin-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
28-
path: gin-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
29-
release:
30-
needs: build
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Download Artifacts
34-
uses: actions/download-artifact@v2
15+
fetch-depth: 0
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v3
3519
with:
36-
path: ./dist
37-
- name: Create Release
38-
id: create_release
39-
uses: actions/create-release@v1
40-
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
go-version: "1.21"
21+
22+
- name: Run GoReleaser
23+
uses: goreleaser/goreleaser-action@v4
4224
with:
43-
tag_name: ${{ github.ref }}
44-
release_name: Release ${{ github.ref }}
45-
draft: false
46-
prerelease: false
47-
- name: Upload Release Assets
48-
uses: actions/upload-release-asset@v1
25+
distribution: goreleaser
26+
version: latest
27+
args: release --clean
4928
env:
5029
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
with:
52-
upload_url: ${{ steps.create_release.outputs.upload_url }}
53-
asset_path: ./dist/gin-*
54-
asset_name: gin-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
55-
asset_content_type: application/octet-stream

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin
2+
gin
3+
gincli

.goreleaser.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
project_name: gincli
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- darwin
13+
- windows
14+
goarch:
15+
- amd64
16+
- arm64
17+
- 386
18+
ignore:
19+
- goos: windows
20+
goarch: arm64
21+
- goos: darwin
22+
goarch: 386
23+
ldflags:
24+
- -s -w -X main.version={{.Version}} -X main.buildDate={{.Date}}
25+
26+
archives:
27+
- format: tar.gz
28+
name_template: >-
29+
{{ .ProjectName }}_
30+
{{- title .Os }}_
31+
{{- if eq .Arch "amd64" }}x86_64
32+
{{- else if eq .Arch "386" }}i386
33+
{{- else }}{{ .Arch }}{{ end }}
34+
format_overrides:
35+
- goos: windows
36+
format: zip
37+
38+
checksum:
39+
name_template: "checksums.txt"
40+
41+
snapshot:
42+
name_template: "{{ incpatch .Version }}-next"
43+
44+
changelog:
45+
sort: asc
46+
filters:
47+
exclude:
48+
- "^docs:"
49+
- "^test:"
50+
- "^ci:"
51+
- "^chore:"

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.PHONY: build clean release
2+
3+
# Version information
4+
VERSION ?= $(shell git describe --tags --always --dirty)
5+
BUILD_DATE = $(shell date +%Y-%m-%dT%H:%M:%S%z)
6+
LDFLAGS = -ldflags "-X main.version=$(VERSION) -X main.buildDate=$(BUILD_DATE)"
7+
8+
# Build for current platform
9+
build:
10+
go build $(LDFLAGS) -o gincli
11+
12+
# Build for all platforms
13+
release: clean
14+
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/gincli-linux-amd64
15+
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o bin/gincli-linux-arm64
16+
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o bin/gincli-darwin-amd64
17+
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o bin/gincli-darwin-arm64
18+
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o bin/gincli-windows-amd64.exe
19+
GOOS=windows GOARCH=386 go build $(LDFLAGS) -o bin/gincli-windows-386.exe
20+
21+
# Clean build artifacts
22+
clean:
23+
rm -rf bin/
24+
mkdir -p bin

analyze.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

gincli-logo.jpg

-76 KB
Binary file not shown.

gincli-logo.png

405 KB
Loading

main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
// ./main.go
22
package main
33

4-
import "github.com/golang-programming/gincli/cmd"
4+
import (
5+
"fmt"
6+
"os"
7+
"github.com/golang-programming/gincli/cmd"
8+
)
9+
10+
var (
11+
version = "dev"
12+
buildDate = "unknown"
13+
)
514

615
func main() {
16+
if len(os.Args) > 1 && os.Args[1] == "version" {
17+
fmt.Printf("gincli version %s (built on %s)\n", version, buildDate)
18+
return
19+
}
720
cmd.Execute()
821
}

0 commit comments

Comments
 (0)