diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 72d4f88..696b575 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,28 +1,32 @@ +name: release + on: - release: - types: created + push: + tags: + - '*' + +permissions: + contents: write # for publishing to github releases jobs: - releases-matrix: - name: Release Go Binary + goreleaser: runs-on: ubuntu-latest - strategy: - matrix: - # build and publish in parallel: linux/amd64, linux/arm64, windows/amd64, darwin/amd64, darwin/arm64 - goos: [linux, windows, darwin] - goarch: [amd64, arm64] - exclude: - - goarch: arm64 - goos: windows steps: - - uses: actions/checkout@v3 - - uses: wangyoucao577/go-release-action@v1.35 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - extra_files: LICENSE README.md - compress_assets: "true" - md5sum: "false" - project_path: aws-whoami - binary_name: aws-whoami + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: git fetch --force --tags + + - uses: actions/setup-go@v4 + with: + go-version: stable + + - uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_HOMEBREW_TAP_TOKEN: ${{ secrets.GORELEASER_HOMEBREW_TAP_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cde0123 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..1cca6b5 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,57 @@ +project_name: aws-whoami +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - arm64 + - amd64 + main: ./aws-whoami +nfpms: + - package_name: aws-whoami + vendor: Ben Kehoe + homepage: https://github.com/benkehoe/aws-whoami-golang + maintainer: Ben Kehoe + description: A tool to show what AWS account and identity you're using. + formats: [ deb ] +brews: + - name: aws-whoami + tap: + owner: benkehoe + name: homebrew-tap + token: '{{ .Env.GORELEASER_HOMEBREW_TAP_TOKEN }}' + commit_author: + name: Ben Kehoe + email: ben@kehoe.io + homepage: https://github.com/benkehoe/aws-whoami-golang + description: A tool to show what AWS account and identity you're using. +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# The lines beneath this are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/aws-whoami/main.go b/aws-whoami/main.go index b0ff258..fd5c0de 100644 --- a/aws-whoami/main.go +++ b/aws-whoami/main.go @@ -31,7 +31,7 @@ import ( "github.com/aws/smithy-go" ) -var Version string = "2.6" +var version string = "(unknown)" // this is set by goreleaser var DisableAccountAliasEnvVarName = "AWS_WHOAMI_DISABLE_ACCOUNT_ALIAS" type Whoami struct { @@ -275,7 +275,7 @@ func main() { flag.Parse() if *showVersion { - fmt.Println(Version) + fmt.Println(version) return }