Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the goreleaser for installation of Mac, Linux, and Windows #73

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 16 additions & 27 deletions .github/workflows/dispatch_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ on:
workflow_dispatch:
inputs:
version:
description: 'enter version(x.y.z)'
description: "enter version(x.y.z)"
required: true
default: '0.0.0'
default: "0.0.0"
container_arch:
type: choice
description: 'choose container architecture'
description: "choose container architecture"
default: linux/amd64
options:
- "linux/amd64"
- "linux/amd64,linux/arm64"
- "linux/amd64"
- "linux/amd64,linux/arm64"

env:
ARCH: ${{ github.event.inputs.container_arch }}
Expand Down Expand Up @@ -46,37 +46,26 @@ jobs:
author_name: Github Action Slack

build:
needs: tagging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.1'
go-version: "1.23.1"

- name: Build for all platforms
run: |
# macOS (Intel, Apple Silicon)
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/cfctl-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/cfctl-darwin-arm64

# Linux (64bit, ARM)
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/cfctl-linux-amd64
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o dist/cfctl-linux-arm64

# Windows (64bit)
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/cfctl-windows-amd64.exe

- name: Create Release
uses: softprops/action-gh-release@v1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
files: |
dist/cfctl-darwin-amd64
dist/cfctl-darwin-arm64
dist/cfctl-linux-amd64
dist/cfctl-linux-arm64
dist/cfctl-windows-amd64.exe
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Notice when job fails
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea

dist/
46 changes: 46 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 2

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
ldflags:
- -s -w

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
format_overrides:
- goos: windows
format: zip

brews:
- repository:
owner: cloudforet-io
name: homebrew-tap
token: "{{ .Env.GITHUB_TOKEN }}"
homepage: "https://github.com/cloudforet-io/cfctl"
description: "Command-line interface for SpaceONE"
license: "Apache-2.0"
test: |
system "#{bin}/cfctl version"
install: |
bin.install "cfctl"
Loading