|
| 1 | +# Debian Repositories (apt support) for GitHub Releases |
| 2 | + |
| 3 | +It's great when GitHub-hosted projects produce `.deb` packages in their release workflow[^1], |
| 4 | +but GitHub has never bothered to make a GitHub project something you can add to your system's `sources.list` to get ongoing updates. |
| 5 | + |
| 6 | +Here we aim to make it easy and affordable to make an apt-compatible repository for your releases. |
| 7 | + |
| 8 | +[^1]: Shoutout to [GoReleaser](https://goreleaser.com/) and [Tauri](https://v2.tauri.app/distribute/debian/) as a few tools I've seen enabling Debian packaging in the wild. |
| 9 | + |
| 10 | + |
| 11 | +## Requirements |
| 12 | + |
| 13 | +```sh |
| 14 | +sudo apt-get install --no-recommends dpkg-dev sq xz-utils |
| 15 | +``` |
| 16 | + |
| 17 | +And [Node.js v24 (LTS)](https://nodejs.org/en/download) with pnpm. |
| 18 | + |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +### Importing a Release |
| 23 | + |
| 24 | +Import packages from your latest release: |
| 25 | + |
| 26 | +`gh-release-apt import owner/repo` |
| 27 | + |
| 28 | +If you want your repository to retain multiple versions, |
| 29 | +do save the resulting `pool/**/Packages` files (to version control or a persistent filesystem) so this release's packages don't have to be downloaded again next time. |
| 30 | + |
| 31 | + |
| 32 | +### Building the Repository |
| 33 | + |
| 34 | +With your signing key in the `SIGNING_KEY` environment variable, run: |
| 35 | + |
| 36 | +`gh-release-apt assemble` |
| 37 | + |
| 38 | +Then deploy to your server—_excluding_ the `.deb` files themselves. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +## Design |
| 43 | + |
| 44 | +The key feature we rely on is that apt will follow redirects. |
| 45 | +This means we *can* keep using standard GitHub Release asset hosting for the packages themselves— |
| 46 | +which is great, because we don't want the overhead of storing extra copies of them, |
| 47 | +GitHub keeps paying for the bandwidth, |
| 48 | +and the project's download analytics keep working. |
| 49 | + |
| 50 | +[GitHub Pages doesn't offer a way to configure redirects](https://github.com/orgs/community/discussions/86095), |
| 51 | +but other hosts do offer this in their static web hosting features.[^2] |
| 52 | +There is, however, often a limit on the number of redirect rules. |
| 53 | +For that reason, we organize the repository's package pool so it's easy to map back to GitHub URLs with a single rule (instead of Debian's alphabetized structure). |
| 54 | + |
| 55 | +[^2]: including [GitLab Pages](https://docs.gitlab.com/user/project/pages/redirects/), |
| 56 | +[CloudFlare Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/redirects/), |
| 57 | +[AWS S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-page-redirect.html) or |
| 58 | +[AWS Amplify](https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html), |
| 59 | +[NearlyFreeSpeech](https://faq.nearlyfreespeech.net/full/htaccess#htaccess), |
| 60 | +[Firebase](https://firebase.google.com/docs/hosting/full-config#redirects), |
| 61 | +[Netlify](https://docs.netlify.com/manage/routing/redirects/overview/), |
| 62 | +[Vercel](https://vercel.com/docs/redirects/configuration-redirects), |
| 63 | +[Digital Ocean](https://docs.digitalocean.com/products/app-platform/how-to/url-rewrites/#configure-a-redirect), |
| 64 | +[Render](https://render.com/docs/redirects-rewrites), |
| 65 | +[pico.sh](https://pico.sh/pgs#-redirects), |
| 66 | +[Codeberg](https://docs.codeberg.org/codeberg-pages/redirects/), |
| 67 | +etc. |
| 68 | + |
| 69 | + |
| 70 | +## Appendix: Creating a Signing Key |
| 71 | + |
| 72 | +This is not the only way to create a signing key, but if you don't have one already, |
| 73 | +this creates a minimal key for signing only. |
| 74 | + |
| 75 | +```sh |
| 76 | +sq key generate --without-password --can-sign --cannot-encrypt --cannot-authenticate --shared-key --no-userids |
| 77 | +sq cert export --cert $FINGERPRINT | sq packet dearmor --output archive-keyring.pgp |
| 78 | +sq key export --cert $FINGERPRINT | gh secret set SIGNING_KEY |
| 79 | +``` |
| 80 | + |
| 81 | +See [DebianRepository/UseThirdParty](https://wiki.debian.org/DebianRepository/UseThirdParty#OpenPGP_certificate_distribution) |
| 82 | +for recommendations on where to name and place the certificate. |
0 commit comments