Skip to content

Commit

Permalink
build improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ef0xa committed Apr 12, 2024
1 parent 8dd71c2 commit 4beaeda
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 40 deletions.
53 changes: 28 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: 1.22

- name: Gets latest created release info
id: release
uses: jossef/[email protected]
Expand All @@ -29,12 +28,16 @@ jobs:

- name: build
run: |
env GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.Version=${{ steps.release.outputs.tag_name }}'" -o bin/runpodctl-linux-amd64 .
env GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'main.Version=${{ steps.release.outputs.tag_name }}'" -o bin/runpodctl-darwin-amd64 .
env GOOS=darwin GOARCH=arm64 go build -ldflags "-X 'main.Version=${{ steps.release.outputs.tag_name }}'" -o bin/runpodctl-darwin-arm64 .
env GOOS=windows GOARCH=amd64 go build -ldflags "-X 'main.Version=${{ steps.release.outputs.tag_name }}'" -o bin/runpodctl-windows-amd64.exe .
# env GOOS=linux GOARCH=arm64 go build -ldflags "-X 'main.Version=${{ steps.release.outputs.tag_name }}'" -o bin/runpodctl-linux-arm64 .
# env GOOS=android GOARCH=amd64 go build -ldflags "-X 'main.Version=${{ steps.release.outputs.tag_name }}'" -o bin/runpodctl-android-amd64 .
echo '${{ steps.release.outputs.tag_name }}' > VERSION
env GOOS=android GOARCH=amd64 go build -o bin/runpodctl-android-amd64 .
env GOOS=darwin GOARCH=amd64 go build -o bin/runpodctl-darwin-amd64 .
env GOOS=darwin GOARCH=arm64 go build -o bin/runpodctl-darwin-arm64 .
env GOOS=linux GOARCH=amd64 go build -o bin/runpodctl-linux-amd64 .
env GOOS=linux GOARCH=arm64 go build -o bin/runpodctl-linux-arm64 .
env GOOS=windows GOARCH=amd64 go build -o bin/runpodctl-windows-amd64.exe .
strip bin/* || true # strip the binary's DWARF debug info, where applicable
./tools/upx --best bin/* || true # compress the binaries
- name: upload linux amd64 release binary
uses: actions/[email protected]
Expand Down Expand Up @@ -83,21 +86,21 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
VERSION: ${{ steps.release.outputs.tag_name }}
# - name: upload linux arm64 release binary
# uses: actions/[email protected]
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ steps.release.outputs.upload_url }}
# asset_path: bin/runpodctl-linux-arm64
# asset_name: runpodctl-linux-arm64
# asset_content_type: application/octet-stream
# - name: upload android amd64 release binary
# uses: actions/[email protected]
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# upload_url: ${{ steps.release.outputs.upload_url }}
# asset_path: bin/runpodctl-android-amd64
# asset_name: runpodctl-android-amd64
# asset_content_type: application/octet-stream
- name: upload linux arm64 release binary
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: bin/runpodctl-linux-arm64
asset_name: runpodctl-linux-arm64
asset_content_type: application/octet-stream
- name: upload android amd64 release binary
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: bin/runpodctl-android-amd64
asset_name: runpodctl-android-amd64
asset_content_type: application/octet-stream
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
bin/
main
.vscode/
vendor/
vendor/

## auto generated file during make and release
version
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ builds:
goos:
- darwin
- linux
- android
- windows
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
flags:
- -mod=mod
ldflags:
- -X 'main.Version={{ .Env.VERSION }}'

release:
prerelease: auto
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${{ steps.release.outputs.tag_name }}
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package main

import "github.com/runpod/runpodctl/cmd"
import (
_ "embed"

"github.com/runpod/runpodctl/cmd"
)

//go:embed version

Check failure on line 9 in main.go

View workflow job for this annotation

GitHub Actions / build

pattern version: no matching files found
var Version string

func main() {
Expand Down
38 changes: 27 additions & 11 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
.PHONY: proto

local:
go build -ldflags "-X 'main.Version=1.0.0'" -o bin/runpodctl .

linux:
env GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.Version=1.0.0'" -o bin/runpodctl .
mac:
env GOOS=darwin GOARCH=arm64 go build -ldflags "-X 'main.Version=1.0.0'" -o bin/runpodctl .
windows:
env GOOS=windows GOARCH=amd64 go build -ldflags "-X 'main.Version=1.0.0'" -o bin/runpodctl.exe .
mac-amd64:
env GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'main.Version=1.0.0'" -o bin/runpodctl .
local: version
go build -ldflags -o bin/runpodctl .

release: buildall strip compress

lint:
buildall: android-arm64 linux-amd64 darwin-arm64 windows-amd64 windows-arm64 darwin-amd64

compress:
upx --best bin/* || true
strip:
strip bin/* || true


android-arm64: version
env GOOS=android GOARCH=arm64 go build -o bin/runpodctl-android-arm64 .
linux-amd64: version
env GOOS=linux GOARCH=amd64 go build -o bin/runpodctl-linux-amd64 .
darwin-arm64: version
env GOOS=darwin GOARCH=arm64 go build -o bin/runpodctl-darwin-arm64 .
windows-amd64: version
env GOOS=windows GOARCH=amd64 go build -o bin/runpodctl-windows-amd64.exe .
windows-arm64: version
env GOOS=windows GOARCH=arm64 go build -o bin/runpodctl-windows-arm64.exe .
darwin-amd64: version
env GOOS=darwin GOARCH=amd64 go build -o bin/runpodctl-darwin-amd64 .

lint: version
golangci-lint run
version:
echo "1.0.0-test" > VERSION
Binary file added tools/upx
Binary file not shown.

0 comments on commit 4beaeda

Please sign in to comment.