Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Docker Image

on:
push:
branches:
- main
tags:
- v*
workflow_dispatch:

permissions:
contents: read
packages: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:22.04

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl unzip bash \
&& rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://raw.githubusercontent.com/pixelib/goomba/refs/heads/main/install.sh | bash

ENV PATH="/root/.goomba/bin:$PATH"
WORKDIR /work

COPY scripts/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
72 changes: 72 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Goomba Build
branding:
icon: package
color: blue
description: Build Go projects with Goomba across platforms and architectures.
inputs:
source-dir:
description: Path to the Go module to build.
required: false
default: .
platforms:
description: Comma-separated list of platforms (linux, macos, windows).
required: true
default: linux,macos,windows
arch:
description: Comma-separated list of architectures (x64, arm64).
required: true
default: x64,arm64
cgo-enabled:
description: Enable CGO support.
required: false
default: "false"
go-args:
description: Additional go build args passed via --go-args.
required: false
default: ""
runs:
using: composite
steps:
- name: Install Goomba (macOS/Linux)
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
curl -fsSL https://raw.githubusercontent.com/pixelib/goomba/refs/heads/main/install.sh | bash
echo "$HOME/.goomba/bin" >> "$GITHUB_PATH"

- name: Install Goomba (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
irm https://raw.githubusercontent.com/pixelib/goomba/refs/heads/main/install.ps1 | iex
"$env:LOCALAPPDATA\Programs\goomba" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Build with Goomba (macOS/Linux)
if: runner.os != 'Windows'
shell: bash
working-directory: ${{ inputs.source-dir }}
run: |
set -euo pipefail
args=(build --no-tui --platforms "${{ inputs.platforms }}" --arch "${{ inputs.arch }}")
if [ "${{ inputs.cgo-enabled }}" = "true" ]; then
args+=(--cgo-enabled)
fi
if [ -n "${{ inputs.go-args }}" ]; then
args+=(--go-args "${{ inputs.go-args }}")
fi
goomba "${args[@]}"

- name: Build with Goomba (Windows)
if: runner.os == 'Windows'
shell: pwsh
working-directory: ${{ inputs.source-dir }}
run: |
$args = @("build", "--no-tui", "--platforms", "${{ inputs.platforms }}", "--arch", "${{ inputs.arch }}")
if ("${{ inputs.cgo-enabled }}" -eq "true") {
$args += "--cgo-enabled"
}
if ("${{ inputs.go-args }}") {
$args += @("--go-args", "${{ inputs.go-args }}")
}
& goomba @args
22 changes: 22 additions & 0 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

source_dir="${GOOMBA_SOURCE_DIR:-.}"
platforms="${GOOMBA_PLATFORMS:-linux,macos,windows}"
arch="${GOOMBA_ARCH:-x64,arm64}"
cgo_enabled="${GOOMBA_CGO_ENABLED:-false}"
go_args="${GOOMBA_GO_ARGS:-}"

if [ -n "$source_dir" ]; then
cd "$source_dir"
fi

args=(build --no-tui --platforms "$platforms" --arch "$arch")
if [ "$cgo_enabled" = "true" ]; then
args+=(--cgo-enabled)
fi
if [ -n "$go_args" ]; then
args+=(--go-args "$go_args")
fi

goomba "${args[@]}"
36 changes: 36 additions & 0 deletions scripts/test-dockersetup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail

script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
repo_root=$(cd "$script_dir/.." && pwd)

dockerfile="$repo_root/Dockerfile"
image_name="${GOOMBA_CI_IMAGE:-goomba-ci-local:latest}"
project_dir="$repo_root/_testproject/cgo"

if [[ ! -f "$dockerfile" ]]; then
echo "Dockerfile not found at $dockerfile" >&2
exit 1
fi

if [[ ! -d "$project_dir" ]]; then
echo "Test project not found at $project_dir" >&2
exit 1
fi

echo ">> Building CI image: $image_name"
if docker buildx version >/dev/null 2>&1; then
docker buildx build --load -t "$image_name" -f "$dockerfile" "$repo_root"
else
echo "docker buildx not available; falling back to docker build" >&2
docker build -t "$image_name" -f "$dockerfile" "$repo_root"
fi

echo ">> Running goomba build in _testproject/cgo"
docker run --rm \
-e GOOMBA_SOURCE_DIR=/work/_testproject/cgo \
-e GOOMBA_PLATFORMS=linux \
-e GOOMBA_ARCH=x64 \
-e GOOMBA_CGO_ENABLED=true \
-v "$repo_root":/work \
"$image_name"
Loading