Skip to content

Commit 333c3e2

Browse files
authored
GitHub action implementation (#4)
* github | Implement github action * github | Add step for publish binaries * github | Add badge for build result from github actions
1 parent 6667b33 commit 333c3e2

File tree

5 files changed

+85
-4
lines changed

5 files changed

+85
-4
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
go-version: [ "1.13.x", "1.14.x" ]
14+
os: [ ubuntu-latest ]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v2
24+
with:
25+
go-version: ${{ matrix.go-version }}
26+
27+
- name: Lint
28+
run: make lint
29+
30+
- name: Test
31+
run: make test

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish
2+
3+
on:
4+
create:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
publish:
10+
strategy:
11+
matrix:
12+
go-version: [ "1.13.x", "1.14.x" ]
13+
os: [ ubuntu-latest ]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 1
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v2
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
26+
- name: Make dist
27+
run: make dist
28+
29+
- name: Upload release binaries
30+
uses: alexellis/[email protected]
31+
env:
32+
GITHUB_TOKEN: ${{ github.token }}
33+
with:
34+
asset_paths: '["./bin/awssh*"]'

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ GitCommit := $(shell git rev-parse HEAD)
33
LDFLAGS := "-s -w -X awssh/cmd.Version=$(Version) -X awssh/cmd.GitCommit=$(GitCommit)"
44
OUTDIR := bin
55

6+
GOLANGCI_VERSION = 1.31.0
7+
68
.PHONY: test pretty mod tidy
79
test:
810
CGO_ENABLED=0 go test $(shell go list ./... | grep -v /vendor/|xargs echo) -cover -coverprofile=cover.out
@@ -19,6 +21,17 @@ pretty:
1921
build:
2022
CGO_ENABLED=0 go build -ldflags $(LDFLAGS) -o awssh
2123

24+
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
25+
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
26+
bin/golangci-lint-${GOLANGCI_VERSION}:
27+
@mkdir -p bin
28+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION}
29+
@mv bin/golangci-lint "$@"
30+
31+
.PHONY: lint
32+
lint: bin/golangci-lint ## Run linter
33+
bin/golangci-lint run
34+
2235
.PHONY: dist
2336
dist:
2437
mkdir -p $(OUTDIR)

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# awssh
2+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ardikabs/awssh/CI?style=flat-square)](https://github.com/ardikabs/awssh/actions?query=workflow%3ACI)
3+
![Go Version](https://img.shields.io/badge/go%20version-%3E=1.14-61CFDD.svg?style=flat-square)
4+
[![Go Report Card](https://goreportcard.com/badge/github.com/ardikabs/awssh?style=flat-square)](https://goreportcard.com/report/github.com/ardikabs/awssh)
25
## Description
36
`awssh` is a simple CLI providing an ssh access to EC2 utilizing an [EC2 Instance Connect](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Connect-using-EC2-Instance-Connect.html) feature.<br>
47
The `awssh` is extending the `aws ec2-instance-connect` command to be aware with ssh-agent and/or populate new temporary ssh keypair while trying to establish an ssh connection to the EC2 instance target.
@@ -22,11 +25,11 @@ The `awssh` is extending the `aws ec2-instance-connect` command to be aware with
2225

2326
## Development Guide
2427
### Prerequisites
25-
* Go 1.13.5 or later
28+
* Go 1.14 or later
2629

2730
### Setup
2831
* Install Git
29-
* Install Go 1.13.5 or later
32+
* Install Go 1.14 or later
3033
* Clone this repository
3134

3235
### Build and run binary file

internal/logging/logging.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ func NewLogger(debugMode bool) *zap.SugaredLogger {
4040

4141
// Get used to get the application logger
4242
func Get() *zap.SugaredLogger {
43-
defer appLogger.Sync()
43+
defer appLogger.Sync() // nolint: errcheck
4444
return appLogger
4545
}
4646

4747
// ExitWithError will terminate execution with an error result
4848
// It prints the error to stderr and exits with a non-zero exit code
4949
func ExitWithError(err error) {
50-
defer appLogger.Sync()
50+
defer appLogger.Sync() // nolint: errcheck
5151
appLogger.Error(err)
5252
os.Exit(1)
5353
}

0 commit comments

Comments
 (0)