-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use go 1.17.x * Separate build steps into different files * Add new build steps to publish a release upon a new tag
- Loading branch information
1 parent
df9f887
commit 734114c
Showing
4 changed files
with
106 additions
and
96 deletions.
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,31 @@ | ||
name: Upload code coverage | ||
|
||
on: | ||
workflow_run: | ||
workflows: [Build] | ||
types: [completed] | ||
branches: [master] | ||
|
||
jobs: | ||
upload-code-coverage: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
|
||
- name: Run tests and write coverprofile | ||
shell: bash | ||
run: | | ||
go test -race -coverprofile=profile.out -covermode=atomic ./... | ||
- name: Upload testcoverage to codecov.io | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./profile.out | ||
fail_ci_if_error: true |
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,43 @@ | ||
name: Publish release | ||
|
||
on: | ||
workflow_run: | ||
workflows: [Build] | ||
types: [completed] | ||
|
||
jobs: | ||
publish-release: | ||
runs-on: ubuntu-latest | ||
# Kinda bad since it might release on any branch starting with v, but it'll do for now. | ||
# Tag filtering in "on:" doesn't work, since the inital build trigger gets lost. | ||
# github.ref is therefore also being reset to "refs/head/master". | ||
if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') }} | ||
|
||
steps: | ||
- name: Download linux artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: test-and-build.yml | ||
name: scribblers-linux-x64 | ||
|
||
- name: Download macos artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: test-and-build.yml | ||
name: scribblers-macos-x64 | ||
|
||
- name: Download windows artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: test-and-build.yml | ||
name: scribblers-x64.exe | ||
|
||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: ${{ github.event.workflow_run.head_branch }} | ||
tag_name: ${{ github.event.workflow_run.head_branch }} | ||
files: | | ||
scribblers-linux-x64 | ||
scribblers-macos-x64 | ||
scribblers-x64.exe |
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 |
---|---|---|
@@ -1,105 +1,41 @@ | ||
name: Run tests, build artifacts and upload code coverage | ||
name: Build | ||
|
||
on: push | ||
|
||
jobs: | ||
|
||
run-tests: | ||
test-and-build: | ||
strategy: | ||
matrix: | ||
go-version: [1.16.x] | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
include: | ||
- platform: windows-latest | ||
binary_name: scribblers-x64.exe | ||
- platform: ubuntu-latest | ||
binary_name: scribblers-linux-x64 | ||
- platform: macos-latest | ||
binary_name: scribblers-macos-x64 | ||
|
||
runs-on: ${{ matrix.platform }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Run tests and write coverprofile | ||
shell: bash | ||
run: | | ||
go test -race -coverprofile=profile.out -covermode=atomic ./... | ||
- name: Upload testcoverage to codecov.io | ||
if: github.ref == 'refs/heads/master' && matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.16.x' | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./profile.out | ||
fail_ci_if_error: true | ||
|
||
# We run builds for the three major platforms on the latest go | ||
# version, while the tests may run on older versions. | ||
|
||
# Each artifact upload has a name specified, so we can avoid uploading | ||
# all artifcats in one zip. | ||
|
||
build-linux: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- name: Build linux artifact | ||
shell: bash | ||
run: | | ||
go build -o scribblers-linux-x64 . | ||
- name: Upload linux build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: scribblers-linux-x64 | ||
path: ./scribblers-linux-x64 | ||
|
||
build-macos: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- name: Build macos artifact | ||
shell: bash | ||
run: | | ||
go build -o scribblers-macos-x64 . | ||
- name: Upload macos build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: scribblers-macos-x64 | ||
path: ./scribblers-macos-x64 | ||
|
||
build-windows: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- name: Build windows artifact | ||
shell: cmd | ||
run: | | ||
go build -o scribblers-x64.exe . | ||
- name: Upload windows build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: scribblers-x64.exe | ||
path: ./scribblers-x64.exe | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
|
||
- name: Run tests | ||
shell: bash | ||
run: | | ||
go test -race -covermode=atomic ./... | ||
- name: Build artifact | ||
shell: bash | ||
run: | | ||
go build -o ${{ matrix.binary_name }} . | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ matrix.binary_name }} | ||
path: ./${{ matrix.binary_name }} |
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