Hello everyone, I recently deployed a fresh Gitea and Gitea Actions instance in my home server. I’m developing a tool in Go that has SQLite as one of its dependencies, for this reason I have to enable CGO in my builds, looking around I found something called xgo, apparently this tool has a Go wrapper and will create a docker container to build the cross-compiled binaries.
To not make my story more long, I have created this Actions workflow:
name: Release Abyss
on:
push:
tags: ["*"]
jobs:
build-binary:
name: Build Binary
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@v5
- name: Set up Node
uses: actions/setup-node@v5
with:
node-version: '22.17.0'
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3.3'
- name: Set up Golang
uses: actions/setup-go@v6
with:
go-version: '1.24'
- name: Build binary
run: ./scripts/build.sh
- name: List build artifacts (debug)
run: ls -la build/
- name: Upload binary artifacts
uses: actions/upload-artifact@v3
with:
name: binaries
path: build/
build-push-docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: [build-binary]
steps:
- name: Clone the repository
uses: actions/checkout@v5
- name: Download binary artifacts
uses: actions/download-artifact@v3-node20
with:
name: binaries
path: build/
- name: Login into registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.ACCESS_TOKEN }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
file: Containerfile
context: .
tags: |
${{ secrets.REGISTRY }}/${{ gitea.repository }}:latest
And this is my building script:
#!/bin/sh
set -e
cd frontend
bun install
bun run build
cd ..
# Install xgo
go install src.techknowlogick.com/xgo@latest
xgo --targets=linux/amd64,linux/arm64 --dest=build \
--out=abyss --pkg cmd/api .
Every step is successful except for the xgo one, I tried using an action exclusively for xgo, but I keep getting this issue:
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
Cleaning up build environment...
chown: cannot access '/build/abyss*': No such file or directory
2025/12/11 20:47:09 Failed to cross compile package: exit status 1.
I’m not sure if I need a dind Actions Runner image, but I don’t understand what’s happening with this workflow, I’ve tried options like using Makefiles, doing the command in the pipeline and not in a separate file and I’m getting the same error.
Any help or recommendation will be appreciated, thanks