Compare commits
3 Commits
56df31ee12
...
bdffb44bb7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdffb44bb7 | ||
|
|
1a232f36af | ||
|
|
fb8a8773ea |
22
README.md
22
README.md
@@ -77,6 +77,28 @@ ldd target/x86_64-unknown-linux-musl/release/story-kit
|
|||||||
./story-kit
|
./story-kit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Releasing
|
||||||
|
|
||||||
|
Builds both macOS and Linux binaries locally, tags the repo, and publishes a Gitea release with a changelog.
|
||||||
|
|
||||||
|
**One-time setup:**
|
||||||
|
|
||||||
|
1. Create a Gitea API token at `https://code.crashlabs.io/user/settings/applications` (needs repository read/write)
|
||||||
|
2. Add it to `.env` (gitignored): `GITEA_TOKEN=your_token`
|
||||||
|
3. Ensure `cross` is installed (`cargo install cross`) and Docker is running
|
||||||
|
|
||||||
|
**To release:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make release V=0.2.0
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
- Build macOS arm64 (native) and Linux amd64 (static musl via cross/Docker)
|
||||||
|
- Generate a changelog from commits since the last tag
|
||||||
|
- Tag the repo as `v0.2.0` and push the tag
|
||||||
|
- Create a Gitea release with both binaries and the changelog attached
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
### Frontend Tests
|
### Frontend Tests
|
||||||
|
|||||||
@@ -67,6 +67,29 @@ chmod +x "${DIST}"/*
|
|||||||
echo "==> Binaries:"
|
echo "==> Binaries:"
|
||||||
ls -lh "${DIST}"/
|
ls -lh "${DIST}"/
|
||||||
|
|
||||||
|
# ── Changelog ──────────────────────────────────────────────────
|
||||||
|
echo "==> Generating changelog..."
|
||||||
|
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||||
|
if [ -n "$PREV_TAG" ]; then
|
||||||
|
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges)
|
||||||
|
RANGE="${PREV_TAG}...${TAG}"
|
||||||
|
else
|
||||||
|
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges)
|
||||||
|
RANGE="initial...${TAG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CHANGELOG" ]; then
|
||||||
|
CHANGELOG="- No changes since last release"
|
||||||
|
fi
|
||||||
|
|
||||||
|
RELEASE_BODY="## What's Changed
|
||||||
|
|
||||||
|
${CHANGELOG}
|
||||||
|
|
||||||
|
**Full diff:** ${GITEA_URL}/${REPO}/compare/${RANGE}"
|
||||||
|
|
||||||
|
echo "$RELEASE_BODY"
|
||||||
|
|
||||||
# ── Tag & Push ─────────────────────────────────────────────────
|
# ── Tag & Push ─────────────────────────────────────────────────
|
||||||
echo "==> Tagging ${TAG}..."
|
echo "==> Tagging ${TAG}..."
|
||||||
git tag -a "$TAG" -m "Release ${TAG}"
|
git tag -a "$TAG" -m "Release ${TAG}"
|
||||||
@@ -74,11 +97,20 @@ git push origin "$TAG"
|
|||||||
|
|
||||||
# ── Create Gitea Release ──────────────────────────────────────
|
# ── Create Gitea Release ──────────────────────────────────────
|
||||||
echo "==> Creating release on Gitea..."
|
echo "==> Creating release on Gitea..."
|
||||||
|
RELEASE_JSON=$(python3 -c "
|
||||||
|
import json, sys
|
||||||
|
print(json.dumps({
|
||||||
|
'tag_name': sys.argv[1],
|
||||||
|
'name': sys.argv[1],
|
||||||
|
'body': sys.argv[2]
|
||||||
|
}))
|
||||||
|
" "$TAG" "$RELEASE_BODY")
|
||||||
|
|
||||||
RELEASE_RESPONSE=$(curl -sf -X POST \
|
RELEASE_RESPONSE=$(curl -sf -X POST \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
||||||
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\", \"body\": \"Release ${TAG}\"}")
|
-d "$RELEASE_JSON")
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,19 @@ fn main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When cross-compiling (e.g. musl via `cross`), the Docker container
|
||||||
|
// has no Node/pnpm. The release script builds macOS first, so
|
||||||
|
// frontend/dist/ already exists. Skip the frontend build in that case.
|
||||||
|
let target = env::var("TARGET").unwrap_or_default();
|
||||||
|
let host = env::var("HOST").unwrap_or_default();
|
||||||
|
if target != host {
|
||||||
|
let dist = Path::new("../frontend/dist");
|
||||||
|
if !dist.exists() {
|
||||||
|
panic!("Cross-compiling but frontend/dist/ is missing. Build macOS first.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let frontend_dir = Path::new("../frontend");
|
let frontend_dir = Path::new("../frontend");
|
||||||
|
|
||||||
// Ensure dependencies are installed and build the frontend bundle.
|
// Ensure dependencies are installed and build the frontend bundle.
|
||||||
|
|||||||
Reference in New Issue
Block a user