more or less still dont know
release / build (push) Successful in 2m18s

This commit is contained in:
lda
2025-08-25 06:21:12 +07:00 Unverified
parent 9aa1c44246
commit 2392477ec8
8 changed files with 122 additions and 138 deletions
-5
View File
@@ -1,7 +1,2 @@
# [target.armv7-unknown-linux-gnueabihf]
# linker = "arm-none-eabi-gcc"
# advices from gpt5rustup target add armv7-unknown-linux-musleabihf
[build]
# target = "armv7-unknown-linux-musleabihf"
+2
View File
@@ -16,3 +16,5 @@ target/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.env
+4 -1
View File
@@ -1,2 +1,5 @@
[build]
default-target = "armv7-unknown-linux-musleabihf"
default-target = "armv7-unknown-linux-musleabihf"
# [build.env]
# passthrough = ["VAR1_ARG", "VAR2_ARG=VALUE"]
+53 -88
View File
@@ -1,106 +1,71 @@
# Scripts
This folder contains helper scripts for building, packaging, releasing, and deploying `wakey`.
This folder has small helpers for build, CI, and router install. Keep it simple; use only what you need.
## Overview
## Quick start (recommended)
- `act_runner.ps1` Starts your local Gitea runner as a background daemon on Windows.
- `cross_build.ps1` — Cross-compiles the project using `cross` for one or more Linux targets.
- `package.ps1` — Builds a developer-friendly tarball/zip containing binaries and init scripts.
- `package_rootfs.ps1` — Builds a router-ready rootfs tarball that can be installed via `wget | tar`.
- `release.ps1` — One-shot helper to cross build and package.
- `publish.ps1` — Optional: bump version in Cargo.toml, build, `cargo publish`, and tag the repo.
- `init/openwrt/*` — OpenWrt init scripts (procd) to run `wakey` and other helpers.
- `systemd/wakey.service` — A basic systemd unit for Linux hosts.
## act_runner.ps1
Starts the Gitea `act_runner` if it isn't already running.
- Default paths assume `~/Documents/gitea/act_runner.exe` and config at `~/Documents/gitea/.runner`.
- Usage:
1. Start your Gitea runner on this Windows PC
```powershell
./scripts/act_runner.ps1
# or specify custom paths
./scripts/act_runner.ps1 -RunnerPath "C:/Users/Admin/Documents/gitea/act_runner.exe" -Config "C:/Users/Admin/Documents/gitea/.runner"
```
## cross_build.ps1
If first-time, it prints the exact register command. Run it once, check labels include `windows:host,self-hosted`, then rerun the script.
Cross-compile with `cross` for the targets you need.
- Requires `cross` installed (`cargo install cross`).
- Usage:
1. Tag and push to trigger CI
```powershell
git tag v0.1.0
git push origin v0.1.0
```
1. Install on the router
Use the release asset URL from your Gitea Release page:
```sh
wget -O- https://<gitea>/<owner>/<repo>/releases/download/v0.1.0/wakey-rootfs-v0.1.0-armv7-unknown-linux-musleabihf.tgz | tar -xz -C /
chmod +x /etc/init.d/wakey && /etc/init.d/wakey enable && /etc/init.d/wakey restart
```
Alternatively, use the updater on the router to fetch the latest automatically:
```sh
WAKEY_HOST=git.ldlda.com WAKEY_OWNER=lda WAKEY_REPO=wakey sh /etc/ldlda_help/update_wakey.sh
```
## Scripts overview
- `act_runner.ps1` — Start/seed the local Gitea runner. Use `-Attach` to see logs, `-ForceConfigure` to register non-interactively.
- `cross_build.ps1` — Simple wrapper for `cross build` per target (default: armv7-unknown-linux-musleabihf).
- `package_rootfs.ps1` — Produces `dist/wakey-rootfs-<version>-<target>.tgz` with `/root/.bin/wakey` and `/etc/init.d/*`.
- `package.ps1` — Dev bundle with binaries + init scripts (not a rootfs layout).
- `publish.ps1` — Optional version bump + build + tag (and `cargo publish` only if you pass `-Publish`).
## CI (Gitea)
- Defined in `.gitea/workflows/release.yml`.
- Runs on your `self-hosted, windows` runner.
- Steps: cross build → package rootfs → upload artifact (v3) → publish a release and attach tgz.
- Requires `secrets.GITEA_TOKEN` in the repo to publish the release.
## Local build/install (manual path)
```powershell
# Build (requires cross installed)
./scripts/cross_build.ps1 -Release -Targets armv7-unknown-linux-musleabihf
# Package rootfs
./scripts/package_rootfs.ps1 -Version v0.1.0 -Target armv7-unknown-linux-musleabihf
# Copy to router (PowerShell)
scp -O .\dist\wakey-rootfs-v0.1.0-armv7-unknown-linux-musleabihf.tgz root@<router-ip>:/tmp/wakey.tgz
```
## package.ps1
Create a developer bundle with binaries and init scripts. Doesnt layout files for `/` directly.
```powershell
./scripts/package.ps1 -Version 0.1.0 -Targets armv7-unknown-linux-musleabihf
```
Artifacts in `dist/wakey-<version>.(tgz|zip)`.
## package_rootfs.ps1
Create a router-ready rootfs tarball that installs with a one-liner.
```powershell
./scripts/package_rootfs.ps1 -Version 0.1.0 -Target armv7-unknown-linux-musleabihf
```
This writes `dist/wakey-rootfs-<version>-<target>.tgz` containing:
- `root/.bin/wakey`
- `etc/init.d/wakey` (and any other scripts under `scripts/init/openwrt`)
Install on OpenWrt:
```sh
wget -O- <URL>/wakey-rootfs-<version>-<target>.tgz | tar -xz -C /
chmod +x /etc/init.d/wakey
/etc/init.d/wakey enable
/etc/init.d/wakey start
# On the router
tar -xz -f /tmp/wakey.tgz -C /
chmod +x /etc/init.d/wakey && /etc/init.d/wakey enable && /etc/init.d/wakey restart
```
## release.ps1
One-shot:
```powershell
./scripts/release.ps1 -Version 0.1.0 -Targets armv7-unknown-linux-musleabihf
```
## publish.ps1
Optional helper to bump the version, build release, publish the crate, and tag the repo.
```powershell
./scripts/publish.ps1 -Version 0.1.0 -Tag
```
- If youre not publishing to crates.io, the `cargo publish` step will warn and continue.
- Uses a simple regex replace to update the `version = "…"` line in `Cargo.toml`.
## CI workflow (Gitea)
A workflow in `.gitea/workflows/release.yml` is provided:
- Triggers on tag pushes (v\*) and manual dispatch.
- Builds with `cross` on your self-hosted Windows runner.
- Packages a rootfs tarball.
- Publishes a Gitea release via API, attaching the tarball (requires `secrets.GITEA_TOKEN`).
Once published, you can install on the router with:
```sh
wget -O- <release-asset-URL> | tar -xz -C /
```
Adjust paths and targets as needed for your environment.
Thats it. Keep the flow: start runner → tag push → install.
+1 -2
View File
@@ -3,7 +3,7 @@
param(
[string]$RunnerPath = "$HOME/Documents/gitea/act_runner.exe",
# Config is a FILE path (e.g., runner.yaml). Parent folder will be created if missing.
[string]$Config = "$HOME/Documents/gitea/config.yaml",
[string]$Config = (Join-Path (Split-Path -Parent $PSScriptRoot) 'ar_data/config.yaml'),
[string]$ServerUrl,
[string]$Token,
[string]$Labels = "windows:host,self-hosted",
@@ -28,7 +28,6 @@ if ($running) {
# Ensure config exists
$configFile = $Config
$configDir = Split-Path -Parent $configFile
Set-Location $configDir
if (-not (Test-Path $configDir)) { New-Item -ItemType Directory -Force -Path $configDir | Out-Null }
if (-not (Test-Path $configFile)) {
+3 -3
View File
@@ -17,8 +17,8 @@ if (-not $Token) { throw 'Missing Gitea token. Set -Token or $env:GITEA_TOKEN' }
if (-not $Owner -or -not $Repo) {
if ($env:GITHUB_REPOSITORY) {
$parts = $env:GITHUB_REPOSITORY -split '/'
$Owner = $Owner ?: $parts[0]
$Repo = $Repo ?: $parts[1]
if (-not $Owner -and $parts.Length -ge 1) { $Owner = $parts[0] }
if (-not $Repo -and $parts.Length -ge 2) { $Repo = $parts[1] }
}
else {
throw 'Missing Owner/Repo and GITHUB_REPOSITORY not set'
@@ -53,5 +53,5 @@ if (-not $rid) { throw "Failed to resolve release id: $($release | ConvertTo-Jso
$uploadUri = "$api/repos/$Owner/$Repo/releases/$rid/assets?name=$($asset.Name)"
Write-Host "Uploading asset $($asset.Name)"
Invoke-WebRequest -Headers $headers -Uri $uploadUri -Method Post -InFile $asset.FullName -ContentType 'application/gzip' | Out-Null
Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $uploadUri -Method Post -InFile $asset.FullName -ContentType 'application/octet-stream' | Out-Null
Write-Host "Release published: tag $Tag with asset $($asset.Name)"
+15 -11
View File
@@ -1,9 +1,17 @@
# Publish to registry and tag
# Usage: ./scripts/publish.ps1 -Version 0.1.0 -Tag
# Publish to registry and tag (manual; CI does not use this)
# Usage:
# ./scripts/publish.ps1 -Version 0.1.0 -Publish # publish to your configured Cargo registry (crates.io or Gitea)
# ./scripts/publish.ps1 -Version 0.1.0 -Tag # create/push git tag v0.1.0
# ./scripts/publish.ps1 -Version 0.1.0 -Publish -Tag # both
# ./scripts/publish.ps1 -Version 0.1.0 -Publish -Registry gitea # publish to named registry
param(
[string]$Version,
[switch]$Tag,
[switch]$Publish
[switch]$ForceTag,
[string]$Registry
)
$ErrorActionPreference = 'Stop'
@@ -18,19 +26,15 @@ if ($Version) {
cargo build --release
# Publish crate (only if -Publish and registry auth is available)
# Publish crate (only if -Publish). Relies on your Cargo config/credentials.
if ($Publish) {
$token = $env:CARGO_REGISTRIES_CRATES_IO_TOKEN
if (-not $token) { $token = $env:CARGO_REGISTRY_TOKEN }
if (-not $token) {
Write-Warning "No registry token found (CARGO_REGISTRIES_CRATES_IO_TOKEN or CARGO_REGISTRY_TOKEN). Skipping cargo publish."
try {
$pubArgs = @('publish')
if ($Registry) { $pubArgs += @('--registry', $Registry) }
cargo @pubArgs
}
else {
try {
cargo publish
}
catch {
Write-Warning ("cargo publish failed: {0}" -f $_)
}
catch {
Write-Warning ("cargo publish failed: {0}" -f $_)
}
}
+44 -28
View File
@@ -1,27 +1,45 @@
#!/bin/sh
# Update/install wakey on OpenWrt by fetching a rootfs tarball and extracting to /
# Supports either a direct URL or auto-detecting the latest release from a Gitea instance.
# Simple defaults, BusyBox-friendly.
#
# Env overrides:
# WAKEY_TGZ_URL Direct URL to wakey-rootfs-<ver>-<arch>.tgz
# WAKEY_HOST Gitea host, e.g. git.ldlda.com
# WAKEY_OWNER Repo owner, e.g. lda
# WAKEY_REPO Repo name, e.g. wakey
# WAKEY_ARCH Target triplet in filename (default: armv7-unknown-linux-musleabihf)
# WAKEY_VERSION Tag name (e.g., v0.1.0). If omitted, fetch latest via API.
# WAKEY_INSECURE If set (non-empty), pass --no-check-certificate to wget
# Env options:
# WAKEY_TGZ_URL Direct URL to wakey-rootfs-<ver>-<arch>.tgz (preferred if known)
# WAKEY_HOST Gitea host (default: git.ldlda.com)
# WAKEY_OWNER Repo owner (default: lda)
# WAKEY_REPO Repo name (default: wakey)
# WAKEY_ARCH Target triplet in filename (default: armv7-unknown-linux-musleabihf)
# WAKEY_VERSION Tag name (e.g., v0.1.0). If omitted, resolve latest via API.
# WAKEY_INSECURE If set, disable TLS verify for wget/curl
#
# Requires: wget (or uclient-fetch), tar
# Requires: uclient-fetch or wget (curl optional), tar
set -eu
ARCH=${WAKEY_ARCH:-armv7-unknown-linux-musleabihf}
TMPFILE="/tmp/wakey-rootfs.$$.$ARCH.tgz"
API_TOKEN="${WAKEY_TOKEN:-}"
log() { echo "[update_wakey] $*"; }
fail() { echo "[update_wakey] ERROR: $*" >&2; exit 1; }
http_get() {
# http_get <url>
if command -v uclient-fetch >/dev/null 2>&1; then
# uclient-fetch supports -O -, write to stdout
uclient-fetch -O - "$1" 2>/dev/null || return 1
elif command -v wget >/dev/null 2>&1; then
# shellcheck disable=SC2086
wget ${WAKEY_INSECURE:+--no-check-certificate} -qO- "$1" || return 1
elif command -v curl >/dev/null 2>&1; then
if [ -n "${WAKEY_INSECURE:-}" ]; then
curl -fsSL -k "$1" || return 1
else
curl -fsSL "$1" || return 1
fi
else
return 2
fi
}
fetch() {
# fetch <url> <out>
if command -v uclient-fetch >/dev/null 2>&1; then
@@ -29,29 +47,27 @@ fetch() {
elif command -v wget >/dev/null 2>&1; then
# shellcheck disable=SC2086
wget ${WAKEY_INSECURE:+--no-check-certificate} -O "$2" "$1" || return 1
elif command -v curl >/dev/null 2>&1; then
if [ -n "${WAKEY_INSECURE:-}" ]; then
curl -fSL -k -o "$2" "$1" || return 1
else
curl -fSL -o "$2" "$1" || return 1
fi
else
return 2
fi
}
latest_asset_url() {
# prints URL to stdout, returns 0 on success
HOST=$1 OWNER=$2 REPO=$3 ARCH=$4 TOKEN=$5
# prints URL to stdout, returns 0 on success (public release only)
HOST=$1 OWNER=$2 REPO=$3 ARCH=$4
API="https://$HOST/api/v1/repos/$OWNER/$REPO/releases/latest"
if command -v curl >/dev/null 2>&1; then
if [ -n "$TOKEN" ]; then
RESP=$(curl -fsSL -H "Authorization: token $TOKEN" "$API") || return 1
else
RESP=$(curl -fsSL "$API") || return 1
fi
elif command -v wget >/dev/null 2>&1; then
# shellcheck disable=SC2086
RESP=$(wget ${WAKEY_INSECURE:+--no-check-certificate} -qO- "$API") || return 1
else
return 2
fi
# crude parse for browser_download_url matching arch; avoids jq dependency
echo "$RESP" | sed -n "s/.*\"browser_download_url\"\s*:\s*\"\([^\"]*${ARCH}\.tgz\)\".*/\1/p" | head -n1
RESP=$(http_get "$API") || return 1
# Extract the first browser_download_url ending with our ARCH .tgz (BusyBox-friendly)
echo "$RESP" \
| grep -o '"browser_download_url"[[:space:]]*:[[:space:]]*"[^"]*'"$ARCH"'\.tgz"' \
| head -n1 \
| cut -d '"' -f 4
}
main() {
@@ -64,7 +80,7 @@ main() {
FILE="wakey-rootfs-${WAKEY_VERSION}-${ARCH}.tgz"
URL="https://$HOST/$OWNER/$REPO/releases/download/${WAKEY_VERSION}/$FILE"
else
URL=$(latest_asset_url "$HOST" "$OWNER" "$REPO" "$ARCH" "$API_TOKEN") || fail "unable to resolve latest asset URL"
URL=$(latest_asset_url "$HOST" "$OWNER" "$REPO" "$ARCH") || fail "unable to resolve latest asset URL"
[ -n "$URL" ] || fail "no asset URL found for arch $ARCH"
fi
fi