-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: updating go, new workflows, lint cleanup
- Loading branch information
Showing
15 changed files
with
376 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: golangci-lint | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
golangci-lint: | ||
name: golangci-lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.x' | ||
cache: false | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: goreleaser | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- next | ||
tags: | ||
- "*" | ||
release: | ||
types: | ||
- published | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
id-token: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- uses: actions/checkout@v4 | ||
if: github.event_name != 'pull_request' | ||
with: | ||
fetch-depth: 0 | ||
- name: setup-go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.x | ||
- uses: anchore/sbom-action/[email protected] | ||
- name: setup qemu | ||
id: qemu | ||
uses: docker/setup-qemu-action@v3 | ||
- name: setup docker buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: install cosign | ||
uses: sigstore/cosign-installer@v3 | ||
- name: install quill | ||
env: | ||
QUILL_VERSION: 0.4.1 | ||
run: | | ||
curl -Lo /tmp/quill_${QUILL_VERSION}_linux_amd64.tar.gz https://github.com/anchore/quill/releases/download/v${QUILL_VERSION}/quill_${QUILL_VERSION}_linux_amd64.tar.gz | ||
tar -xvf /tmp/quill_${QUILL_VERSION}_linux_amd64.tar.gz -C /tmp | ||
mv /tmp/quill /usr/local/bin/quill | ||
chmod +x /usr/local/bin/quill | ||
- name: set goreleaser default args | ||
if: startsWith(github.ref, 'refs/tags/') == true | ||
run: | | ||
echo "GORELEASER_ARGS=" >> $GITHUB_ENV | ||
- name: set goreleaser args for branch | ||
if: startsWith(github.ref, 'refs/tags/') == false | ||
run: | | ||
echo "GORELEASER_ARGS=--snapshot" >> $GITHUB_ENV | ||
- name: set goreleaser args renovate | ||
if: startsWith(github.ref, 'refs/heads/renovate') == true | ||
run: | | ||
echo "GORELEASER_ARGS=--snapshot --skip publish --skip sign" >> $GITHUB_ENV | ||
- name: setup-quill | ||
uses: 1password/load-secrets-action@v2 | ||
if: startsWith(github.ref, 'refs/tags/') == true && (github.actor == github.repository_owner || github.actor == 'sans-sroc[bot]') | ||
with: | ||
export-env: true | ||
env: | ||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | ||
QUILL_NOTARY_KEY: ${{ secrets.OP_QUILL_NOTARY_KEY }} | ||
QUILL_NOTARY_KEY_ID: ${{ secrets.OP_QUILL_NOTARY_KEY_ID }} | ||
QUILL_NOTARY_ISSUER: ${{ secrets.OP_QUILL_NOTARY_ISSUER }} | ||
QUILL_SIGN_PASSWORD: ${{ secrets.OP_QUILL_SIGN_PASSWORD }} | ||
QUILL_SIGN_P12: ${{ secrets.OP_QUILL_SIGN_P12 }} | ||
- name: run goreleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean ${{ env.GORELEASER_ARGS }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: push docker images (for branches) | ||
if: github.ref == 'refs/heads/main' || github.event.pull_request.base.ref == 'main' | ||
run: | | ||
docker images --format "{{.Repository}}:{{.Tag}}" | grep "${{ github.repository }}" | xargs -L1 docker push | ||
- name: upload artifacts | ||
if: github.event.pull_request.base.ref == 'main' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: binaries | ||
path: releases/*.tar.gz |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: semantic | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- next | ||
|
||
permissions: | ||
contents: read # for checkout | ||
|
||
jobs: | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # to be able to publish a GitHub release | ||
issues: write # to be able to comment on released issues | ||
pull-requests: write # to be able to comment on released pull requests | ||
id-token: write # to enable use of OIDC for npm provenance | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: setup node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "lts/*" | ||
- name: generate-token | ||
id: generate_token | ||
uses: tibdex/github-app-token@v2 | ||
with: | ||
app_id: ${{ secrets.SROC_BOT_APP_ID }} | ||
private_key: ${{ secrets.SROC_BOT_APP_PEM }} | ||
revoke: true | ||
- name: release | ||
uses: cycjimmy/semantic-release-action@v4 | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
linters-settings: | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 3 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
gocyclo: | ||
min-complexity: 15 | ||
golint: | ||
min-confidence: 0 | ||
lll: | ||
line-length: 140 | ||
maligned: | ||
suggest-new: true | ||
misspell: | ||
locale: US | ||
|
||
linters: | ||
# please, do not use `enable-all`: it's deprecated and will be removed soon. | ||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
#- depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- copyloopvar | ||
- funlen | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- noctx | ||
- nolintlint | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
issues: | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- funlen | ||
|
||
run: | ||
timeout: 2m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
release: | ||
github: | ||
owner: sans-sroc | ||
name: integrity | ||
env: | ||
- REGISTRY=ghcr.io | ||
- IMAGE=sans-sroc/integrity | ||
builds: | ||
- id: integrity | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s | ||
- -w | ||
- -extldflags="-static" | ||
- -X '{{ .ModulePath }}/pkg/common.SUMMARY=v{{ .Version }}' | ||
- -X '{{ .ModulePath }}/pkg/common.BRANCH={{ .Branch }}' | ||
- -X '{{ .ModulePath }}/pkg/common.VERSION={{ .Tag }}' | ||
- -X '{{ .ModulePath }}/pkg/common.COMMIT={{ .Commit }}' | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
hooks: | ||
post: | ||
- cmd: | | ||
{{- if eq .Os "darwin" -}} | ||
quill sign-and-notarize "{{ .Path }}" --dry-run={{ .IsSnapshot }} --ad-hoc={{ .IsSnapshot }} -vv | ||
{{- else -}} | ||
true | ||
{{- end -}} | ||
env: | ||
- QUILL_LOG_FILE=/tmp/quill-{{ .Target }}.log | ||
sboms: | ||
- artifacts: archive | ||
archives: | ||
- id: integrity | ||
builds: | ||
- integrity | ||
name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ .Arm }}" | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
signs: | ||
- ids: | ||
- default | ||
- darwin | ||
cmd: cosign | ||
signature: "${artifact}.sig" | ||
certificate: "${artifact}.pem" | ||
args: ["sign-blob", "--yes", "--oidc-provider=github", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}"] | ||
artifacts: all | ||
checksum: | ||
name_template: "checksums.txt" | ||
snapshot: | ||
version_template: '{{ trimprefix .Summary "v" }}' | ||
# We are skipping changelog because we are using semantic release | ||
changelog: | ||
disable: true |
Oops, something went wrong.