Skip to content

Commit 7a98e76

Browse files
committed
chore: update goreleaser and release workflow
1 parent 452c976 commit 7a98e76

11 files changed

Lines changed: 142 additions & 102 deletions

File tree

.github/workflows/build.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,25 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v5
16+
with:
17+
fetch-depth: 0
1618

1719
- uses: actions/setup-go@v5
1820
with:
1921
go-version-file: go.mod
2022

23+
- uses: goreleaser/goreleaser-action@v6
24+
with:
25+
# https://github.com/goreleaser/goreleaser/releases/tag/v2.12.7
26+
version: v2.12.7
27+
args: build --clean --snapshot
28+
2129
- shell: sh
22-
run: |-
23-
go build -o ./dist/aws-console .
24-
./dist/aws-console --version
30+
run: ./dist/aws-console_linux_amd64_v1/aws-console --version
31+
32+
- uses: actions/upload-artifact@v4
33+
continue-on-error: true
34+
with:
35+
name: artifacts
36+
path: dist/
37+
retention-days: 1

.github/workflows/release.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
name: Release
1+
name: release
2+
23
on:
34
push:
4-
branches:
5-
- "!*"
65
tags:
76
- "v*.*.*"
87

98
jobs:
10-
build:
11-
name: Release
12-
runs-on: ubuntu-22.04
9+
release:
10+
name: release
11+
runs-on: ubuntu-latest
12+
environment: release
13+
14+
permissions:
15+
contents: write
1316

1417
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
18+
- uses: actions/checkout@v5
1719

18-
- name: Setup go
19-
uses: actions/setup-go@v4
20+
- uses: actions/setup-go@v5
2021
with:
21-
go-version: "1.20"
22+
go-version-file: go.mod
2223

23-
- name: Build and publish release artifacts
24-
uses: goreleaser/goreleaser-action@v2
24+
- uses: goreleaser/goreleaser-action@v6
2525
with:
26-
# https://github.com/goreleaser/goreleaser/releases/tag/v1.17.2
27-
version: v1.17.2
28-
args: release
26+
# https://github.com/goreleaser/goreleaser/releases/tag/v2.12.7
27+
version: v2.12.7
28+
args: release --clean
2929
env:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
HOMEBREW_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
31+
HOMEBREW_DEPLOY_KEY: ${{ secrets.HOMEBREW_DEPLOY_KEY }}

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ linters:
2222
- depguard
2323
- err113
2424
- exhaustruct
25+
- gochecknoglobals
2526
- lll
2627
- noinlineerr
2728
- tagliatelle

.goreleaser.yaml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
project_name: aws-console
1+
version: 2
22

33
builds:
4-
- id: aws-console
5-
binary: aws-console
4+
- goos:
5+
- darwin
6+
- linux
67

7-
targets:
8-
- darwin_amd64
9-
- darwin_arm64
10-
- linux_amd64
8+
goarch:
9+
- amd64
10+
- arm64
1111

1212
flags:
1313
- -buildvcs=false
1414
- -trimpath
1515

1616
ldflags:
17-
- -s -w
17+
- -X github.com/joshdk/aws-console/cmd.revision={{ .FullCommit }}
18+
- -X github.com/joshdk/aws-console/cmd.timestamp={{ .Date }}
19+
- -X github.com/joshdk/aws-console/cmd.version={{ .Summary }}
1820
- -buildid=
19-
- -X jdk.sh/meta.date={{ .Date }}
20-
- -X jdk.sh/meta.sha={{ .Commit }}
21-
- -X jdk.sh/meta.version={{ .Tag }}
21+
- -s
22+
- -w
2223

2324
env:
2425
- CGO_ENABLED=0
2526

2627
archives:
27-
- id: aws-console
28+
- formats: [tar.gz]
2829
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
2930

3031
release:
3132
name_template: "{{ .Tag }} Release"
3233
prerelease: auto
3334

34-
checksum:
35-
name_template: "checksums.txt"
36-
3735
changelog:
38-
skip: true
36+
disable: true
3937

40-
brews:
41-
- name: aws-console
42-
43-
tap:
44-
owner: joshdk
45-
name: homebrew-tap
46-
token: "{{ .Env.HOMEBREW_GITHUB_TOKEN }}"
38+
checksum:
39+
disable: true
4740

48-
url_template: "https://github.com/joshdk/aws-console/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
41+
homebrew_casks:
42+
- description: Generate a temporary login URL for the AWS Console
43+
homepage: https://github.com/joshdk/aws-console
44+
license: MIT
4945

50-
commit_msg_template: "feat: brew formula update for {{ .ProjectName }} {{ .Tag }}"
5146
commit_author:
5247
name: Josh Komoroske
5348
email: jdkomo@gmail.com
5449

55-
folder: Formula
50+
hooks:
51+
post:
52+
install: |
53+
if OS.mac?
54+
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/{{ .ProjectName }}"]
55+
end
5656
57-
caveats: "Run aws-console --help for usage"
58-
homepage: "https://github.com/joshdk/aws-console"
59-
description: "Generate a temporary login URL for the AWS Console"
60-
license: "MIT"
57+
repository:
58+
owner: joshdk
59+
name: homebrew-tap
6160

62-
test: |
63-
system "#{bin}/aws-console --version"
61+
git:
62+
url: git@github.com:joshdk/homebrew-tap.git
63+
private_key: "{{ .Env.HOMEBREW_DEPLOY_KEY }}"

