Skip to content

Commit

Permalink
Merge pull request #40 from kitagry/add-goreleaser
Browse files Browse the repository at this point in the history
Add goreleaser
  • Loading branch information
kitagry authored Jul 12, 2023
2 parents 5a140db + 9c546b9 commit 94ea920
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 7 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Release

on:
push:
tags: ["*"]

jobs:
release:
strategy:
matrix:
include:
- os: ubuntu-latest
lower_os: linux
asset_name: bqls_linux_amd64
- os: macos-latest
lower_os: macos
asset_name: bqls_darwin_amd64
name: Release Go Binary
runs-on: ${{ matrix.os }}
env:
BIN_NAME: bqls

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: setup Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true

- name: cache for linux
uses: actions/cache@v3
if: runner.os == 'Linux'
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: cache for macOS
uses: actions/cache@v3
if: runner.os == 'macOS'
with:
path: |
~/Library/Caches/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: download modules
run: |
go mod download
- uses: rui314/setup-mold@v1

- name: Set tag to environment variable
id: set-tag
run: echo ::set-output name=version::${GITHUB_REF#refs/*/}

- name: build
run: mkdir ./build && go build -o ./build/bqls -ldflags '-s -w -X main.version=${{ steps.set-tag.outputs.version }}' .
env:
CC: clang
CXX: clang++

- name: Zip binaries
run: |
cd build
zip ${{ matrix.asset_name }}.zip bqls
ls -lR ./
cd ../
- id: lowerCaseOS
run: INPUT=${{ runner.os }} echo "::set-output name=os::${INPUT,,}"

- uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --config=./.goreleaser-${{ matrix.lower_os }}.yml --clean
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
10 changes: 3 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ on:
jobs:
build:
name: Build
strategy:
matrix:
os: [ "ubuntu-latest" ]
go-version: [ "1.20" ]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup Go ${{ matrix.go-version }}
- name: setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
go-version-file: go.mod
cache: true
- name: cache for linux
uses: actions/cache@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
17 changes: 17 additions & 0 deletions .goreleaser-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
builds:
- binary: bqls
skip: true
- goos:
- linux
goarch:
- amd64
ldflags:
- -X main.version={{ .Version }}
- -X main.revision={{ .ShortCommit }}

release:
github:
owner: kitagry
name: bqls
extra_files:
- glob: "build/*.zip"
15 changes: 15 additions & 0 deletions .goreleaser-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
builds:
- goos:
- darwin
goarch:
- amd64
ldflags:
- -X main.version={{ .Version }}
- -X main.revision={{ .ShortCommit }}

release:
github:
owner: kitagry
name: bqls
extra_files:
- glob: "build/*.zip"

0 comments on commit 94ea920

Please sign in to comment.