initial commit
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-07-31 18:33:06 +02:00
commit 64b2f479e0
8 changed files with 5475 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
target
bin
dist
*.zip
.version
+35
View File
@@ -0,0 +1,35 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// Copy to .vscode/tasks.json and replace "bevydemo" with your PROJECT name.
"version": "2.0.0",
"tasks": [
{
"label": "Run",
"type": "shell",
"command": "cargo run",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build & Run",
"type": "shell",
"command": "make clean && make build && ./bin/bevydemo",
"problemMatcher": []
},
{
"label": "Build WASM",
"type": "shell",
"command": "make wasm",
"problemMatcher": []
},
{
"label": "Make build",
"type": "shell",
"command": "make build"
}
]
}
+38
View File
@@ -0,0 +1,38 @@
steps:
- name: version
image: alpine
commands:
- apk add --no-cache git make jq
- make ci-version
- name: build
image: rust:1-alpine
commands:
- apk add --no-cache musl-dev zip make curl
- rustup target add wasm32-unknown-unknown
- WB=$(grep -o 'WASM_BINDGEN_VERSION *= *[0-9.]*' Makefile | grep -o '[0-9.]*$')
- curl -sSL "https://github.com/rustwasm/wasm-bindgen/releases/download/$${WB}/wasm-bindgen-$${WB}-x86_64-unknown-linux-musl.tar.gz" | tar xz -C /usr/local/bin --strip-components=1
- make ci-export
- name: upload
image: alpine
environment:
DROPAREA_HOST: vps.teletype.hu
DROPAREA_PORT: 2223
DROPAREA_TARGET_PATH: /home/drop
DROPAREA_USER: drop
DROPAREA_SSH_PASSWORD:
from_secret: droparea_ssh_password
commands:
- apk add --no-cache make openssh-client sshpass
- make ci-upload
- name: update
image: alpine
environment:
UPDATE_SERVER: https://teletypegames.org
UPDATE_SECRET:
from_secret: update_secret_key
commands:
- apk add --no-cache make curl
- make ci-update
Generated
+5207
View File
File diff suppressed because it is too large Load Diff
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "bevydemo"
version = "1.0.0"
edition = "2021"
license = "MIT"
[dependencies]
bevy = "0.16"
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "=0.2.100"
[profile.release]
lto = "thin"
+83
View File
@@ -0,0 +1,83 @@
# -----------------------------------------
# Makefile Bevy project builder
# -----------------------------------------
PROJECT = bevydemo
# Must match the `wasm-bindgen` version pinned in Cargo.toml
# ([target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = "=0.2.100")
WASM_BINDGEN_VERSION = 0.2.100
BIN_DIR = bin
DIST_DIR = dist
WASM_TARGET = wasm32-unknown-unknown
WASM_RELEASE = target/$(WASM_TARGET)/release/$(PROJECT).wasm
OUTPUT_ZIP = $(PROJECT)-$(VERSION).html.zip
VERSION_FILE = .version
INDEX_HTML_URL = https://git.teletype.hu/tools/bevy-tools/raw/branch/master/web/index.html
all: build
build:
@mkdir -p $(BIN_DIR)
cargo build --release
cp target/release/$(PROJECT) $(BIN_DIR)/$(PROJECT)
run:
cargo run
wasm:
@mkdir -p $(DIST_DIR)
cargo build --release --target $(WASM_TARGET)
wasm-bindgen --target web --no-typescript \
--out-dir $(DIST_DIR) --out-name game $(WASM_RELEASE)
export: wasm
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION not set!"; exit 1; \
fi
@echo "==> Downloading index.html"
curl -sSL $(INDEX_HTML_URL) -o $(DIST_DIR)/index.html
@echo "==> Packaging HTML/WASM for $(VERSION)"
zip -r $(OUTPUT_ZIP) -j $(DIST_DIR)/game_bg.wasm $(DIST_DIR)/game.js $(DIST_DIR)/index.html
@echo "==> Cleaning temporary files"
rm -f $(DIST_DIR)/game_bg.wasm $(DIST_DIR)/game.js $(DIST_DIR)/index.html
watch:
fswatch -o src | while read; do make build; done
clean:
rm -rf $(BIN_DIR) $(DIST_DIR) target
ci-version:
@if [ -f metadata.json ]; then \
VERSION=$$(jq -r '.version' metadata.json); \
else \
VERSION=$$(git rev-parse --short HEAD); \
fi; \
BRANCH=$$(git rev-parse --abbrev-ref HEAD); \
if [ "$$BRANCH" != "main" ] && [ "$$BRANCH" != "master" ]; then \
VERSION="dev-$$VERSION-$$BRANCH"; \
fi; \
echo $$VERSION > $(VERSION_FILE)
ci-export:
@VERSION=$$(cat $(VERSION_FILE)); \
$(MAKE) export VERSION=$$VERSION
ci-upload:
@VERSION=$$(cat $(VERSION_FILE)); \
FILE="$(PROJECT)-$$VERSION.html.zip"; \
META_SRC="metadata.json"; \
META_DST="$(PROJECT)-$$VERSION.metadata.json"; \
cp $$META_SRC $$META_DST; \
sshpass -p "$(DROPAREA_SSH_PASSWORD)" scp -o StrictHostKeyChecking=no -P $(DROPAREA_PORT) \
$$FILE $$META_DST \
$(DROPAREA_USER)@$(DROPAREA_HOST):$(DROPAREA_TARGET_PATH)/
ci-update:
@VERSION=$$(cat $(VERSION_FILE)); \
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
+9
View File
@@ -0,0 +1,9 @@
{
"name": "bevydemo",
"title": "Bevy Demo",
"author": "Teletype Games",
"desc": "It's a simple demo program in Bevy",
"site": "https://git.teletype.hu/games/bevydemo",
"license": "MIT License",
"version": "1.0.0"
}
+84
View File
@@ -0,0 +1,84 @@
use bevy::prelude::*;
const SCREEN_W: f32 = 640.0;
const SCREEN_H: f32 = 480.0;
const MESSAGE: &str = "TELETYPE GAMES";
const CHAR_W: f32 = 40.0;
const WAVE_AMPLITUDE: f32 = 28.0;
fn palette(i: usize) -> Color {
match i % 5 {
0 => Color::srgb_u8(0x1a, 0x1c, 0x2c),
1 => Color::srgb_u8(0x5d, 0x27, 0x5d),
2 => Color::srgb_u8(0xb1, 0x3e, 0x53),
3 => Color::srgb_u8(0xef, 0x7d, 0x57),
_ => Color::srgb_u8(0xff, 0xcd, 0x75),
}
}
#[derive(Component)]
struct Letter(usize);
#[derive(Component)]
struct Shadow;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Teletype Games".into(),
resolution: (SCREEN_W, SCREEN_H).into(),
..default()
}),
..default()
}))
.insert_resource(ClearColor(Color::BLACK))
.add_systems(Startup, setup)
.add_systems(Update, animate)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2d);
let total_w = MESSAGE.chars().count() as f32 * CHAR_W;
for (i, ch) in MESSAGE.chars().enumerate() {
let x = i as f32 * CHAR_W - total_w / 2.0 + CHAR_W / 2.0;
let font = TextFont {
font_size: 48.0,
..default()
};
commands.spawn((
Text2d::new(ch.to_string()),
font.clone(),
TextColor(Color::srgba(0.0, 0.0, 0.0, 0.7)),
Transform::from_xyz(x + 4.0, -4.0, 0.0),
Letter(i),
Shadow,
));
commands.spawn((
Text2d::new(ch.to_string()),
font,
TextColor(palette(i)),
Transform::from_xyz(x, 0.0, 1.0),
Letter(i),
));
}
}
fn animate(
time: Res<Time>,
mut query: Query<(&Letter, &mut Transform, &mut TextColor, Option<&Shadow>)>,
) {
let t = time.elapsed_secs() * 2.5;
for (letter, mut transform, mut color, shadow) in &mut query {
let y = (t + letter.0 as f32 * 0.4).sin() * WAVE_AMPLITUDE;
if shadow.is_some() {
transform.translation.y = y - 4.0;
} else {
transform.translation.y = y;
color.0 = palette(letter.0 + (t * 0.8) as usize);
}
}
}