stargazer/.github/workflows/build.yml

85 lines
2.1 KiB
YAML
Raw Normal View History

2022-06-25 23:40:02 +02:00
name: Build & Test
2022-06-22 21:22:45 +02:00
on:
- push
- pull_request
env:
GOVER: ^1.18
NAME: stargazer
jobs:
2022-06-25 23:40:02 +02:00
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GOVER }}
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- run: go test ./...
2022-06-22 21:22:45 +02:00
build:
2022-06-25 23:40:02 +02:00
needs: test
2022-06-22 21:22:45 +02:00
name: build
runs-on: ubuntu-latest
strategy:
matrix:
GOOS: [ windows, linux, darwin ]
GOARCH: [ amd64, 386, arm, arm64 ]
exclude:
- GOOS: windows
GOARCH: arm
- GOOS: darwin
GOARCH: 386
- GOOS: darwin
GOARCH: arm
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GOVER }}
- name: Build
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
2022-06-25 23:29:57 +02:00
working-directory: cmd/stargazer
run: go build -ldflags="-s -w" -o ../../dist/$NAME-$GOOS-$GOARCH
2022-06-22 21:22:45 +02:00
- name: Rename binaries (Windows)
if: matrix.GOOS == 'windows'
run: for x in dist/$NAME-windows-*; do mv $x $x.exe; done
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{env.NAME}}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}-${{github.sha}}
path: dist/*
retention-days: 90