Skip to content

Commit e74881e

Browse files
authored
upload artifacts after a release is created (#7)
use skx/github-action-publish-binaries allowing multiple files at once use go action v2 build darwin binary add license
1 parent b0f2b6f commit e74881e

File tree

4 files changed

+95
-30
lines changed

4 files changed

+95
-30
lines changed

.github/workflows/test_and_build.yml .github/workflows/test.yml

+5-26
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ on:
66
branches:
77
- master
88

9-
name: test and build
9+
name: run tests
1010
jobs:
1111
lint:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Install Go
15-
uses: actions/setup-go@v2-beta
15+
uses: actions/setup-go@v2
1616
with:
1717
go-version: 1.15.x
1818
- name: Checkout code
@@ -22,7 +22,7 @@ jobs:
2222
go get github.com/golangci/golangci-lint/cmd/golangci-lint
2323
- name: Run linters
2424
run: |
25-
export PATH=$PATH:$(go env GOPATH)/bin
25+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
2626
./pre-commit
2727
2828
test:
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
- name: Install Go
3636
if: success()
37-
uses: actions/setup-go@v2-beta
37+
uses: actions/setup-go@v2
3838
with:
3939
go-version: ${{ matrix.go-version }}
4040
- name: Checkout code
@@ -47,14 +47,13 @@ jobs:
4747
steps:
4848
- name: Install Go
4949
if: success()
50-
uses: actions/setup-go@v2-beta
50+
uses: actions/setup-go@v2
5151
with:
5252
go-version: 1.15.x
5353
- name: Checkout code
5454
uses: actions/checkout@v2
5555
- name: Calc coverage
5656
run: |
57-
export PATH=$PATH:$(go env GOPATH)/bin
5857
go test -v -covermode=count -coverprofile=coverage.out
5958
- name: Convert coverage to lcov
6059
uses: jandelgado/gcov2lcov-action@v1.0.5
@@ -67,23 +66,3 @@ jobs:
6766
github-token: ${{ secrets.github_token }}
6867
path-to-lcov: coverage.lcov
6968

70-
build:
71-
runs-on: ubuntu-latest
72-
needs: [lint, test]
73-
steps:
74-
- name: Install Go
75-
uses: actions/setup-go@v2-beta
76-
with:
77-
go-version: 1.15.x
78-
- name: Checkout code
79-
uses: actions/checkout@v2
80-
- name: build
81-
run: |
82-
export GO111MODULE=on
83-
GOOS=windows GOARCH=amd64 go build -o bin/ci-test-windows-amd64.exe
84-
GOOS=linux GOARCH=amd64 go build -o bin/ci-test-linux-amd64
85-
- name: upload artifacts
86-
uses: actions/upload-artifact@master
87-
with:
88-
name: binaries
89-
path: bin/

.github/workflows/upload_assets.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
on:
2+
release:
3+
types: [created]
4+
5+
name: Upload release assets after release is created
6+
jobs:
7+
build:
8+
name: build binaries
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Install Go
12+
uses: actions/setup-go@v2
13+
with:
14+
go-version: 1.15.x
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
- name: build
18+
run: |
19+
echo "GO111MODULE=on" >> $GITHUB_ENV
20+
GOOS=windows GOARCH=amd64 go build -o bin/ci-test-windows-amd64.exe
21+
GOOS=linux GOARCH=amd64 go build -o bin/ci-test-linux-amd64
22+
GOOS=darwin GOARCH=amd64 go build -o bin/ci-test-macos-amd64
23+
- name: upload artifacts
24+
uses: actions/upload-artifact@master
25+
with:
26+
name: binaries
27+
path: bin/
28+
29+
upload:
30+
name: Upload release assets
31+
runs-on: ubuntu-latest
32+
needs: [build]
33+
steps:
34+
35+
- name: Branch name
36+
id: branch_name
37+
run: |
38+
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
39+
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
40+
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
41+
42+
- uses: actions/checkout@v1
43+
44+
- name: Download build artefacts
45+
uses: actions/download-artifact@v1
46+
with:
47+
name: binaries
48+
path: bin/
49+
50+
- name: Create asset zips
51+
env:
52+
SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
53+
run: |
54+
mkdir assets
55+
zip assets/ci-test-${SOURCE_TAG}-windows-amd64.zip bin/ci-test-windows-amd64.exe README.md
56+
zip assets/ci-test-${SOURCE_TAG}-linux-amd64.zip bin/ci-test-linux-amd64 README.md
57+
zip assets/ci-test-${SOURCE_TAG}-darwin-amd64.zip bin/ci-test-darwin-amd64 README.md
58+
sha256sum assets/*zip > assets/SHASUMS256.txt
59+
60+
- name: Upload release assets
61+
uses: skx/github-action-publish-binaries@master
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
args: './assets/*'

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019-2020 Jan Delgado, jdelgado[at]gmx.net
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# golang ci template using github actions
22

3-
**WORK IN PROGRESS**
3+
**WORK IN PROGRESS, but can already be used**
44

55
[![Build Status](https://github.com/jandelgado/golang-ci-template-github-actions/workflows/test%20and%20build/badge.svg)](https://github.com/jandelgado/golang-ci-template-github-actions/actions?workflow=test%20and%20build)
66
[![Coverage Status](https://coveralls.io/repos/github/jandelgado/golang-ci-template-github-actions/badge.svg?branch=master)](https://coveralls.io/github/jandelgado/golang-ci-template-github-actions?branch=master)
@@ -34,9 +34,9 @@ packetized in a zip-archive.
3434

3535
## Creating a release
3636

37-
On your repositories home (github.com) go to `Releases` > `create realease`.
38-
As soon as the release-tag is created, Travis will run the deployment step.
39-
(TODO)
37+
On your repositories home (github.com) go to `Releases` > `create release`.
38+
As soon as the release-tag is created, the artifacts will be built and uploaded
39+
to the release page.
4040

4141
## Test coverage (coveralls)
4242

0 commit comments

Comments
 (0)