Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
/ golang-pipeline Public archive

Github Actions for Go, it tests and builds your code seamlessly without any hassle.

Notifications You must be signed in to change notification settings

shoukoo/golang-pipeline

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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/shoukoo/golang-pipeline/master/install.sh | bash

Workflows

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

Format

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

Examples

# Run linters in Go1.11
shoukoo/golang-pipeline/go1.11/linter@master
# Run test in Go1.12
shoukoo/golang-pipeline/go1.12/test@master
# Run release in Go1.13
shoukoo/golang-pipeline/go1.13/release@master
# Run release in Go1.19
shoukoo/golang-pipeline/go1.19/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: shoukoo/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: shoukoo/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: shoukoo/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: shoukoo/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: shoukoo/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: shoukoo/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