Skip to content

Commit 57ee42b

Browse files
authored
fix: update deps and add release process (#7)
* fix: update deps and add release process * fix: update some tests * fix: remove version command use built in cobra version
1 parent d923d42 commit 57ee42b

File tree

14 files changed

+330
-823
lines changed

14 files changed

+330
-823
lines changed

.aws-cli-auth.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[role]
2+
[role.arn_aws_iam__111122342343_role____DevAdmin]
3+
name = "arn:aws:iam::111122342343:role/DevAdmin"
4+
[role.role2]

.github/workflows/build.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
7+
jobs:
8+
set-version:
9+
runs-on: ubuntu-latest
10+
container:
11+
image: mcr.microsoft.com/dotnet/sdk:6.0
12+
outputs:
13+
semVer: ${{ steps.gitversion.outputs.semVer }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- name: Install GitVersion
19+
uses: gittools/actions/gitversion/setup@v0.9.15
20+
with:
21+
versionSpec: '5.x'
22+
- name: Set SemVer Version
23+
uses: gittools/actions/gitversion/execute@v0.9.15
24+
id: gitversion
25+
26+
- name: echo VERSIONS
27+
run: |
28+
echo "REVISION -> $GITHUB_SHA"
29+
echo "VERSION -> $GITVERSION_SEMVER"
30+
test:
31+
runs-on: ubuntu-latest
32+
container:
33+
image: golang:1.20-bullseye
34+
needs: set-version
35+
env:
36+
SEMVER: ${{ needs.set-version.outputs.semVer }}
37+
GIT_TAG: ${{ needs.set-version.outputs.semVer }}
38+
GOVCS: false
39+
steps:
40+
- uses: actions/checkout@v3
41+
with:
42+
fetch-depth: 1
43+
- name: install deps
44+
run: |
45+
apt update && apt install -y jq git
46+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
47+
git config user.email ${{ github.actor }}-ci@gha.org
48+
git config user.name ${{ github.actor }}
49+
- name: make test
50+
run: |
51+
make REVISION=$GITHUB_SHA test
52+
- name: Publish Junit style Test Report
53+
uses: mikepenz/action-junit-report@v3
54+
if: always() # always run even if the previous step fails
55+
with:
56+
report_paths: '**/.coverage/report-junit.xml'
57+
- name: Analyze with SonarCloud
58+
# You can pin the exact commit or the version.
59+
uses: SonarSource/sonarcloud-github-action@master
60+
env:
61+
SEMVER: $SEMVER
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
63+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
64+
with:
65+
# Additional arguments for the sonarcloud scanner
66+
args:
67+
# mandatory
68+
-Dsonar.projectVersion=${{ needs.set-version.outputs.semVer }}
69+
-Dsonar.go.coverage.reportPaths=/github/workspace/.coverage/out
70+
-Dsonar.go.tests.reportPaths=/github/workspace/.coverage/report-junit.xml

.github/workflows/pr.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
branches: [ master, main ]
6+
7+
jobs:
8+
set-version:
9+
runs-on: ubuntu-latest
10+
container:
11+
image: mcr.microsoft.com/dotnet/sdk:6.0
12+
outputs:
13+
semVer: ${{ steps.gitversion.outputs.semVer }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- name: Install GitVersion
19+
uses: gittools/actions/gitversion/setup@v0.9.15
20+
with:
21+
versionSpec: '5.x'
22+
- name: Set SemVer Version
23+
uses: gittools/actions/gitversion/execute@v0.9.15
24+
id: gitversion
25+
pr:
26+
runs-on: ubuntu-latest
27+
container:
28+
image: golang:1.20-bullseye
29+
needs: set-version
30+
env:
31+
REVISION: $GITHUB_SHA
32+
SEMVER: ${{ needs.set-version.outputs.semVer }}
33+
steps:
34+
- uses: actions/checkout@v3
35+
- name: install deps
36+
run: |
37+
apt-get update && apt-get install -y jq git
38+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
39+
git config user.email ${{ github.actor }}-ci@gha.org
40+
git config user.name ${{ github.actor }}
41+
- name: make test
42+
run: |
43+
make REVISION=$GITHUB_SHA test
44+
- name: Publish Junit style Test Report
45+
uses: mikepenz/action-junit-report@v3
46+
if: always() # always run even if the previous step fails
47+
with:
48+
report_paths: '**/report-junit.xml'
49+
- name: Analyze with SonarCloud
50+
# You can pin the exact commit or the version.
51+
uses: SonarSource/sonarcloud-github-action@master
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
54+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
55+
with:
56+
args:
57+
-Dsonar.projectVersion=${{ needs.set-version.outputs.semVer }}
58+
-Dsonar.go.coverage.reportPaths=/github/workspace/.coverage/out
59+
-Dsonar.go.tests.reportPaths=/github/workspace/.coverage/report-junit.xml

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: release
2+
3+
on:
4+
workflow_run:
5+
workflows: ['CI']
6+
types:
7+
- completed
8+
9+
jobs:
10+
set-version:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
container:
14+
image: mcr.microsoft.com/dotnet/sdk:6.0
15+
outputs:
16+
semVer: ${{ steps.gitversion.outputs.semVer }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Install GitVersion
22+
uses: gittools/actions/gitversion/setup@v0.9.15
23+
with:
24+
versionSpec: '5.x'
25+
- name: Set SemVer Version
26+
uses: gittools/actions/gitversion/execute@v0.9.15
27+
id: gitversion
28+
29+
- name: echo VERSIONS
30+
run: |
31+
echo "REVISION -> $GITHUB_SHA"
32+
echo "VERSION -> $GITVERSION_SEMVER"
33+
release:
34+
runs-on: ubuntu-latest
35+
container:
36+
image: golang:1.20-bullseye
37+
env:
38+
FOO: Bar
39+
needs: set-version
40+
env:
41+
SEMVER: ${{ needs.set-version.outputs.semVer }}
42+
steps:
43+
- uses: actions/checkout@v3
44+
with:
45+
fetch-depth: 1
46+
- name: install deps
47+
run: |
48+
apt-get update && apt-get install jq git -y
49+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
50+
git config user.email ${{ github.actor }}-ci@gha.org
51+
git config user.name ${{ github.actor }}
52+
- name: release library
53+
run: |
54+
make GIT_TAG=${SEMVER} REVISION=$GITHUB_SHA tag
55+
- name: release binary
56+
run: |
57+
make REVISION=$GITHUB_SHA GIT_TAG=${SEMVER} PAT=${{ secrets.GITHUB_TOKEN }} cross-build
58+
make REVISION=$GITHUB_SHA GIT_TAG=${SEMVER} PAT=${{ secrets.GITHUB_TOKEN }} release

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Test binary, build with `go test -c`
99
*.test
10+
.coverage
1011

1112
# Output of the go coverage tool, specifically when used with LiteIDE
1213
*.out
@@ -24,4 +25,4 @@ vendor/
2425
# IDEs
2526
.vscode
2627

27-
.ignore*
28+
.ignore*

Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
OWNER := dnitsch
22
NAME := aws-cli-auth
3-
VERSION := v0.10.1
4-
REVISION := $(shell git rev-parse --short HEAD)
3+
GIT_TAG := 0.11.11
4+
VERSION := v$(GIT_TAG)
5+
REVISION := aaaabbbbb1234
56

6-
LDFLAGS := -ldflags="-s -w -X \"github.com/dnitsch/aws-cli-auth/cmd.Version=$(VERSION)\" -X \"github.com/dnitsch/aws-cli-auth/cmd.Revision=$(REVISION)\" -extldflags -static"
7+
LDFLAGS := -ldflags="-s -w -X \"github.com/$(OWNER)/$(NAME)/cmd.Version=$(VERSION)\" -X \"github.com/$(OWNER)/$(NAME)/cmd.Revision=$(REVISION)\" -extldflags -static"
78

89
.PHONY: test test_ci tidy install buildprep build buildmac buildwin
910

@@ -33,17 +34,24 @@ clean:
3334
rm -rf vendor/*
3435

3536
.PHONY: cross-build
37+
3638
cross-build:
3739
for os in darwin linux windows; do \
38-
[ $$os = "windows" ] && EXT=".exe"; \
39-
GOOS=$$os CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo $(LDFLAGS) -o dist/$(NAME)-$$os$$EXT .; \
40+
GOOS=$$os CGO_ENABLED=0 go build -mod=readonly -buildvcs=false $(LDFLAGS) -o dist/$(NAME)-$$os .; \
4041
done
4142

42-
release: cross-build
43-
git tag $(VERSION)
44-
git push origin $(VERSION)
43+
release:
4544
OWNER=$(OWNER) NAME=$(NAME) PAT=$(PAT) VERSION=$(VERSION) . hack/release.sh
4645

46+
tag:
47+
git tag -a $(VERSION) -m "ci tag release" $(REVISION)
48+
git push origin $(VERSION)
49+
50+
tagbuildrelease: tag cross-build release
51+
52+
show_coverage: test
53+
go tool cover -html=.coverage/out
54+
4755
.PHONY: deps
4856
deps:
4957
GO111MODULE=on go mod vendor
@@ -56,5 +64,3 @@ dist:
5664
$(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \
5765
$(DIST_DIRS) zip -r $(NAME)-$(VERSION)-{}.zip {} \; && \
5866
cd ..
59-
60-

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
[![Go Report Card](https://goreportcard.com/badge/github.com/dnitsch/aws-cli-auth)](https://goreportcard.com/report/github.com/dnitsch/aws-cli-auth)
2+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=dnitsch_aws-cli-auth&metric=bugs)](https://sonarcloud.io/summary/new_code?id=dnitsch_aws-cli-auth)
3+
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=dnitsch_aws-cli-auth&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=dnitsch_aws-cli-auth)
4+
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=dnitsch_aws-cli-auth&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=dnitsch_aws-cli-auth)
5+
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=dnitsch_aws-cli-auth&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=dnitsch_aws-cli-auth)
6+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=dnitsch_aws-cli-auth&metric=coverage)](https://sonarcloud.io/summary/new_code?id=dnitsch_aws-cli-auth)
7+
18
# aws-cli-auth
29

3-
[![Go Report Card](https://goreportcard.com/badge/github.com/dnitsch/aws-cli-auth)](https://goreportcard.com/report/github.com/dnitsch/aws-cli-auth)
410

511
CLI tool for retrieving AWS temporary credentials using SAML providers.
612

cmd/root.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import (
99
"github.com/spf13/cobra"
1010
)
1111

12+
var (
13+
Version string = "0.0.1"
14+
Revision string = "1111aaaa"
15+
)
16+
1217
var (
1318
cfgSectionName string
1419
storeInProfile bool
@@ -20,6 +25,7 @@ var (
2025
Long: `CLI tool for retrieving AWS temporary credentials using SAML providers, or specified method of retrieval - i.e. force AWS_WEB_IDENTITY.
2126
Useful in situations like CI jobs or containers where multiple env vars might be present.
2227
Stores them under the $HOME/.aws/credentials file under a specified path or returns the crednetial_process payload for use in config`,
28+
Version: fmt.Sprintf("%s-%s", Version, Revision),
2329
}
2430
)
2531

cmd/version.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

go.mod

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
module github.com/dnitsch/aws-cli-auth
22

3-
go 1.18
3+
go 1.20
44

55
require (
6-
github.com/aws/aws-sdk-go v1.44.62
6+
github.com/aws/aws-sdk-go v1.46.3
77
github.com/mitchellh/go-ps v1.0.0
88
github.com/pkg/errors v0.9.1
9-
github.com/spf13/cobra v1.5.0
9+
github.com/spf13/cobra v1.7.0
1010
// github.com/spf13/viper v1.10.1
11-
github.com/zalando/go-keyring v0.2.1
11+
github.com/zalando/go-keyring v0.2.3
1212
)
1313

1414
require (
15-
github.com/alessio/shellescape v1.4.1 // indirect
16-
github.com/danieljoos/wincred v1.1.2 // indirect
15+
github.com/alessio/shellescape v1.4.2 // indirect
16+
github.com/danieljoos/wincred v1.2.0 // indirect
1717
github.com/godbus/dbus/v5 v5.1.0 // indirect
1818
github.com/gofrs/flock v0.8.1 // indirect
19-
github.com/google/uuid v1.3.0 // indirect
20-
github.com/mattn/go-colorable v0.1.12 // indirect
21-
github.com/mattn/go-isatty v0.0.14 // indirect
19+
github.com/google/uuid v1.3.1 // indirect
20+
github.com/mattn/go-colorable v0.1.13 // indirect
21+
github.com/mattn/go-isatty v0.0.20 // indirect
2222
github.com/spaolacci/murmur3 v1.1.0 // indirect
23+
github.com/ysmood/fetchup v0.2.3 // indirect
2324
github.com/ysmood/goob v0.4.0 // indirect
24-
github.com/ysmood/gson v0.7.2 // indirect
25+
github.com/ysmood/got v0.34.1 // indirect
26+
github.com/ysmood/gson v0.7.3 // indirect
2527
github.com/ysmood/leakless v0.8.0 // indirect
26-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
28+
golang.org/x/crypto v0.14.0 // indirect
2729
)
2830

2931
require (
30-
github.com/go-rod/rod v0.108.1
31-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
32+
github.com/go-rod/rod v0.114.4
33+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3234
github.com/jmespath/go-jmespath v0.4.0 // indirect
33-
github.com/rs/zerolog v1.27.0
35+
github.com/rs/zerolog v1.31.0
3436
github.com/spf13/pflag v1.0.5 // indirect
35-
github.com/werf/lockgate v0.0.0-20211004100849-f85d5325b201
36-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
37-
gopkg.in/ini.v1 v1.66.6
37+
github.com/werf/lockgate v0.1.1
38+
golang.org/x/sys v0.13.0 // indirect
39+
gopkg.in/ini.v1 v1.67.0
3840
)

0 commit comments

Comments
 (0)