Skip to main content

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 "<username>:<PAT>" \
  --upload-file target/release/bookstack-cli-rs \
  https://git.example.com/api/packages/<owner>/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 "<username>:${{ secrets.PACKAGE_TOKEN }}"

Download URL

Users can download binaries with:

curl -fsSL \
  --user "<username>:$GITEA_TOKEN" \
  https://git.example.com/api/packages/<owner>/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:

  1. Runs tests
  2. Builds release binary
  3. Publishes to Gitea generic package registry
  4. Creates a Gitea release