Skip to content

Commit c7342df

Browse files
committed
Add goreleaser
1 parent 3f4554c commit c7342df

6 files changed

Lines changed: 99 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [main, master]
5+
branches: [master]
66
pull_request:
77

88
jobs:

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
goreleaser:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
cache: true
22+
23+
- uses: goreleaser/goreleaser-action@v6
24+
with:
25+
version: "~> v2"
26+
args: release --clean
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/cshell
2+
/dist/
23
*.out

.goreleaser.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# GoReleaser configuration — https://goreleaser.com
2+
version: 2
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
8+
builds:
9+
- id: cshell
10+
main: .
11+
binary: cshell
12+
env:
13+
- CGO_ENABLED=0
14+
flags:
15+
- -trimpath
16+
ldflags:
17+
- -s -w -X main.version={{ .Version }}
18+
goos:
19+
- linux
20+
- darwin
21+
goarch:
22+
- amd64
23+
- arm64
24+
25+
archives:
26+
- id: cshell
27+
formats: [tar.gz]
28+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
29+
30+
checksum:
31+
name_template: checksums.txt
32+
33+
changelog:
34+
use: github
35+
sort: asc
36+
filters:
37+
exclude:
38+
- "^docs:"
39+
- "^test:"
40+
- "^ci:"
41+
- "^chore:"
42+
43+
release:
44+
draft: false
45+
prerelease: auto

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,27 @@ hands the session off to the AWS `session-manager-plugin`.
1111
1212
## Install
1313

14+
Download a prebuilt binary for your platform (Linux/macOS, x86-64/arm64) from the
15+
[Releases](https://github.com/avoidik/cshell/releases) page, e.g.:
16+
17+
```sh
18+
tar -xzf cshell_$(uname -s | tr A-Z a-z)_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
19+
sudo mv cshell /usr/local/bin/
20+
```
21+
22+
Or with Go:
23+
1424
```sh
15-
go install github.com/avoidik/cshell@latest
25+
go install github.com/avoidik/cshell@latest # or: go build -o cshell .
1626
```
1727

18-
Or build locally:
28+
## Releasing
29+
30+
Releases are built by [GoReleaser](https://goreleaser.com) on tag push (CI builds
31+
Linux/macOS × amd64/arm64 archives + checksums):
1932

2033
```sh
21-
go build -o cshell .
34+
git tag v0.1.0 && git push origin v0.1.0
2235
```
2336

2437
## Requirements

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import (
1919
// envName is the name used for environments this tool creates with a VPC.
2020
const envName = "cshell"
2121

22+
// version is overridden at build time via -ldflags "-X main.version=…".
23+
var version = "dev"
24+
2225
func main() {
2326
if len(os.Args) < 2 {
2427
usage()
@@ -30,6 +33,10 @@ func main() {
3033
usage()
3134
return
3235
}
36+
if cmd == "version" || cmd == "-v" || cmd == "--version" {
37+
fmt.Println("cshell", version)
38+
return
39+
}
3340

3441
fs := flag.NewFlagSet(cmd, flag.ExitOnError)
3542
profile := fs.String("profile", os.Getenv("AWS_PROFILE"), "AWS named profile to use")
@@ -281,6 +288,7 @@ Commands:
281288
create Create a CloudShell environment
282289
delete Delete a CloudShell environment
283290
vpcs List VPCs (or subnets + security groups with -vpc-id)
291+
version Print the cshell version
284292
285293
Common flags:
286294
-profile <name> AWS named profile (default: $AWS_PROFILE)

0 commit comments

Comments
 (0)