cmd/command.go

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ package cmd
99
import (
1010
"fmt"
1111
"os"
12+
"strings"
1213
"time"
1314

1415
"github.com/atotto/clipboard"
1516
"github.com/aws/aws-sdk-go-v2/aws"
17+
"github.com/joshdk/buildversion"
1618
"github.com/pkg/browser"
1719
"github.com/spf13/cobra"
18-
"jdk.sh/meta"
1920

2021
"github.com/joshdk/aws-console/console"
2122
"github.com/joshdk/aws-console/credentials"
@@ -225,58 +226,17 @@ func Command() *cobra.Command { //nolint:cyclop,funlen
225226

226227
// Define -A/--user-agent flag.
227228
cmd.Flags().StringVarP(&flags.userAgent, "user-agent", "A",
228-
versionFmt("joshdk/aws-console", " %s (%s)", meta.Version(), meta.ShortSHA()),
229+
buildversion.Template("joshdk/aws-console {{ .Version }}{{- if .ShortRevision }} ({{ .ShortRevision }}){{ end }}"),
229230
"user agent to use for http requests")
230231

231-
cmd.Example = ` Generate a login url for the default profile:
232-
$ aws-console
233-
234-
Generate a login url for the "production" profile:
235-
$ aws-console production
236-
237-
Generate a login url from the output of the aws cli:
238-
$ aws sts assume-role … | aws-console -
239-
240-
Open url with the default browser:
241-
$ aws-console --browser
242-
243-
Redirect to IAM service after logging in:
244-
$ aws-console --location iam
245-
246-
Display a QR code for the login url:
247-
$ aws-console --qr
248-
249-
Save QR code to a file:
250-
$ aws-console --qr > qr.png`
232+
// Set a custom list of examples.
233+
cmd.Example = strings.TrimRight(exampleText, "\n")
251234

252235
// Add a custom usage footer template.
253-
cmd.SetUsageTemplate(cmd.UsageTemplate() + versionFmt(
254-
"\nInfo:\n"+
255-
" https://github.com/joshdk/aws-console\n",
256-
" %s (%s) built on %v\n",
257-
meta.Version(), meta.ShortSHA(), meta.DateFormat(time.RFC3339),
258-
))
236+
cmd.SetUsageTemplate(cmd.UsageTemplate() + "\n" + buildversion.Template(usageTemplate))
259237

260238
// Set a custom version template.
261-
cmd.SetVersionTemplate(versionFmt(
262-
"homepage: https://github.com/joshdk/aws-console\n"+
263-
"author: Josh Komoroske\n"+
264-
"license: MIT\n",
265-
"version: %s\n"+
266-
"sha: %s\n"+
267-
"date: %s\n",
268-
meta.Version(), meta.ShortSHA(), meta.DateFormat(time.RFC3339),
269-
))
239+
cmd.SetVersionTemplate(buildversion.Template(versionTemplate))
270240

271241
return cmd
272242
}
273-
274-
// versionFmt returns the given literal, as well as a formatted string if
275-
// version metadata is set.
276-
func versionFmt(literal, format string, a ...any) string {
277-
if meta.Version() == "" {
278-
return literal
279-
}
280-
281-
return literal + fmt.Sprintf(format, a...)
282-
}

cmd/files/examples.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Generate a login url for the default profile:
2+
$ aws-console
3+
4+
Generate a login url for the "production" profile:
5+
$ aws-console production
6+
7+
Generate a login url from the output of the aws cli:
8+
$ aws sts assume-role … | aws-console -
9+
10+
Open url with the default browser:
11+
$ aws-console --browser
12+
13+
Redirect to IAM service after logging in:
14+
$ aws-console --location iam
15+
16+
Display a QR code for the login url:
17+
$ aws-console --qr
18+
19+
Save QR code to a file:
20+
$ aws-console --qr > qr.png

cmd/files/usage-template.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Info:
2+
https://{{ .Path }}
3+
{{ .Version }}
4+
{{- if .ShortRevision }} ({{ .ShortRevision }}){{ end }}
5+
{{- if .Timestamp }} built on {{ .Timestamp }}{{ end }}

cmd/files/version-template.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
homepage: https://{{ .Path }}
2+
author: Josh Komoroske
3+
license: MIT
4+
version: {{ .Version }}
5+
{{ if .ShortRevision -}}
6+
revision: {{ .ShortRevision }}
7+
{{ end -}}
8+
{{ if .Timestamp -}}
9+
date: {{ .Timestamp }}
10+
{{ end -}}
11+
platform: {{ .OS }}/{{ .Arch}}
12+
runtime: {{ .Runtime }}

cmd/version.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright Josh Komoroske. All rights reserved.
2+
// Use of this source code is governed by the MIT license,
3+
// a copy of which can be found in the LICENSE.txt file.
4+
// SPDX-License-Identifier: MIT
5+
6+
package cmd
7+
8+
import (
9+
_ "embed"
10+
11+
"github.com/joshdk/buildversion"
12+
)
13+
14+
var (
15+
version string
16+
revision string
17+
timestamp string
18+
19+
_ = buildversion.Override(version, revision, timestamp)
20+
21+
//go:embed files/usage-template.tmpl
22+
usageTemplate string
23+
24+
//go:embed files/version-template.tmpl
25+
versionTemplate string
26+
27+
//go:embed files/examples.txt
28+
exampleText string
29+
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ require (
88
github.com/aws/aws-sdk-go-v2/config v1.31.16
99
github.com/aws/aws-sdk-go-v2/credentials v1.18.20
1010
github.com/aws/aws-sdk-go-v2/service/sts v1.39.0
11+
github.com/joshdk/buildversion v0.1.0
1112
github.com/mattn/go-isatty v0.0.20
1213
github.com/mattn/go-sixel v0.0.5
1314
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
1415
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
1516
github.com/spf13/cobra v1.10.1
16-
jdk.sh/meta v0.1.1-0.20211021015548-cff3b930ebd9
1717
)
1818

1919
require (

0 commit comments

Comments
 (0)