Skip to content

Commit

Permalink
makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Razikus committed Apr 26, 2024
1 parent 928d34e commit fb666df
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 60 deletions.
72 changes: 12 additions & 60 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,6 @@ jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # Define operating systems in the matrix
go-version: [1.22]
include:
# Standard architectures
- os: ubuntu-latest
arch: amd64
goos: linux
goarch: amd64
binary-suffix: linux-amd64
- os: ubuntu-latest
arch: arm64
goos: linux
goarch: arm64
binary-suffix: linux-arm64
- os: windows-latest # Specify the correct OS for this architecture
arch: amd64
goos: windows
goarch: amd64
binary-suffix: windows-amd64
# Raspberry Pi architectures
- os: ubuntu-latest
arch: armv6
goos: linux
goarch: arm
goarm: 6
binary-suffix: linux-armv6 # Raspberry Pi Zero
- os: ubuntu-latest
arch: armv7
goos: linux
goarch: arm
goarm: 7
binary-suffix: linux-armv7 # Raspberry Pi 3
- os: ubuntu-latest
arch: arm64
goos: linux
goarch: arm64
binary-suffix: linux-arm64 # Raspberry Pi 4

steps:
- name: Check out code
Expand All @@ -58,31 +19,22 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Set up Go environment variables
run: |
echo "GOOS=${{ matrix.goos }}" >> $GITHUB_ENV
echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV
if [ "${{ matrix.goarch }}" == "arm" ]; then
echo "GOARM=${{ matrix.goarm }}" >> $GITHUB_ENV
fi
go-version: 1.22

- name: Build
run: cd src && go build -v -o sshtows-${{ matrix.binary-suffix }} main.go
run: cd src && make all


- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: sshtows-${{ matrix.binary-suffix }}
path: src/sshtows-${{ matrix.binary-suffix }}

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
sshtows-${{ matrix.binary-suffix }}
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
path: src/bin/*

# - name: Create Release
# if: startsWith(github.ref, 'refs/tags/')
# uses: softprops/action-gh-release@v2
# with:
# files: |
# sshtows-${{ matrix.binary-suffix }}
# env:
# GITHUB_TOKEN: ${{ secrets.TOKEN }}
40 changes: 40 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
VERSION=dev
BINARY_NAME=$(VERSION)_ssh2ws

amd64:
GOOS=linux GOARCH=amd64 go build -o bin/$(BINARY_NAME)_amd64 main.go

amd64-static:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o bin/$(BINARY_NAME)_amd64_static main.go

arm32:
GOOS=linux GOARCH=arm go build -o bin/$(BINARY_NAME)_arm32 main.go

arm32-static:
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -installsuffix cgo -o bin/$(BINARY_NAME)_arm32_static main.go

arm64:
GOOS=linux GOARCH=arm64 go build -o bin/$(BINARY_NAME)_arm64 main.go

arm64-static:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -o bin/$(BINARY_NAME)_arm64_static main.go

windows:
GOOS=windows GOARCH=amd64 go build -o bin/$(BINARY_NAME).exe main.go

windows-static:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -a -installsuffix cgo -o bin/$(BINARY_NAME)_static.exe main.go

darwin:
GOOS=darwin GOARCH=amd64 go build -o bin/$(BINARY_NAME)_darwin main.go

darwin-static:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -installsuffix cgo -o bin/$(BINARY_NAME)_darwin_static main.go

darwinarm64:
GOOS=darwin GOARCH=arm64 go build -o bin/$(BINARY_NAME)_darwinarm64 main.go

darwinarm64-static:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -installsuffix cgo -o bin/$(BINARY_NAME)_darwinarm64_static main.go

all: amd64 amd64-static arm32 arm32-static arm64 arm64-static windows windows-static darwin darwin-static darwinarm64 darwinarm64-static

0 comments on commit fb666df

Please sign in to comment.