Generic Package Publishing Debugging
Generic Package Publishing Debugging
Problem
When trying to publish release binaries as Gitea generic packages via CI/CD, all upload attempts failed with various error codes (401, 404, 405, 500).
Root Cause Discovery
The instance is Forgejo (v14.0.2 / gitea-1.22.0), not standard Gitea. The authentication method required differs between the two.
What Didn't Work
| Method | Result |
|---|---|
Authorization: token <PAT> + raw PUT |
500 (content-type mismatch) |
Authorization: token <PAT> + multipart form POST |
404 |
Authorization: token <PAT> + multipart form PUT |
405 |
--user "user:token" + raw PUT to /api/v1/packages/... |
404 |
What Worked
curl -X PUT \
--user "ravenscroftj:<PAT>" \
--upload-file target/release/bookstack-cli-rs \
https://git.jamesravey.me/api/packages/ravenscroftj/generic/bookstack-cli-rs/v0.1.2-rc1/bookstack-cli-rs-x86_64-unknown-linux-gnu
Key: Use Basic auth (--user user:token), not Authorization: token header.
Forgejo vs Gitea Auth Difference
| API Endpoint | Gitea Auth | Forgejo Auth |
|---|---|---|
/api/v1/... (REST) |
Authorization: token <PAT> |
Authorization: token <PAT> |
/api/packages/... (packages) |
Authorization: token <PAT> |
Basic auth (--user user:token) |
Forgejo requires Basic authentication for the generic package registry API, while standard Gitea accepts the token header. The REST API works with both.
CI/CD Workflow Fix
Changed from:
-H "Authorization: token ${{ secrets.PACKAGE_TOKEN }}"
To:
--user "ravenscroftj:${{ secrets.PACKAGE_TOKEN }}"
Download URL
Users can download binaries with:
curl -fsSL \
--user "ravenscroftj:$GITEA_TOKEN" \
https://git.jamesravey.me/api/packages/ravenscroftj/generic/bookstack-cli-rs/0.1.0/bookstack-cli-rs-x86_64-unknown-linux-gnu \
-o bookstack-cli-rs && chmod +x bookstack-cli-rs
Release Process
cargo test --all && cargo build --release
git tag v0.1.0
git push origin v0.1.0
This triggers the CI workflow which:
- Runs tests
- Builds release binary
- Publishes to Gitea generic package registry
- Creates a Gitea release