Skip to content

Commit

Permalink
Add the release job
Browse files Browse the repository at this point in the history
  • Loading branch information
abicky committed Jan 27, 2021
1 parent e9b9663 commit 450f05b
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 19 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/test.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: main
on:
push:
pull_request:
Expand Down Expand Up @@ -32,3 +32,25 @@ jobs:
- run: go fmt ./... && git diff --exit-code -- ':!go.sum'

- run: make test

release:
runs-on: ubuntu-latest
needs: test
if: contains(github.ref, 'tags/v')
steps:
- uses: actions/checkout@v2

- name: Check the version
run: grep -qr "version = \"$(git tag --points-at HEAD | sed 's/^v//')\"" cmd

- run: git fetch --prune --unshallow
- uses: actions/setup-go@v1
with:
go-version: 1.15
- uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
# Use a custom token instead of GITHUB_TOKEN for the homebrew tap
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/CREDITS
/bin
/dist
46 changes: 31 additions & 15 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
- env GO111MODULE=off GOBIN=/tmp/bin go get github.com/Songmu/gocredits/cmd/gocredits
- /tmp/bin/gocredits -w .
builds:
- env:
- CGO_ENABLED=0
- env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
ldflags:
- -s -w -X github.com/abicky/ecsmec/cmd.revision={{.ShortCommit}}
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
- # Exclude the version to download the latest version via https://github.com/abicky/ecsmec/releases/latest/download/$archive_name
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
files:
- LICENSE
- README.md
- CREDITS
format_overrides:
- goos: windows
format: zip
wrap_in_directory: true
brews:
- tap:
owner: abicky
name: homebrew-tools
homepage: "https://github.com/abicky/ecsmec"
description: "A CLI tool for Amazon ECS that provides some commands to execute bothersome operations"
folder: Formula
test: |
system "#{bin}/ecsmec --version"
checksum:
name_template: 'checksums.txt'
snapshot:
Expand All @@ -24,5 +40,5 @@ changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^docs:'
- '^test:'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ clean:

.PHONY: install
install:
go install
go install -ldflags "-s -w -X github.com/abicky/ecsmec/cmd.revision=$(shell git rev-parse --short HEAD)"

.PHONY: test
test:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ecsmec

![](https://github.com/abicky/ecsmec/workflows/test/badge.svg?branch=master)
![](https://github.com/abicky/ecsmec/workflows/main/badge.svg?branch=master)

`ecsmec` is a CLI tool for Amazon ECS that provides some commands to execute bothersome operations.
For example, if you manage your ECS clusters with a auto scaling group and want to replace all the container instances with new ones, you have to launch new instances, drain old instances, and so on. What a pain!
Expand Down
10 changes: 9 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import (
"golang.org/x/xerrors"
)

const version = "0.1.0"

// This variable should be overwritten by -ldflags
var revision = "HEAD"

var rootCmd = &cobra.Command{
Use: "ecsmec",
Short: "A CLI tool for Amazon ECS that provides some commands to execute bothersome operations",
Long: "A CLI tool for Amazon ECS that provides some commands to execute bothersome operations",
SilenceErrors: true,
SilenceUsage: true,
Version: "0.1.0",
Version: version,
}

type runtimeError struct {
Expand Down Expand Up @@ -50,6 +55,9 @@ func Execute() int {
}

func init() {
rootCmd.SetVersionTemplate(fmt.Sprintf(
`{{with .Name}}{{printf "%%s " .}}{{end}}{{printf "version %%s" .Version}} (revision %s)
`, revision))
rootCmd.PersistentFlags().String("profile", "", "An AWS profile name in your credential file")
rootCmd.PersistentFlags().String("region", "", "The AWS region")
}
Expand Down

0 comments on commit 450f05b

Please sign in to comment.