This commit is contained in:
@@ -1,39 +1,37 @@
|
|||||||
name: Build Go Multi-Platform
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ main ]
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Install Latest Go
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: 'stable'
|
|
||||||
|
|
||||||
- name: Build for Windows amd64
|
|
||||||
run: |
|
run: |
|
||||||
GOOS=windows GOARCH=amd64 go build -o build/myapp-windows-amd64.exe ./...
|
GO_VERSION=$(curl -s https://go.dev/VERSION?m=text)
|
||||||
|
wget https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz
|
||||||
|
sudo rm -rf /usr/local/go
|
||||||
|
sudo tar -C /usr/local -xzf ${GO_VERSION}.linux-amd64.tar.gz
|
||||||
|
export PATH=/usr/local/go/bin:$PATH
|
||||||
|
echo "Go version installed:"
|
||||||
|
go version
|
||||||
|
|
||||||
- name: Build for Linux amd64
|
- name: Checkout code
|
||||||
run: |
|
run: git clone https://your.gitea.server/user/repo.git .
|
||||||
GOOS=linux GOARCH=amd64 go build -o build/myapp-linux-amd64 ./...
|
|
||||||
|
|
||||||
- name: Build for Linux ARM64
|
- name: Build for Linux/Windows (amd64 + arm)
|
||||||
run: |
|
run: |
|
||||||
GOOS=linux GOARCH=arm64 go build -o build/myapp-linux-arm64 ./...
|
mkdir -p build
|
||||||
|
for GOOS in linux windows; do
|
||||||
|
for GOARCH in amd64 arm64; do
|
||||||
|
OUT=build/app-${GOOS}-${GOARCH}
|
||||||
|
[[ $GOOS == "windows" ]] && OUT="${OUT}.exe"
|
||||||
|
GOOS=$GOOS GOARCH=$GOARCH go build -o $OUT .
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
- name: Build for Linux ARMv6 (Raspberry Pi)
|
- name: List artifacts
|
||||||
run: |
|
run: ls -lh build
|
||||||
GOOS=linux GOARCH=arm GOARM=6 go build -o build/myapp-linux-armv6 ./...
|
|
||||||
|
|
||||||
- name: List build artifacts
|
|
||||||
run: |
|
|
||||||
ls -lh build
|
|
||||||
|
Reference in New Issue
Block a user