Add native linux/win binaries to the pipeline
Switch the builder image to rust:1-bookworm — bevy's native linux build needs glibc + alsa/udev, which does not build against musl — and add the x86_64-pc-windows-gnu target with mingw-w64 for the windows cross-compile (linker set from the Makefile, no per-repo .cargo/config). Mac stays out: darwin needs osxcross, same as the ebitengine mac plan. Builder steps pull the image on every run so :latest updates reach the runner. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,16 +6,20 @@ projects, in the same spirit as
|
|||||||
[godot-tools](../godot-tools).
|
[godot-tools](../godot-tools).
|
||||||
|
|
||||||
- `example-makefile.make` — project Makefile: local dev targets
|
- `example-makefile.make` — project Makefile: local dev targets
|
||||||
(`build`, `run`, `wasm`, `export`, `watch`, `clean`) plus the
|
(`build`, `run`, `wasm`, `export`, `binaries`, `watch`, `clean`)
|
||||||
Woodpecker pipeline targets (`ci-version`, `ci-export`, `ci-upload`,
|
plus the Woodpecker pipeline targets (`ci-version`, `ci-export`,
|
||||||
`ci-update`).
|
`ci-binaries`, `ci-upload`, `ci-update`).
|
||||||
- `example-woodpecker.yaml` — Woodpecker pipeline: version → build
|
- `example-woodpecker.yaml` — Woodpecker pipeline: version → build
|
||||||
(Rust, `wasm32-unknown-unknown` target + `wasm-bindgen` in the
|
(Rust, `wasm32-unknown-unknown` target + `wasm-bindgen` in the
|
||||||
`git.teletypegames.org/internal/bevy-builder` image) → upload (scp to the
|
`git.teletypegames.org/internal/bevy-builder` image) → binaries
|
||||||
droparea) → update (calls the teletypegames `/update` endpoint with
|
(native linux-x64 + mingw win-x64) → upload (scp to the droparea) →
|
||||||
|
update (calls the teletypegames `/update` endpoint with
|
||||||
`platform=bevy`).
|
`platform=bevy`).
|
||||||
- `builder.Dockerfile` — the CI builder image: `rust:1-alpine` with
|
- `builder.Dockerfile` — the CI builder image: `rust:1-bookworm`
|
||||||
the wasm target, the wasm-bindgen CLI and make/zip/curl baked in.
|
(glibc — bevy's native linux build needs alsa/udev, which does not
|
||||||
|
build against musl) with the wasm + `x86_64-pc-windows-gnu`
|
||||||
|
targets, mingw-w64, the wasm-bindgen CLI and make/zip/curl baked
|
||||||
|
in.
|
||||||
- `example-tasks.json` — VS Code `.vscode/tasks.json` with the common
|
- `example-tasks.json` — VS Code `.vscode/tasks.json` with the common
|
||||||
dev tasks: **Run** (`cargo run`, default build task, `Cmd+Shift+B`),
|
dev tasks: **Run** (`cargo run`, default build task, `Cmd+Shift+B`),
|
||||||
**Build & Run**, **Build WASM** and **Make build**.
|
**Build & Run**, **Build WASM** and **Make build**.
|
||||||
@@ -49,9 +53,30 @@ Local WASM builds additionally need
|
|||||||
`rustup target add wasm32-unknown-unknown` and the `wasm-bindgen` CLI
|
`rustup target add wasm32-unknown-unknown` and the `wasm-bindgen` CLI
|
||||||
(`cargo install wasm-bindgen-cli --version 0.2.100`).
|
(`cargo install wasm-bindgen-cli --version 0.2.100`).
|
||||||
|
|
||||||
The pipeline uploads `$(PROJECT)-$(VERSION).html.zip` to the droparea,
|
The pipeline uploads `$(PROJECT)-$(VERSION).html.zip` and the native
|
||||||
then triggers
|
binary zips (`-win-x64.zip`, `-linux-x64.zip`) to the droparea, then
|
||||||
`/update?platform=bevy&name=$(PROJECT)&version=$(VERSION)`.
|
triggers `/update?platform=bevy&name=$(PROJECT)&version=$(VERSION)`.
|
||||||
|
The API's `BinaryAttachment` concern picks up the
|
||||||
|
`<name>-<version>-<slug>.zip` files automatically and registers them
|
||||||
|
as `win_x64` / `linux_x64` release assets.
|
||||||
|
|
||||||
|
## Native binaries
|
||||||
|
|
||||||
|
`make binaries VERSION=x.y` builds:
|
||||||
|
|
||||||
|
- **linux-x64** — a regular `cargo build --release` in the
|
||||||
|
debian-based builder; the binary links against the builder's glibc
|
||||||
|
and the usual desktop libs (alsa, udev).
|
||||||
|
- **win-x64** — mingw-w64 cross-compile via the
|
||||||
|
`x86_64-pc-windows-gnu` target; the linker is set from the
|
||||||
|
Makefile (`CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER`), no
|
||||||
|
per-repo `.cargo/config` needed.
|
||||||
|
- **mac** — not built here: cgo-style native cross-compilation to
|
||||||
|
darwin needs osxcross, the same (planned) toolchain as the
|
||||||
|
ebitengine mac targets.
|
||||||
|
|
||||||
|
If the project has an `assets/` directory it is packaged next to the
|
||||||
|
binary — bevy loads it at runtime, it is not embedded.
|
||||||
|
|
||||||
## Builder image
|
## Builder image
|
||||||
|
|
||||||
|
|||||||
+15
-5
@@ -2,10 +2,16 @@
|
|||||||
# wasm32-unknown-unknown target and the wasm-bindgen CLI preinstalled,
|
# wasm32-unknown-unknown target and the wasm-bindgen CLI preinstalled,
|
||||||
# so the pipeline's build step does not download them on every run.
|
# so the pipeline's build step does not download them on every run.
|
||||||
#
|
#
|
||||||
|
# Debian-based (glibc) rather than alpine: the native linux binary needs
|
||||||
|
# glibc + alsa/udev dev libs (wgpu/winit), which bevy cannot build against
|
||||||
|
# musl. The windows binary is cross-compiled with mingw-w64
|
||||||
|
# (x86_64-pc-windows-gnu target). Mac is not cross-compiled here — that
|
||||||
|
# is the same osxcross story as the ebitengine mac targets.
|
||||||
|
#
|
||||||
# WASM_BINDGEN_VERSION must match the `wasm-bindgen` crate version pinned
|
# WASM_BINDGEN_VERSION must match the `wasm-bindgen` crate version pinned
|
||||||
# in the game repos' Cargo.toml (see README) — rebuild and retag this image
|
# in the game repos' Cargo.toml (see README) — rebuild and retag this image
|
||||||
# when bumping it. The CLI is the x86_64 musl binary, so the image must be
|
# when bumping it. The CLI is the x86_64 musl binary (static, runs on
|
||||||
# built for linux/amd64.
|
# glibc too), so the image must be built for linux/amd64.
|
||||||
#
|
#
|
||||||
# Build & push (the CI runner is linux/amd64):
|
# Build & push (the CI runner is linux/amd64):
|
||||||
# docker build --platform linux/amd64 -f builder.Dockerfile \
|
# docker build --platform linux/amd64 -f builder.Dockerfile \
|
||||||
@@ -13,13 +19,17 @@
|
|||||||
# -t git.teletypegames.org/internal/bevy-builder:latest .
|
# -t git.teletypegames.org/internal/bevy-builder:latest .
|
||||||
# docker push git.teletypegames.org/internal/bevy-builder:latest
|
# docker push git.teletypegames.org/internal/bevy-builder:latest
|
||||||
|
|
||||||
FROM rust:1-alpine
|
FROM rust:1-bookworm
|
||||||
|
|
||||||
ARG WASM_BINDGEN_VERSION=0.2.100
|
ARG WASM_BINDGEN_VERSION=0.2.100
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev make zip curl git jq
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
make zip curl git jq pkg-config \
|
||||||
|
libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev \
|
||||||
|
gcc-mingw-w64-x86-64 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN rustup target add wasm32-unknown-unknown
|
RUN rustup target add wasm32-unknown-unknown x86_64-pc-windows-gnu
|
||||||
|
|
||||||
RUN curl -sSL "https://github.com/rustwasm/wasm-bindgen/releases/download/${WASM_BINDGEN_VERSION}/wasm-bindgen-${WASM_BINDGEN_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
|
RUN curl -sSL "https://github.com/rustwasm/wasm-bindgen/releases/download/${WASM_BINDGEN_VERSION}/wasm-bindgen-${WASM_BINDGEN_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
|
||||||
| tar xz -C /usr/local/bin --strip-components=1 \
|
| tar xz -C /usr/local/bin --strip-components=1 \
|
||||||
|
|||||||
+52
-2
@@ -33,6 +33,48 @@ wasm:
|
|||||||
wasm-bindgen --target web --no-typescript \
|
wasm-bindgen --target web --no-typescript \
|
||||||
--out-dir $(DIST_DIR) --out-name game $(WASM_RELEASE)
|
--out-dir $(DIST_DIR) --out-name game $(WASM_RELEASE)
|
||||||
|
|
||||||
|
# -----------------------------------------
|
||||||
|
# Native binaries. linux-x64: glibc build in the debian-based builder
|
||||||
|
# image; win-x64: mingw-w64 cross-compile (x86_64-pc-windows-gnu).
|
||||||
|
# Mac needs osxcross, it is not built here.
|
||||||
|
# The zip gets the assets/ dir too if the project has one — bevy loads
|
||||||
|
# it at runtime, it is not embedded in the binary.
|
||||||
|
# -----------------------------------------
|
||||||
|
|
||||||
|
BINARY_SLUGS = win-x64 linux-x64
|
||||||
|
WIN_TARGET = x86_64-pc-windows-gnu
|
||||||
|
|
||||||
|
# $(1) slug, $(2) built binary, $(3) file name inside the package
|
||||||
|
define f_pack_binary
|
||||||
|
set -e; \
|
||||||
|
PKG_DIR="$(PROJECT)-$(VERSION)-$(1)"; \
|
||||||
|
rm -rf "$$PKG_DIR" "$$PKG_DIR.zip"; \
|
||||||
|
mkdir -p "$$PKG_DIR"; \
|
||||||
|
cp "$(2)" "$$PKG_DIR/$(3)"; \
|
||||||
|
chmod +x "$$PKG_DIR/$(3)"; \
|
||||||
|
if [ -d assets ]; then cp -r assets "$$PKG_DIR/assets"; fi; \
|
||||||
|
zip -qr "$$PKG_DIR.zip" "$$PKG_DIR"; \
|
||||||
|
rm -rf "$$PKG_DIR"; \
|
||||||
|
echo "==> $$PKG_DIR.zip kesz"
|
||||||
|
endef
|
||||||
|
|
||||||
|
binaries:
|
||||||
|
@if [ -z "$(VERSION)" ]; then \
|
||||||
|
echo "ERROR: VERSION not set!"; exit 1; \
|
||||||
|
fi
|
||||||
|
@$(MAKE) binary-linux binary-win VERSION=$(VERSION)
|
||||||
|
|
||||||
|
binary-linux:
|
||||||
|
@echo "==> Building linux-x64 binary"
|
||||||
|
cargo build --release
|
||||||
|
@$(call f_pack_binary,linux-x64,target/release/$(PROJECT),$(PROJECT))
|
||||||
|
|
||||||
|
binary-win:
|
||||||
|
@echo "==> Building win-x64 binary"
|
||||||
|
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \
|
||||||
|
cargo build --release --target $(WIN_TARGET)
|
||||||
|
@$(call f_pack_binary,win-x64,target/$(WIN_TARGET)/release/$(PROJECT).exe,$(PROJECT).exe)
|
||||||
|
|
||||||
export: wasm
|
export: wasm
|
||||||
@if [ -z "$(VERSION)" ]; then \
|
@if [ -z "$(VERSION)" ]; then \
|
||||||
echo "ERROR: VERSION not set!"; exit 1; \
|
echo "ERROR: VERSION not set!"; exit 1; \
|
||||||
@@ -66,18 +108,26 @@ ci-export:
|
|||||||
@VERSION=$$(cat $(VERSION_FILE)); \
|
@VERSION=$$(cat $(VERSION_FILE)); \
|
||||||
$(MAKE) export VERSION=$$VERSION
|
$(MAKE) export VERSION=$$VERSION
|
||||||
|
|
||||||
|
ci-binaries:
|
||||||
|
@VERSION=$$(cat $(VERSION_FILE)); \
|
||||||
|
$(MAKE) binaries VERSION=$$VERSION
|
||||||
|
|
||||||
ci-upload:
|
ci-upload:
|
||||||
@VERSION=$$(cat $(VERSION_FILE)); \
|
@VERSION=$$(cat $(VERSION_FILE)); \
|
||||||
FILE="$(PROJECT)-$$VERSION.html.zip"; \
|
FILE="$(PROJECT)-$$VERSION.html.zip"; \
|
||||||
META_SRC="metadata.json"; \
|
META_SRC="metadata.json"; \
|
||||||
META_DST="$(PROJECT)-$$VERSION.metadata.json"; \
|
META_DST="$(PROJECT)-$$VERSION.metadata.json"; \
|
||||||
cp $$META_SRC $$META_DST; \
|
cp $$META_SRC $$META_DST; \
|
||||||
|
BINS=""; \
|
||||||
|
for slug in $(BINARY_SLUGS); do \
|
||||||
|
[ -f "$(PROJECT)-$$VERSION-$$slug.zip" ] && BINS="$$BINS $(PROJECT)-$$VERSION-$$slug.zip"; \
|
||||||
|
done; \
|
||||||
sshpass -p "$(DROPAREA_SSH_PASSWORD)" scp -o StrictHostKeyChecking=no -P $(DROPAREA_PORT) \
|
sshpass -p "$(DROPAREA_SSH_PASSWORD)" scp -o StrictHostKeyChecking=no -P $(DROPAREA_PORT) \
|
||||||
$$FILE $$META_DST \
|
$$FILE $$META_DST $$BINS \
|
||||||
$(DROPAREA_USER)@$(DROPAREA_HOST):$(DROPAREA_TARGET_PATH)/
|
$(DROPAREA_USER)@$(DROPAREA_HOST):$(DROPAREA_TARGET_PATH)/
|
||||||
|
|
||||||
ci-update:
|
ci-update:
|
||||||
@VERSION=$$(cat $(VERSION_FILE)); \
|
@VERSION=$$(cat $(VERSION_FILE)); \
|
||||||
curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=bevy&version=$$VERSION"
|
curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=bevy&version=$$VERSION"
|
||||||
|
|
||||||
.PHONY: all build run wasm export watch clean ci-version ci-export ci-upload ci-update
|
.PHONY: all build run wasm export binaries binary-linux binary-win watch clean ci-version ci-export ci-binaries ci-upload ci-update
|
||||||
|
|||||||
@@ -7,9 +7,16 @@ steps:
|
|||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: git.teletypegames.org/internal/bevy-builder:latest
|
image: git.teletypegames.org/internal/bevy-builder:latest
|
||||||
|
pull: true
|
||||||
commands:
|
commands:
|
||||||
- make ci-export
|
- make ci-export
|
||||||
|
|
||||||
|
- name: binaries
|
||||||
|
image: git.teletypegames.org/internal/bevy-builder:latest
|
||||||
|
pull: true
|
||||||
|
commands:
|
||||||
|
- make ci-binaries
|
||||||
|
|
||||||
- name: upload
|
- name: upload
|
||||||
image: alpine
|
image: alpine
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user