Skip to content

Latest commit

 

History

History
161 lines (127 loc) · 4.3 KB

README.md

File metadata and controls

161 lines (127 loc) · 4.3 KB

golang-pipeline

Important! This Github Action only supports Go Module

Quick Install

Run the below command to create a push workflow in your repo.

curl -o- https://raw.githubusercontent.com/jesseobrien/golang-pipeline/master/install.sh | bash

Workflows

golang-pipeline supports Go version 1.11, 1.12, 1.13, 1.14 and 1.15 and each version has its tests, linters and release.

Format

jesseobrien/golang-pipeline/<Go versions>/<action name>@master

Examples

# Run linters in Go1.11
jesseobrien/golang-pipeline/go1.11/linter@master
# Run test in Go1.12
jesseobrien/golang-pipeline/go1.12/test@master
# Run release in Go1.13
jesseobrien/golang-pipeline/go1.13/release@master
# Run release in Go1.14
jesseobrien/golang-pipeline/go1.14/release@master
# Run release in Go1.15
jesseobrien/golang-pipeline/go1.15/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.12 test
  uses: jesseobrien/golang-pipeline/go1.12/test@master
  env:
    PROJECT_PATH: "./my/new/path"

Actions:

Linters:

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: jesseobrien/golang-pipeline/go1.12/linter@master
        with:
          GOLINT: on
          GOLINTPATH: pkg/controller
          MISSPELL: off

Test:

Example

on: push
name: build
jobs:
  go-pipeline:
    name: Go Checks
    runs-on: ubuntu-latest
    steps:
      - name: go1.12 test
        uses: jesseobrien/golang-pipeline/go1.12/test@master

Release:

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: jesseobrien/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: jesseobrien/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: jesseobrien/golang-pipeline/go1.12/release@master
        if: github.event.action == 'published'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GOOS: linux
          GOARCH: amd64

Self-Promotion

Like golang-pipeline? Follow the repository on GitHub or follow me on Twitter