Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi arch release #78

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,32 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- name: Checkout
uses: actions/checkout@v4
with:
go-version: 1.22.x
- run: go mod download
- run: go test -v ./...
- run: go build -v .
- run: ./test.sh
fetch-depth: 0

- name: Create release
uses: actions/create-release@v1
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
go-version: "1.22"
id: go

- name: Cache Go Modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- run: go test -v ./...
- run: ./test.sh

- name: Upload artifacts
uses: actions/[email protected]
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./crd-ref-docs
asset_name: crd-ref-docs
asset_content_type: application/octet-stream
version: '~> v1'
args: release --clean
29 changes: 29 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
before:
hooks:
- go mod tidy
builds:
- main: ./main.go
goos:
- linux
- windows
- darwin
ldflags: -s -w -X main.buildVersion={{.Tag}} -X main.buildCommit={{.ShortCommit}} -X main.buildDate={{.Date}}
archives:
- name_template: >-
{{- .ProjectName }}_
{{- .Version }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
files:
- LICENSE
- README.md
checksum:
name_template: 'checksums.txt'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package main

import (
"fmt"
"os"
"strings"
"time"
Expand All @@ -36,9 +37,12 @@ func main() {
Use: "crd-ref-docs",
Short: "Generate CRD reference documentation",
SilenceUsage: true,
Version: version(),
RunE: doRun,
}

cmd.SetVersionTemplate("{{ .Version }}\n")

cmd.Flags().StringVar(&args.LogLevel, "log-level", "INFO", "Log level")
cmd.Flags().StringVar(&args.Config, "config", "config.yaml", "Path to config file")
cmd.Flags().StringVar(&args.SourcePath, "source-path", "", "Path to source directory containing CRDs")
Expand Down Expand Up @@ -136,3 +140,13 @@ func initLogging(level string) {
zap.ReplaceGlobals(logger.Named("crd-ref-docs"))
zap.RedirectStdLog(logger.Named("stdlog"))
}

var (
buildVersion string
buildDate string
buildCommit string
)

func version() string {
return fmt.Sprintf("Version: %s\nGitCommit: %s\nBuildDate: %s\n", buildVersion, buildCommit, buildDate)
}
Loading