Files
CASAN/docs/packaging/GITEA_PACKAGE_GUIDE.md
T
thanhnvandClaude Opus 4.8 98d699d844 ci(release): auto-publish split bundles to Gitea package registry on version tags
.gitea/workflows/release.yml — on push tag v*: assert tag==VERSION, run the governance
gate (must be green), build core/devkit/platform-preview/all-in-one-demo (enterprise
skipped/refused), then PUT each .tar.gz (+.sha256) to the Gitea generic package registry
using ${{ secrets.GITEA_TOKEN }}. Portable via GITHUB_SERVER_URL/OWNER. Guide updated with
the one-time secret setup + release flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 16:06:28 +09:00

96 lines
4.3 KiB
Markdown

# CASAN on Gitea — Source Hub + Package Registry
This repo uses the existing Gitea server (`ssh://git@161.33.139.73:2222/admin/casan5.git`)
as the **source hub**. Gitea also ships a **package registry** (generic files) and a
**container registry**, so CASAN release bundles and Docker images can live next to the
source. This guide shows the release flow. No secrets are committed; use a Gitea token/PAT.
> Gitea host below is written as `$GITEA` (e.g. `http://161.33.139.73:3000`). Set
> `GITEA_TOKEN` to a personal access token with `write:package` scope. Adjust `admin`/`casan5`
> to your org/repo.
## 1. Build the bundles
```bash
scripts/package-release.sh core
scripts/package-release.sh devkit
scripts/package-release.sh platform # preview
scripts/package-release.sh all-in-one-demo
# enterprise → intentionally refused (future)
ls dist/ # *.tar.gz + *.sha256
```
## 2. Publish tarballs to the Gitea generic package registry
Endpoint: `PUT $GITEA/api/packages/{owner}/generic/{name}/{version}/{file}`
```bash
GITEA=http://161.33.139.73:3000; OWNER=admin; V=$(cat VERSION)
for lvl in core devkit; do
f="dist/casan-$lvl-v$V.tar.gz"
curl -fsSL -XPUT -H "Authorization: token $GITEA_TOKEN" \
--upload-file "$f" \
"$GITEA/api/packages/$OWNER/generic/casan-$lvl/$V/$(basename "$f")"
curl -fsSL -XPUT -H "Authorization: token $GITEA_TOKEN" \
--upload-file "$f.sha256" \
"$GITEA/api/packages/$OWNER/generic/casan-$lvl/$V/$(basename "$f").sha256"
done
# platform is a preview artifact:
curl -fsSL -XPUT -H "Authorization: token $GITEA_TOKEN" \
--upload-file "dist/casan-platform-preview-v$V.tar.gz" \
"$GITEA/api/packages/$OWNER/generic/casan-platform/$V-preview/casan-platform-preview-v$V.tar.gz"
```
Downstream then pulls:
```bash
curl -fsSL -H "Authorization: token $TOKEN" \
"$GITEA/api/packages/admin/generic/casan-core/1.0.0/casan-core-v1.0.0.tar.gz" -o casan-core.tar.gz
```
## 3. Publish Docker images to the Gitea container registry
```bash
V=$(cat VERSION)
docker build -f packages/casan-devkit/Dockerfile.harness -t "$REG/admin/casan-harness:$V" .
echo "$GITEA_TOKEN" | docker login "$REG" -u admin --password-stdin # REG=161.33.139.73:3000
docker push "$REG/admin/casan-harness:$V"
```
See `DOCKER_GUIDE.md` for image details. `casan-platform:$V` is preview; `casan-enterprise:$V`
is future (do not publish).
## 4. Attach bundles to a Gitea Release (optional, human-facing)
Create a tag + release via the API and upload the tarballs as release attachments:
```bash
# create release for tag vX.Y.Z, then:
curl -fsSL -XPOST -H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@dist/casan-devkit-v$V.tar.gz" \
"$GITEA/api/v1/repos/admin/casan5/releases/{release_id}/assets?name=casan-devkit-v$V.tar.gz"
```
## 5. Recommended cadence
- Tag `vX.Y.Z` on `main` → CI green → build bundles → publish `core` + `devkit` (always),
`platform` as `-preview`, `all-in-one-demo` for demos. Never publish `enterprise`.
- Keep `VERSION` and `packages/casan-harness/level5/harness-package.json` version in lockstep.
## Automated release (recommended — already wired)
`.gitea/workflows/release.yml` does all of the above automatically on a version tag. You
never hand a token to anyone — it lives in a CI secret.
**One-time setup**
1. Create a token: Gitea → *Settings → Applications → Generate New Token*, scope
`write:package` (+ `write:repository` if you also want release attachments).
2. Add it as a secret: repo (or org) → *Settings → Actions → Secrets* → name `GITEA_TOKEN`.
**Cut a release**
```bash
# bump the version everywhere first
echo 1.0.1 > VERSION # must match the tag
# (also bump packages/casan-harness/level5/harness-package.json "version")
git commit -am "release v1.0.1"
git tag -a v1.0.1 -m "CASAN v1.0.1"
git push origin main --follow-tags
```
On the tag push the workflow: checks `tag == VERSION` → runs the governance gate (must be
green) → builds `core`/`devkit`/`platform-preview`/`all-in-one-demo` (enterprise skipped) →
`curl` PUTs each `.tar.gz` (+ `.sha256`) to `.../api/packages/<owner>/generic/...`. Bundles
appear under the repo's **Packages** tab. `GITHUB_SERVER_URL` / `GITHUB_REPOSITORY_OWNER`
are provided by Gitea Actions, so the workflow is portable across Gitea hosts.
## Manual one-off (if you don't want to tag)
Use the `curl` snippets in §2/§3 above with a local `GITEA_TOKEN`.