Skip to content

Commit

Permalink
windows build with .exe extension
Browse files Browse the repository at this point in the history
  • Loading branch information
godsarmy committed Jan 5, 2025
1 parent e8559c1 commit d73fb5a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu, windows, darwin]
os: [ubuntu-latest, windows-latest, MacOS-latest]
go: [1.22]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -27,11 +27,11 @@ jobs:

- name: Build
run: |
make build OS=${{ matrix.os }} ARCH=amd64
make build ARCH=amd64
- name: Test
run: |
if [[ "${{ matrix.os }}" == "windows" ]]; then
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "Skip gofmt check on windows"
else
gofmt -d */*.go
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Release Binaries

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
arch: amd64
extension: ""
- os: linux
arch: arm64
extension: ""
- os: darwin
arch: amd64
extension: ""
- os: darwin
arch: arm64
extension: ""
- os: windows
arch: amd64
extension: ".exe"
- os: windows
arch: arm64
extension: ".exe"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.22'
- name: Build binaries
run: |
make build OS=${{ matrix.os }} ARCH=${{ matrix.arch }}
- name: Upload release assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: bin
asset_name: |
beanstalk-cli.${{ matrix.os }}.${{ matrix.arch }}${{ matrix.extension }}
asset_content_type: application/octet-stream
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ ifndef GOARCH
MACHINE=$(shell uname -m)
ifeq ($(MACHINE), x86_64)
GOARCH := amd64
GOEXT :=
else ifeq ($(MACHINE), i386)
GOARCH := i386
GOEXT :=
else ifeq ($(MACHINE), arm)
GOARCH := arm64
GOEXT := .exe
endif
endif
# Set build targets based on OS
Expand All @@ -26,14 +29,19 @@ GO_BUILD := $(GO) build $(EXTRA_FLAGS) -ldflags "$(LDFLAGS_COMMON)"

.PHONY: all
build: beanstalk-cli
mkdir -p bin
cp -f $< bin/$<.$(GOARCH).$(GOOS)$(GOEXT)

beanstalk-cli: cmd/main.go cmd/functions.go
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD) -o $@.$(GOARCH).$(GOOS) $^
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD) -o $@ $^

format:
gofmt -w */*.go
golines -w */*.go

.PHONY: all
clean:
rm -rf beanstalk-cli.*
rm -rf beanstalk-cli

superclean: clean
rm -rf bin/

0 comments on commit d73fb5a

Please sign in to comment.