Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0e8864d4da | ||
![]() |
490fae7d5b | ||
![]() |
ca9d8af13f | ||
![]() |
2537d5f1c8 | ||
![]() |
79ad631494 | ||
![]() |
a0046e1848 |
@@ -30,29 +30,53 @@ jobs:
|
||||
ext: ""
|
||||
|
||||
steps:
|
||||
- name: Install zip
|
||||
run: |
|
||||
apt-get update && apt-get install -y zip
|
||||
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.24.5'
|
||||
- name: Ensure latest Go is installed in /data/go
|
||||
run: |
|
||||
export GOROOT=/data/go/go
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export GOCACHE=/data/gocache
|
||||
export GOMODCACHE=/data/gomodcache
|
||||
mkdir -p $GOCACHE $GOMODCACHE
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
if [ ! -x "$GOROOT/bin/go" ]; then
|
||||
echo "Go not found in $GOROOT, downloading latest stable..."
|
||||
|
||||
GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1)
|
||||
echo "Latest version is $GO_VERSION"
|
||||
|
||||
mkdir -p /data/go
|
||||
curl -sSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tar.gz
|
||||
tar -C /data/go -xzf /tmp/go.tar.gz
|
||||
else
|
||||
echo "Using cached Go from $GOROOT"
|
||||
fi
|
||||
|
||||
go version
|
||||
|
||||
- name: Download Go dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Build binaries
|
||||
run: |
|
||||
export GOROOT=/data/go/go
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export GOCACHE=/data/gocache
|
||||
export GOMODCACHE=/data/gomodcache
|
||||
mkdir -p $GOCACHE $GOMODCACHE
|
||||
go mod download
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
export GOROOT=/data/go/go
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export GOCACHE=/data/gocache
|
||||
export GOMODCACHE=/data/gomodcache
|
||||
mkdir -p $GOCACHE $GOMODCACHE
|
||||
|
||||
OUTPUT="bin/${APP_NAME}-${{ matrix.os }}-${{ matrix.arch }}"
|
||||
if [ -n "${{ matrix.arm_version }}" ]; then
|
||||
OUTPUT="${OUTPUT}v${{ matrix.arm_version }}"
|
||||
@@ -63,8 +87,12 @@ jobs:
|
||||
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
|
||||
shell: bash
|
||||
|
||||
- name: Upload artifacts
|
||||
- name: Zip artifact
|
||||
run: |
|
||||
zip bin/${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.zip bin/${{ env.APP_NAME }}-*
|
||||
|
||||
- name: Upload zipped artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.arm_version && format('v{0}', matrix.arm_version) || '' }}${{ matrix.ext }}
|
||||
path: bin/${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.arm_version && format('v{0}', matrix.arm_version) || '' }}${{ matrix.ext }}
|
||||
name: ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
|
||||
path: bin/${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.zip
|
||||
|
Reference in New Issue
Block a user