Skip to content

Commit

Permalink
Merge pull request #124 from openaustralia/automate_binary_release
Browse files Browse the repository at this point in the history
Automate binary release
  • Loading branch information
jamezpolley authored Jan 16, 2020
2 parents 2bf1c01 + 422bee7 commit 523d37c
Showing 1 changed file with 72 additions and 10 deletions.
82 changes: 72 additions & 10 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: test and build
on: [push, pull_request]
name: Test, Build and Release
on:
push:
pull_request:
release:
types: published
jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -15,9 +19,14 @@ jobs:
echo "::add-path::$(go env GOPATH)/bin"
shell: bash

- name: Checkout code
- name: Checkout code ""
uses: actions/checkout@v1

- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install golangci-lint
run: |
go get github.com/golangci/golangci-lint/cmd/golangci-lint
Expand All @@ -34,7 +43,6 @@ jobs:
uses: actions/setup-go@v1
with:
go-version: 1.13

- name: setup env
run: |
echo "::set-env name=GOPATH::$(go env GOPATH)"
Expand All @@ -43,6 +51,12 @@ jobs:

- name: Check out code into the Go module directory
uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: |
Expand All @@ -63,7 +77,6 @@ jobs:
uses: actions/setup-go@v1
with:
go-version: 1.13.x

- name: setup env
run: |
echo "::set-env name=GOPATH::$(go env GOPATH)"
Expand All @@ -72,6 +85,13 @@ jobs:

- name: Checkout code
uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Calc coverage
run: |
Expand All @@ -86,21 +106,63 @@ jobs:
build:
runs-on: ubuntu-latest
needs: [lint, test]
strategy:
matrix: #Duplicated below because anchors aren't supported :/
goarch: ["amd64", "arm", "arm64", "386"]
goos: ["linux"]
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: Checkout code
uses: actions/checkout@v1
- run: |
echo "::set-env name=GOCACHE::$(go env GOCACHE)"
- uses: actions/cache@v1
with:
path: ${{ env.GOCACHE }}
key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gobuild-
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: build
env:
GO111MODULE: on
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
export GO111MODULE=on
mkdir bin/
#GOOS=windows GOARCH=amd64 go build -o bin ./...
GOOS=linux GOARCH=amd64 go build -o bin ./...
go build -o bin ./...
- name: upload artifacts
uses: actions/upload-artifact@master
with:
name: binaries
name: binaries_${{ matrix.goos }}_${{ matrix.goarch }}
path: bin/
release:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
goarch: ["amd64", "arm", "arm64", "386"]
goos: ["linux"]
if: github.event_name == 'release'
steps:
- uses: actions/download-artifact@v1
with:
name: binaries_${{ matrix.goos }}_${{ matrix.goarch }}
- name: set variables
run: |
echo "::set-env name=VERSION::$(echo ${{ github.ref }} | sed 's@refs/[^/]*/v\?@@')"
shell: bash
- name: Go Release Binary
uses: Shopify/upload-to-release@1.0.0
with:
name: yinyo_${{ env.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: binaries_${{ matrix.goos }}_${{ matrix.goarch }}/yinyo
repo-token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 523d37c

Please sign in to comment.