-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (62 loc) · 1.86 KB
/
cli.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: CLI
on:
push:
paths-ignore:
- "*.md"
- "gobin/**"
- "assets/**"
- "sql/**"
- "styles/**"
- "templates/**"
jobs:
cli-build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ linux, windows, darwin ]
goarch: [ amd64, 386, arm, arm64 ]
exclude:
- goos: darwin
goarch: 386
- goos: darwin
goarch: arm
- goos: windows
goarch: arm
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
cache: true
- name: File Extension Windows
if: ${{ matrix.goos == 'windows' }}
run: echo "file_extension=.exe" >> $GITHUB_ENV
- name: Create Dist Folder
run: mkdir dist
- name: Prepare Version Info
run: |
echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV
echo "COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "BUILD_TIME=$(date --rfc-3339=seconds)" >> $GITHUB_ENV
echo $GITHUB_ENV
- name: Build
run: |
CGO_ENABLED=0
GOOS=${{ matrix.goos }}
GOARCH=${{ matrix.goarch }}
go build -ldflags="-X 'main.Version=${{ env.VERSION }}' -X 'main.Commit=${{ env.COMMIT }}' -X 'main.BuildTime=${{ env.BUILD_TIME }}'" -o dist/gobin-${{ matrix.goos }}-${{ matrix.goarch }}${{ env.file_name }} github.com/topi314/gobin/v2/cli
- name: Upload
uses: actions/upload-artifact@v3
with:
name: gobin-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*
- name: Release
if: ${{ github.event_name == 'release' }}
uses: ncipollo/release-action@v1
with:
artifacts: dist/*
allowUpdates: true