Skip to content

Commit

Permalink
Update GoReleaser config and CI pipelines (#57)
Browse files Browse the repository at this point in the history
* build: use go1.20

Signed-off-by: Akshay Gaikwad <[email protected]>

* ci: update goreleaser

* Remove deprecated archives.replacements from goreleaser config
* Zip archives for Windows
* Run goreleaser for main branch

Signed-off-by: Akshay Gaikwad <[email protected]>

* ci: update go workflow

* Remove Go private module step
* Get go version from go.mod file

Signed-off-by: Akshay Gaikwad <[email protected]>

* ci: release pipeline for pull requests

Signed-off-by: Akshay Gaikwad <[email protected]>

---------

Signed-off-by: Akshay Gaikwad <[email protected]>
  • Loading branch information
akshay196 authored Aug 11, 2023
1 parent 2f5c7da commit 544d4ce
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 70 deletions.
23 changes: 8 additions & 15 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ on:
pull_request:
branches: [ main ]

env:
GOPRIVATE: https://github.com/paralus

jobs:

test:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -23,22 +19,20 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
# Getting go version from the go.mod file
go-version-file: 'go.mod'

- name: Format
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
- run: go version

- name: Granting private modules access
run: |
git config --global url."https://${{ secrets.TOKEN }}:[email protected]/paralus".insteadOf "https://github.com/paralus"
- name: Check code format
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi

- name: Test all
run: go test -v ./...

# golangci:
# strategy:
# matrix:
# go-version: [1.17.x]
# os: [ubuntu-latest]
# runs-on: ${{ matrix.os }}
# steps:
Expand All @@ -47,11 +41,10 @@ jobs:
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: ${{ matrix.go-version }}
# # Getting go version from the go.mod file
# go-version-file: 'go.mod'

# - name: Granting private modules access
# run: |
# git config --global url."https://${{ secrets.TOKEN }}:[email protected]/paralus".insteadOf "https://github.com/paralus"
# - run: go version

# - name: golangci-lint
# uses: golangci/golangci-lint-action@v2
Expand Down
31 changes: 20 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
name: goreleaser
name: GoReleaser

on:
push:
branches: [ main ]
tags: [ 'v*.*.*' ]

pull_request:
branches: [ main ]

permissions:
contents: write

jobs:

goreleaser:
release:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 0 # It is required for GoReleaser to work properly.

# This is needed if you use fields like TagBody, TagSubject or
# TagContents in your templates.
- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
# Getting go version from the go.mod file
go-version-file: 'go.mod'

- name: vendor packages
run: go mod tidy -compat=1.17 && go mod vendor
- run: go version

# Sanity check before publishing
- name: Test all
run: go test -v ./...

- name: Set goreleaser snapshot env
run: if [[ $GITHUB_REF != refs/tags/v* ]]; then echo "goreleaser_snapshot=--snapshot"; fi >> $GITHUB_ENV

- name: Read variables
run: |
echo "goreleaser_snapshot=${{ env.goreleaser_snapshot }}"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # V4.3.0
with:
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean ${{ env.goreleaser_snapshot }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 19 additions & 8 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# Check the documentation at https://goreleaser.com
project_name: pctl

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy -compat=1.17
# you may remove this if you don't need go generate
- go generate ./...
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
Expand All @@ -18,15 +16,28 @@ builds:
- -s -w -X main.version={{.Version}} -X main.time={{.CommitTimestamp }} -X main.buildNum={{.Version}}

archives:
- replacements:
386: i386
- name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
{{- .Os }}_
{{- if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
use: github
filters:
exclude:
- '^docs:'
- '^test:'
- '^chore'
- Merge pull request
43 changes: 13 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
module github.com/paralus/cli

go 1.17

require github.com/spf13/cobra v1.3.0

require go.uber.org/zap v1.21.0

require github.com/tidwall/gjson v1.14.0

require (
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852
github.com/segmentio/encoding v0.3.4
gopkg.in/yaml.v2 v2.4.0
)

require github.com/go-openapi/runtime v0.23.1
go 1.20

require (
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/runtime v0.23.1
github.com/levigross/grequests v0.0.0-20190908174114-253788527a1a
)

require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
github.com/spacemonkeygo/httpsig v0.0.0-20181218213338-2605ae379e47
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

require (
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/viper v1.10.1
)

require github.com/olekukonko/tablewriter v0.0.5

require (
github.com/olekukonko/tablewriter v0.0.5
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852
github.com/ory/kratos-client-go v0.11.1
github.com/paralus/paralus v0.1.10-0.20230127131419-80f7a148b0b6
github.com/segmentio/encoding v0.3.4
github.com/spacemonkeygo/httpsig v0.0.0-20181218213338-2605ae379e47
github.com/spf13/cobra v1.3.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.10.1
github.com/stretchr/testify v1.7.0
github.com/tidwall/gjson v1.14.0
go.uber.org/zap v1.21.0
golang.org/x/term v0.6.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

require (
Expand Down
13 changes: 7 additions & 6 deletions pkg/output/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import (
"github.com/paralus/cli/pkg/log"
)

/* This function exits the pctl program. In case 'exit' is not set,
nothing will be printed to the console. The return code of
program is set to zero.
/*
This function exits the pctl program. In case 'exit' is not set,
nothing will be printed to the console. The return code of program is
set to zero.
When 'exit' is set, the exit message will be printed to
the console before the program exits with the return code
set in the 'exit' structure.
When 'exit' is set, the exit message will be printed to the console
before the program exits with the return code set in the 'exit'
structure.
*/
func Exit() {
e := exit.Get()
Expand Down

0 comments on commit 544d4ce

Please sign in to comment.