2022-06-25 23:40:02 +02:00
|
|
|
name: Build & Test
|
2022-06-22 21:22:45 +02:00
|
|
|
on:
|
|
|
|
- push
|
|
|
|
- pull_request
|
|
|
|
|
|
|
|
env:
|
|
|
|
NAME: stargazer
|
|
|
|
|
|
|
|
jobs:
|
2022-06-25 23:40:02 +02:00
|
|
|
test:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-06-25 23:48:42 +02:00
|
|
|
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
2022-06-25 23:40:02 +02:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2022-06-25 23:49:39 +02:00
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2022-06-25 23:48:42 +02:00
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v3
|
2022-06-25 23:40:02 +02:00
|
|
|
with:
|
2022-06-25 23:48:42 +02:00
|
|
|
go-version-file: 'go.mod'
|
|
|
|
|
|
|
|
- name: Cache
|
|
|
|
uses: actions/cache@v3
|
2022-06-25 23:40:02 +02:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/go/pkg/mod
|
|
|
|
~/.cache/go-build
|
|
|
|
~/Library/Caches/go-build
|
|
|
|
~\AppData\Local\go-build
|
2022-06-25 23:48:42 +02:00
|
|
|
key: ${{ runner.os }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
|
2022-06-25 23:40:02 +02:00
|
|
|
restore-keys: |
|
2022-06-25 23:48:42 +02:00
|
|
|
${{ runner.os }}-go-${{ env.GOVER }}-
|
|
|
|
- name: Run tests
|
|
|
|
run: go test ./...
|
2022-06-25 23:40:02 +02:00
|
|
|
|
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:
|
2022-06-25 23:49:39 +02:00
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2022-06-25 23:48:42 +02:00
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v3
|
|
|
|
with:
|
|
|
|
go-version-file: 'go.mod'
|
|
|
|
|
2022-06-22 21:22:45 +02:00
|
|
|
|
|
|
|
- name: Cache
|
2022-06-25 23:48:42 +02:00
|
|
|
uses: actions/cache@v3
|
2022-06-22 21:22:45 +02:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
|
|
|
- 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
|