Skip to content

Commit 94ea920

Browse files
authored
Merge pull request #40 from kitagry/add-goreleaser
Add goreleaser
2 parents 5a140db + 9c546b9 commit 94ea920

File tree

5 files changed

+123
-7
lines changed

5 files changed

+123
-7
lines changed

.github/workflows/release.yaml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["*"]
6+
7+
jobs:
8+
release:
9+
strategy:
10+
matrix:
11+
include:
12+
- os: ubuntu-latest
13+
lower_os: linux
14+
asset_name: bqls_linux_amd64
15+
- os: macos-latest
16+
lower_os: macos
17+
asset_name: bqls_darwin_amd64
18+
name: Release Go Binary
19+
runs-on: ${{ matrix.os }}
20+
env:
21+
BIN_NAME: bqls
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
28+
- name: setup Go
29+
uses: actions/setup-go@v4
30+
with:
31+
go-version-file: go.mod
32+
cache: true
33+
34+
- name: cache for linux
35+
uses: actions/cache@v3
36+
if: runner.os == 'Linux'
37+
with:
38+
path: |
39+
~/.cache/go-build
40+
~/go/pkg/mod
41+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
42+
restore-keys: |
43+
${{ runner.os }}-go-
44+
45+
- name: cache for macOS
46+
uses: actions/cache@v3
47+
if: runner.os == 'macOS'
48+
with:
49+
path: |
50+
~/Library/Caches/go-build
51+
~/go/pkg/mod
52+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
53+
restore-keys: |
54+
${{ runner.os }}-go-
55+
56+
- name: download modules
57+
run: |
58+
go mod download
59+
60+
- uses: rui314/setup-mold@v1
61+
62+
- name: Set tag to environment variable
63+
id: set-tag
64+
run: echo ::set-output name=version::${GITHUB_REF#refs/*/}
65+
66+
- name: build
67+
run: mkdir ./build && go build -o ./build/bqls -ldflags '-s -w -X main.version=${{ steps.set-tag.outputs.version }}' .
68+
env:
69+
CC: clang
70+
CXX: clang++
71+
72+
- name: Zip binaries
73+
run: |
74+
cd build
75+
zip ${{ matrix.asset_name }}.zip bqls
76+
ls -lR ./
77+
cd ../
78+
79+
- id: lowerCaseOS
80+
run: INPUT=${{ runner.os }} echo "::set-output name=os::${INPUT,,}"
81+
82+
- uses: goreleaser/goreleaser-action@v2
83+
with:
84+
version: latest
85+
args: release --config=./.goreleaser-${{ matrix.lower_os }}.yml --clean
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}

.github/workflows/test.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,14 @@ on:
88
jobs:
99
build:
1010
name: Build
11-
strategy:
12-
matrix:
13-
os: [ "ubuntu-latest" ]
14-
go-version: [ "1.20" ]
15-
runs-on: ${{ matrix.os }}
11+
runs-on: ubuntu-latest
1612
steps:
1713
- name: checkout
1814
uses: actions/checkout@v3
19-
- name: setup Go ${{ matrix.go-version }}
15+
- name: setup Go
2016
uses: actions/setup-go@v4
2117
with:
22-
go-version: ${{ matrix.go-version }}
18+
go-version-file: go.mod
2319
cache: true
2420
- name: cache for linux
2521
uses: actions/cache@v3

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

.goreleaser-linux.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
builds:
2+
- binary: bqls
3+
skip: true
4+
- goos:
5+
- linux
6+
goarch:
7+
- amd64
8+
ldflags:
9+
- -X main.version={{ .Version }}
10+
- -X main.revision={{ .ShortCommit }}
11+
12+
release:
13+
github:
14+
owner: kitagry
15+
name: bqls
16+
extra_files:
17+
- glob: "build/*.zip"

.goreleaser-macos.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
builds:
2+
- goos:
3+
- darwin
4+
goarch:
5+
- amd64
6+
ldflags:
7+
- -X main.version={{ .Version }}
8+
- -X main.revision={{ .ShortCommit }}
9+
10+
release:
11+
github:
12+
owner: kitagry
13+
name: bqls
14+
extra_files:
15+
- glob: "build/*.zip"

0 commit comments

Comments
 (0)