Important! This Github Action only supports Go Module
Run the below command to create a push workflow in your repo.
curl -o- https://raw.githubusercontent.com/flypay/golang-pipeline/master/install.sh | bash
golang-pipeline supports Go version 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20 and 1.21 and each version has its tests, linters and release.
Format
flypay/golang-pipeline/<Go versions>/<action name>@master
Examples
# Run linters in Go1.11
flypay/golang-pipeline/go1.11/linter@master
# Run test in Go1.12
flypay/golang-pipeline/go1.12/test@master
# Run release in Go1.13
flypay/golang-pipeline/go1.13/release@master
# Run release in Go1.14
flypay/golang-pipeline/go1.14/release@master
# Run release in Go1.15
flypay/golang-pipeline/go1.15/release@master
# Run release in Go1.16
flypay/golang-pipeline/go1.16/release@master
# Run release in Go1.17
flypay/golang-pipeline/go1.16/release@master
# Run release in Go1.18
flypay/golang-pipeline/go1.16/release@master
If your Go project is not located at the root of the repo you can also specify environment variable PROJECT_PATH:
steps:
- name: go1.21 test
uses: flypay/golang-pipeline/go1.21/test@master
env:
PROJECT_PATH: "./my/new/path"
This is the list of linters you can use in your workflow, you can turn them on or off by declaring their key and value in the workflow.
-
Staticcheck A collection of tools and libraries for working with Go code, including linters and static analysis, most prominently staticcheck.
- default: on
- key: STATICCHECK
-
Errcheck A program for checking for unchecked errors in go programs.
- default: on
- key: ERRCHECK
-
Golint Golint is more focused with coding style. Golint is in use at Google, and it seeks to match the accepted style of the open source Go project.
- default: off
- key: GOLINT
Additionally you can override default golint path with
- default: .
- key: GOLINTPATH
-
Misspell Correct commonly misspelt English words
- default : off
- key: MISSPELL
Example
on: push
name: build
jobs:
go-pipeline:
name: Go Checks
runs-on: ubuntu-latest
steps:
- name: go1.12 linter
uses: flypay/golang-pipeline/go1.12/linter@master
with:
GOLINT: on
GOLINTPATH: pkg/controller
MISSPELL: off
Example
on: push
name: build
jobs:
go-pipeline:
name: Go Checks
runs-on: ubuntu-latest
steps:
- name: go1.12 test
uses: flypay/golang-pipeline/go1.12/test@master
This action required GOOS, GOARCH and GITHUB_TOKEN env variables for golang-pipeline to build and deploy binary to a release.
- GOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
- GOARCH is the running program's architecture target: one of 386, amd64, arm, s390x, and so on.
- GITHUB_TOKEN
use this token -
${{ secrets.GITHUB_TOKEN }}
to deploy your build
Exmaple:
on: release
name: Build on release
jobs:
build:
name: Build Go
runs-on: ubuntu-latest
steps:
- name: osx build
uses: flypay/golang-pipeline/go1.12/release@master
if: github.event.action == 'published'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOS: darwin
GOARCH: amd64
- name: windows build
uses: flypay/golang-pipeline/go1.12/release@master
if: github.event.action == 'published'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOS: windows
GOARCH: amd64
- name: linux build
uses: flypay/golang-pipeline/go1.12/release@master
if: github.event.action == 'published'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOS: linux
GOARCH: amd64