From 83c327b654a06c7d7e10051d60cdb5ca9c7efe79 Mon Sep 17 00:00:00 2001 From: Eytan Avisror Date: Fri, 8 Apr 2022 17:18:14 -0400 Subject: [PATCH] feat: add goreleaser & binary publishing (#33) * Add goreleaser Signed-off-by: Eytan Avisror * fix dynamic versioning Signed-off-by: Eytan Avisror * address comments Signed-off-by: Eytan Avisror --- .github/workflows/push.yaml | 4 ++++ .github/workflows/release.yaml | 31 +++++++++++++++++++++++++++++++ .github/workflows/unit-test.yaml | 2 +- .gitignore | 3 ++- .goreleaser.yaml | 30 ++++++++++++++++++++++++++++++ cmd/cli/version.go | 2 +- 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index d78cdf5..7de2435 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -41,6 +41,10 @@ jobs: uses: docker/metadata-action@v3 with: images: ${{ github.repository_owner }}/aws-auth + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} - name: Build and push uses: docker/build-push-action@v2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..30fb45f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,31 @@ +name: Release aws-auth binaries + +on: + release: + types: [created] + +jobs: + releases-matrix: + name: Release Go Binary + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: ^1.17 + + - name: GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # TODO: Test using krew-release-bot later + + # - name: Update new version in krew-index + # uses: rajatjindal/krew-release-bot@v0.0.42 \ No newline at end of file diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index e1596d8..b1d69e5 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -15,7 +15,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.13 + go-version: ^1.17 - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 4cc4d46..ba688c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin/* coverage.txt -coverage.html \ No newline at end of file +coverage.html +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..cfecceb --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,30 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + - go mod tidy + - go generate ./... +builds: + - id: aws-auth + main: ./ + binary: aws-auth + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + ldflags: + - -s + - -w + - -X github.com/keikoproj/aws-auth/cmd/cli.gitCommit={{.Commit}} + - -X github.com/keikoproj/aws-auth/cmd/cli.buildDate={{.Date}} + - -X github.com/keikoproj/aws-auth/cmd/cli.pkgVersion={{.Version}} +archives: + - builds: + - aws-auth + name_template: "{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" + wrap_in_directory: false + format: tar.gz + files: + - LICENSE diff --git a/cmd/cli/version.go b/cmd/cli/version.go index 51f4157..3716eea 100644 --- a/cmd/cli/version.go +++ b/cmd/cli/version.go @@ -30,7 +30,7 @@ var ( //It should be set during build via -ldflags. buildDate string // version is the aws-auth package version - pkgVersion string = "0.3.2" + pkgVersion string = "dev" ) // Info holds the information related to descheduler app version.