Skip to content

Commit

Permalink
add gh release & cleanup (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
gertd authored Dec 15, 2023
1 parent 761d266 commit d6e2791
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 798 deletions.
76 changes: 49 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,53 @@ on:
env:
VAULT_ADDR: https://vault.eng.aserto.com/
PRE_RELEASE: ${{ github.ref == 'refs/heads/main' && 'development' || '' }}
GO_VERSION: "1.19"
GO_VERSION: "1.20"
GO_RELEASER_VERSION: "v1.20.0"
GO_LANGCI_LINT_VERSION: "v1.53.3"
GO_TESTSUM_VERSION: "1.10.1"

jobs:
test:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup caching
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
uses: actions/checkout@v4
-
name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
-
name: Lint and Test
name: Build
uses: goreleaser/goreleaser-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
distribution: goreleaser
version: ${{ env.GO_RELEASER_VERSION }}
args: build --clean --snapshot --single-target
-
name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GO_LANGCI_LINT_VERSION }}
args: --timeout=30m
-
name: Test Setup
uses: autero1/[email protected]
with:
gotestsum_version: ${{ env.GO_TESTSUM_VERSION }}
-
name: Test
run: |
go run mage.go deps generate build lint test
gotestsum --format short-verbose -- -count=1 -parallel=1 -v -timeout=240s -coverprofile=cover.out -coverpkg=./... ./...
-
name: Upload code coverage
uses: shogo82148/actions-goveralls@v1
continue-on-error: true
with:
path-to-profile: cover.out

release:
needs: test
Expand All @@ -54,7 +75,7 @@ jobs:
steps:
-
name: Read Configuration
uses: hashicorp/vault-action@v2.5.0
uses: hashicorp/vault-action@v2
id: vault
with:
url: ${{ env.VAULT_ADDR }}
Expand All @@ -65,7 +86,7 @@ jobs:
kv/data/gcp "SERVICE_ACCOUNT_GITHUB_ACTIONS_RELEASE" | SERVICE_ACCOUNT_GITHUB_ACTIONS_RELEASE;
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
-
Expand All @@ -74,20 +95,21 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
-
name: Setup caching
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
name: GCS Application Credentials
run: |
echo "${SERVICE_ACCOUNT_GITHUB_ACTIONS_RELEASE}" > /tmp/gs.json
-
name: Write Version Info
run: |
git describe --tags > VERSION.txt
-
name: Release
uses: goreleaser/goreleaser-action@v4
env:
HOMEBREW_TAP: ${{ steps.vault.outputs.ASERTO_TAP }}
GITHUB_TOKEN: ${{ steps.vault.outputs.READ_WRITE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_APPLICATION_CREDENTIALS: /tmp/gs.json
run: |
echo "${SERVICE_ACCOUNT_GITHUB_ACTIONS_RELEASE}" > /tmp/gs.json
go run mage.go deps generate release
with:
distribution: goreleaser
version: ${{ env.GO_RELEASER_VERSION }}
args: release --clean
4 changes: 2 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ linters-settings:
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 18
min-complexity: 20
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
Expand Down Expand Up @@ -73,7 +73,6 @@ linters:
enable:
- asciicheck
- bodyclose
- depguard
- dogsled
- errcheck
- exportloopref
Expand Down Expand Up @@ -105,6 +104,7 @@ linters:
- unused

# don't enable:
# - depguard
# - dupl
# - gochecknoglobals
# - gocognit
Expand Down
56 changes: 38 additions & 18 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
before:
hooks:

env:
- REGISTRY=ghcr.io
- ORG=aserto-dev
- REPO=aserto

builds:
-
id: build
# https://goreleaser.com/customization/build/
- id: build
main: ./cmd/aserto
binary: aserto
goos:
Expand All @@ -21,14 +26,16 @@ builds:
ldflags:
- -s
- -w
- -X github.com/aserto-dev/aserto/pkg/version.ver={{.Version}}
- -X github.com/aserto-dev/aserto/pkg/version.commit={{.ShortCommit}}
- -X github.com/aserto-dev/aserto/pkg/version.date={{.Date}}
- -X github.com/{{ .Env.ORG }}/{{ .Env.REPO }}/pkg/version.ver={{.Version}}
- -X github.com/{{ .Env.ORG }}/{{ .Env.REPO }}/pkg/version.commit={{.ShortCommit}}
- -X github.com/{{ .Env.ORG }}/{{ .Env.REPO }}/pkg/version.date={{.Date}}
mod_timestamp: '{{ .CommitTimestamp }}'

archives:
# https://goreleaser.com/customization/archive/
- format: zip
rlcp: true
builds:
- build
files:
- LICENSE.md
- README.md
Expand All @@ -37,43 +44,56 @@ archives:
checksum:
# https://goreleaser.com/customization/checksum/
name_template: 'checksums.txt'

snapshot:
# https://goreleaser.com/customization/snapshots/
name_template: "{{ .Tag }}"

source:
# https://goreleaser.com/customization/source/
enabled: false

changelog:
# https://goreleaser.com/customization/changelog/
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"

release:
disable: true
# https://goreleaser.com/customization/release/
github:
owner: "{{ .Env.ORG }}"
name: "{{ .Env.REPO }}"

draft: false
prerelease: "false"
name_template: "{{.ProjectName}} {{.Tag}}"

blobs:
-
provider: gs
# https://goreleaser.com/customization/blob/
- provider: gs
bucket: aserto-cli
folder: "aserto/{{ .Version }}"
extra_files:
- glob: VERSION.txt
-
provider: gs
- provider: gs
bucket: aserto-cli
folder: "aserto/latest"
extra_files:
- glob: VERSION.txt

brews:
-
name: aserto
# https://goreleaser.com/customization/homebrew/
- name: aserto

tap:
owner: aserto-dev
repository:
owner: "{{ .Env.ORG }}"
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP }}"
token: "{{ .Env.ASERTO_TAP }}"

url_template: "https://storage.googleapis.com/aserto-cli/aserto/{{ .Version }}/{{ .ArtifactName }}"

Expand Down
6 changes: 3 additions & 3 deletions Depfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ go:
version: "v0.5.0"
goreleaser:
importPath: github.com/goreleaser/goreleaser
version: "v1.16.2"
version: "v1.20.0"
gotestsum:
importPath: "gotest.tools/gotestsum"
version: "v1.9.0"
version: "v1.10.1"
golangci-lint:
importPath: "github.com/golangci/golangci-lint/cmd/golangci-lint"
version: "v1.52.2"
version: "v1.53.3"
6 changes: 3 additions & 3 deletions cmd/aserto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func ConfigResolver() kong.Resolver {
})

if err != nil || flag.Tag == nil || flag.Tag.EnvPrefix == "" {
return
return resolved, err
}

var svcOptions *x.ServiceOptions = nil
Expand All @@ -87,7 +87,7 @@ func ConfigResolver() kong.Resolver {
case "ASERTO_DECISION_LOGS_":
svcOptions = &tmpConfig.Services.DecisionLogsService
default:
return
return resolved, err
}

switch flag.Name {
Expand All @@ -104,7 +104,7 @@ func ConfigResolver() kong.Resolver {
resolved = flag.Default
}

return
return resolved, err
}

return f
Expand Down
Loading

0 comments on commit d6e2791

Please sign in to comment.