-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add github action for build and test * Add working directory * Split into build and test phases Store binary from build. * Add badge to readme * Upload single file * Move storing an artifact to only run on main * Add extra flag to build These should reduce the size of the binary produced.
- Loading branch information
1 parent
6261155
commit 3f653cc
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Go | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.13 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: go mod download | ||
working-directory: src | ||
|
||
- name: Build | ||
run: go build -v . | ||
working-directory: src | ||
|
||
unit_test: | ||
name: Unit test | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.13 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: go mod download | ||
working-directory: src | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
working-directory: src | ||
|
||
store: | ||
name: Store artifacts | ||
runs-on: ubuntu-latest | ||
needs: [build, unit_test] | ||
if: github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.13 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: go mod download | ||
working-directory: src | ||
|
||
- name: Build | ||
run: "go build -ldflags='-w -s' -o dist/worklog -v ." | ||
working-directory: src | ||
|
||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: workflow-binary | ||
path: src/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters