Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuo48 committed Feb 4, 2023
1 parent 517d288 commit e12349b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/[email protected]
with:
go-version: "^1.20"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@@v4.2.0
with:
version: latest
args: release --rm-dist
env:
# To upload homebrew formula to other repos,
# need to set the dedicated token having enough permissions
# https://github.com/goreleaser/goreleaser/issues/982
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
project_name: ecsource
before:
hooks:
- go mod tidy
builds:
- main: .
binary: ecsource
ldflags:
- -s -w
- -X github.com/tatsuo48/ecsource/main.Version={{.Version}}
- -X github.com/tatsuo48/ecsource/main.Revision={{.ShortCommit}}
env:
- CGO_ENABLED=0
archives:
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
replacements:
darwin: darwin
linux: linux
windows: windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
release:
prerelease: auto

brews:
- tap:
owner: tatsuo48
name: homebrew-tap
folder: Formula
homepage: https://github.com/tatsuo48/ecsource
description: ECS Task Definition tool to display resources such as CPU, memory, and memory reservations in an easy-to-read format.
skip_upload: auto
test: |
system "#{bin}/ecsource", "-v"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build
.PHONY: build install clean

build:
@echo "Building..."
Expand Down
17 changes: 16 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
"github.com/olekukonko/tablewriter"
)

// These variables are set in build step
var (
Version = "unset"
Revision = "unset"
)

// Generated by https://quicktype.io

type TaskDefinitionJson struct {
Expand Down Expand Up @@ -92,7 +98,16 @@ type Secret struct {

func main() {
if len(os.Args) < 2 {
log.Fatal("ファイル名を指定してくだい")
log.Fatal("please specify file path")
}
if os.Args[1] == "-h" || os.Args[1] == "--help" {
fmt.Printf("Usage: %s [file path]", os.Args[0])
os.Exit(0)
}
if os.Args[1] == "--version" || os.Args[1] == "-v" {
fmt.Printf("version: %s\n", Version)
fmt.Printf("revision: %s\n", Revision)
os.Exit(0)
}
src, err := os.ReadFile(os.Args[1])
if err != nil {
Expand Down

0 comments on commit e12349b

Please sign in to comment.