Skip to content

Commit

Permalink
upload artifacts after a release is created (#7)
Browse files Browse the repository at this point in the history
use skx/github-action-publish-binaries allowing multiple files at once
use go action v2
build darwin binary
add license
  • Loading branch information
jandelgado authored Oct 15, 2020
1 parent b0f2b6f commit e74881e
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
branches:
- master

name: test and build
name: run tests
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2-beta
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
Expand All @@ -22,7 +22,7 @@ jobs:
go get github.com/golangci/golangci-lint/cmd/golangci-lint
- name: Run linters
run: |
export PATH=$PATH:$(go env GOPATH)/bin
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
./pre-commit
test:
Expand All @@ -34,7 +34,7 @@ jobs:
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v2-beta
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
Expand All @@ -47,14 +47,13 @@ jobs:
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v2-beta
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: Calc coverage
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go test -v -covermode=count -coverprofile=coverage.out
- name: Convert coverage to lcov
uses: jandelgado/[email protected]
Expand All @@ -67,23 +66,3 @@ jobs:
github-token: ${{ secrets.github_token }}
path-to-lcov: coverage.lcov

build:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Install Go
uses: actions/setup-go@v2-beta
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: build
run: |
export GO111MODULE=on
GOOS=windows GOARCH=amd64 go build -o bin/ci-test-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build -o bin/ci-test-linux-amd64
- name: upload artifacts
uses: actions/upload-artifact@master
with:
name: binaries
path: bin/
65 changes: 65 additions & 0 deletions .github/workflows/upload_assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
release:
types: [created]

name: Upload release assets after release is created
jobs:
build:
name: build binaries
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v2
- name: build
run: |
echo "GO111MODULE=on" >> $GITHUB_ENV
GOOS=windows GOARCH=amd64 go build -o bin/ci-test-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build -o bin/ci-test-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o bin/ci-test-macos-amd64
- name: upload artifacts
uses: actions/upload-artifact@master
with:
name: binaries
path: bin/

upload:
name: Upload release assets
runs-on: ubuntu-latest
needs: [build]
steps:

- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- uses: actions/checkout@v1

- name: Download build artefacts
uses: actions/download-artifact@v1
with:
name: binaries
path: bin/

- name: Create asset zips
env:
SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
run: |
mkdir assets
zip assets/ci-test-${SOURCE_TAG}-windows-amd64.zip bin/ci-test-windows-amd64.exe README.md
zip assets/ci-test-${SOURCE_TAG}-linux-amd64.zip bin/ci-test-linux-amd64 README.md
zip assets/ci-test-${SOURCE_TAG}-darwin-amd64.zip bin/ci-test-darwin-amd64 README.md
sha256sum assets/*zip > assets/SHASUMS256.txt
- name: Upload release assets
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: './assets/*'
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019-2020 Jan Delgado, jdelgado[at]gmx.net

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# golang ci template using github actions

**WORK IN PROGRESS**
**WORK IN PROGRESS, but can already be used**

[![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)
[![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)
Expand Down Expand Up @@ -34,9 +34,9 @@ packetized in a zip-archive.

## Creating a release

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

## Test coverage (coveralls)

Expand Down

0 comments on commit e74881e

Please sign in to comment.