diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5651b9dc..0115eeee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,17 +4,24 @@ on: push: tags: - 'v*' + # A manual run packages package.json's version from any branch and keeps the files as run artifacts: it neither waits + # for Check nor publishes. + workflow_dispatch: permissions: {} env: NFPM_VERSION: 2.47.0 NFPM_SHA256: 0660ca602b2d2d2ae4781a06c692b3eeb9d437ffea05b831d76e41f4a3188783 + ALPINE_IMAGE: alpine:3.24.2@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6 + # The OpenWrt packages are PKGARCH all, so any target's SDK builds them. + OPENWRT_SDK_IMAGE: openwrt/sdk:x86-64-25.12.5@sha256:e916b7cc555890bdc4725c926e139b888294f0c8f56561b88d8da3a6348616a2 jobs: # A tag points at a commit that main's Check already ran the browser suite on, so the release waits for that run # instead of repeating the suite serially. verified: + if: github.event_name == 'push' runs-on: ubuntu-latest timeout-minutes: 40 permissions: @@ -36,6 +43,7 @@ jobs: build: needs: [verified] + if: ${{ !cancelled() && (needs.verified.result == 'success' || github.event_name == 'workflow_dispatch') }} runs-on: ubuntu-latest permissions: contents: read @@ -58,9 +66,11 @@ jobs: - name: Check the tag against package.json id: version run: | - eval "$(tools/version.sh "${GITHUB_REF_NAME}")" + tag=${GITHUB_REF_NAME} + [ "$GITHUB_EVENT_NAME" = push ] || tag=v$(node -p 'require("./package.json").version') + eval "$(tools/version.sh "$tag")" declared=$(node -p 'require("./package.json").version') - [ "$NPM" = "$declared" ] || { echo "tag ${GITHUB_REF_NAME} is version $NPM, package.json says $declared" >&2; exit 1; } + [ "$NPM" = "$declared" ] || { echo "tag $tag is version $NPM, package.json says $declared" >&2; exit 1; } { echo "VERSION=$VERSION" echo "PRERELEASE=$PRERELEASE" @@ -72,7 +82,48 @@ jobs: - run: pnpm check - run: pnpm build - run: pnpm check:size - - run: tools/package.sh --git-version + - name: Install asset compressors + run: sudo apt-get update && sudo apt-get install -y brotli gzip + - name: Package the archives + run: | + if [ "$GITHUB_EVENT_NAME" = push ]; then tools/package.sh --git-version; else tools/package.sh; fi + # Temporary: honk has no release with the native API yet, so every doona release carries the honk debug builds of the + # tag pinned in tools/honk-pin.txt, the source archive of their commit and a note naming it. fetch-honk.mjs reads that + # tag's own release and fails unless its body, target and source tag name the pinned tag and commit. Remove this step, + # that file and the three honk lines in release's `files` once honk ships one. + - name: Bundle the honk-core debug builds + env: + GH_TOKEN: ${{ github.token }} + run: | + node tools/fetch-honk.mjs release + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: archives + path: | + release/ + !release/SHA256SUMS + if-no-files-found: error + retention-days: 1 + + # nfpm builds the deb, rpm, ipk and Arch packages in seconds, so one job runs the four formats in turn. + nfpm: + needs: [build] + if: ${{ !cancelled() && needs.build.result == 'success' }} + runs-on: ubuntu-latest + permissions: + contents: read + env: + VERSION: ${{ needs.build.outputs.VERSION }} + PRERELEASE: ${{ needs.build.outputs.PRERELEASE }} + ARCH_PRERELEASE: ${{ needs.build.outputs.ARCH_PRERELEASE }} + NPM: ${{ needs.build.outputs.NPM }} + PACKAGE_RELEASE: ${{ needs.build.outputs.PACKAGE_RELEASE }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: archives + path: release/ - name: Install nfpm run: | curl -fsSL --retry 3 -o "$RUNNER_TEMP/nfpm.tar.gz" \ @@ -88,9 +139,11 @@ jobs: export SOURCE_DATE_EPOCH program=build/stage/doona/usr/share/doona fonts=build/stage/doona-fonts/usr/share/doona - mkdir -p "$program" "$fonts" + precompressed=build/stage/doona-precompressed/usr/share/doona + mkdir -p "$program" "$fonts" "$precompressed" packages tar -xzf "release/doona-${NPM}.tar.gz" -C "$program" tar -xzf "release/doona-fonts-${NPM}.tar.gz" -C "$fonts" + tar -xzf "release/doona-precompressed-${NPM}.tar.gz" -C "$precompressed" doc=build/stage/doona/usr/share/doc/doona mkdir -p "$doc" build/stage/doona-fonts/usr/share/doc/doona mv "$program"/LICENSE "$program"/LICENSES "$program"/NOTICE "$program"/THIRD-PARTY-NOTICES.txt \ @@ -104,46 +157,111 @@ jobs: # Debian's archive has an unrelated doona, so only the deb carries the -web suffix (see doona.yaml). for packager in deb rpm ipk archlinux; do if [ "$packager" = deb ]; then export PACKAGE_SUFFIX=-web; else export PACKAGE_SUFFIX=; fi - for config in install/nfpm/doona.yaml install/nfpm/doona-fonts.yaml; do + # doona-precompressed depends on exactly this doona version, spelled the way the format spells it. + if [ "$packager" = archlinux ]; then + export DOONA_VERSION="${VERSION}${ARCH_PRERELEASE}-${PACKAGE_RELEASE}" + else + export DOONA_VERSION="${VERSION}${PRERELEASE:+~$PRERELEASE}-${PACKAGE_RELEASE}" + fi + for config in install/nfpm/doona.yaml install/nfpm/doona-fonts.yaml install/nfpm/doona-precompressed.yaml; do if [ "$packager" = archlinux ]; then # nfpm 2.47 needs an explicit default epoch to retain Arch's prerelease in .PKGINFO. arch_config="$RUNNER_TEMP/$(basename "$config")" sed "/^version_schema: semver$/a epoch: '0'" "$config" > "$arch_config" - PRERELEASE="$ARCH_PRERELEASE" nfpm package --config "$arch_config" --packager "$packager" --target release/ + PRERELEASE="$ARCH_PRERELEASE" nfpm package --config "$arch_config" --packager "$packager" --target packages/ else - nfpm package --config "$config" --packager "$packager" --target release/ + nfpm package --config "$config" --packager "$packager" --target packages/ fi done done # Keep upstream SemVer in asset names; package metadata retains each format's own version. - - name: Sum every asset + - name: Name the packages after the upstream version run: | - cd release - if [ -n "$PRERELEASE" ]; then - for name in doona doona-fonts; do - deb="doona-web${name#doona}" + cd packages + for name in doona doona-fonts doona-precompressed; do + deb="doona-web${name#doona}" + if [ -n "$PRERELEASE" ]; then mv "${deb}_${VERSION}~${PRERELEASE}-${PACKAGE_RELEASE}_all.deb" "${deb}_${NPM}-${PACKAGE_RELEASE}_all.deb" mv "${name}-${VERSION}~${PRERELEASE}-${PACKAGE_RELEASE}.noarch.rpm" "${name}-${NPM}-${PACKAGE_RELEASE}.noarch.rpm" mv "${name}_${VERSION}~${PRERELEASE}-${PACKAGE_RELEASE}_all.ipk" "${name}_${NPM}-${PACKAGE_RELEASE}_all.ipk" - done - fi - set -- "doona-${NPM}.tar.gz" "doona-fonts-${NPM}.tar.gz" - for name in doona doona-fonts; do - set -- "$@" "doona-web${name#doona}_${NPM}-${PACKAGE_RELEASE}_all.deb" "${name}-${NPM}-${PACKAGE_RELEASE}.noarch.rpm" \ + fi + ls "${deb}_${NPM}-${PACKAGE_RELEASE}_all.deb" "${name}-${NPM}-${PACKAGE_RELEASE}.noarch.rpm" \ "${name}_${NPM}-${PACKAGE_RELEASE}_all.ipk" "${name}-${VERSION}${ARCH_PRERELEASE}-${PACKAGE_RELEASE}-any.pkg.tar.zst" done - sha256sum "$@" > SHA256SUMS - # Temporary: honk has no release with the native API yet, so every doona release carries the honk debug builds of the - # tag pinned in tools/honk-pin.txt, the source archive of their commit and a note naming it. fetch-honk.mjs reads that - # tag's own release and fails unless its body, target and source tag name the pinned tag and commit. Remove this step, - # that file and the three honk lines in release's `files` once honk ships one. - - name: Bundle the honk-core debug builds - env: - GH_TOKEN: ${{ github.token }} + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: nfpm-packages + path: packages/ + if-no-files-found: error + retention-days: 1 + + alpine: + needs: [build] + if: ${{ !cancelled() && needs.build.result == 'success' }} + runs-on: ubuntu-latest + permissions: + contents: read + env: + NPM: ${{ needs.build.outputs.NPM }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: archives + path: release/ + - name: Build the Alpine packages + run: docker run --rm -v "$PWD:/src" -w /src "$ALPINE_IMAGE" sh tools/package-alpine.sh "$NPM" + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: alpine-packages + path: release/alpine/ + if-no-files-found: error + retention-days: 1 + + openwrt-apk: + needs: [build] + if: ${{ !cancelled() && needs.build.result == 'success' }} + runs-on: ubuntu-latest + permissions: + contents: read + env: + NPM: ${{ needs.build.outputs.NPM }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: archives + path: release/ + # The SDK image builds as its own unprivileged user, which needs to write the output directory. + - name: Build the OpenWrt apk packages + run: | + mkdir -p release/openwrt + chmod 777 release/openwrt + docker run --rm -v "$PWD:/src" -w /src "$OPENWRT_SDK_IMAGE" sh tools/package-openwrt.sh "$NPM" + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: openwrt-packages + path: release/openwrt/ + if-no-files-found: error + retention-days: 1 + + # Collects every package next to the archives and sums them, so the release job only uploads. + sums: + needs: [build, nfpm, alpine, openwrt-apk] + if: ${{ !cancelled() && needs.nfpm.result == 'success' && needs.alpine.result == 'success' && needs.openwrt-apk.result == 'success' }} + runs-on: ubuntu-latest + permissions: {} + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + pattern: '{archives,*-packages}' + path: release/ + merge-multiple: true + - name: Sum every asset run: | - node tools/fetch-honk.mjs release cd release - sha256sum honk-core-debug-*.tar.gz honk-source-*.tar.gz HONK-SOURCE.txt >> SHA256SUMS + sha256sum -- * > "$RUNNER_TEMP/SHA256SUMS" + mv "$RUNNER_TEMP/SHA256SUMS" SHA256SUMS - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: release-assets @@ -152,7 +270,8 @@ jobs: retention-days: 1 release: - needs: [build] + needs: [build, nfpm, alpine, openwrt-apk, sums] + if: github.event_name == 'push' runs-on: ubuntu-latest permissions: contents: write @@ -179,6 +298,10 @@ jobs: release/*-${{ env.NPM }}-${{ env.PACKAGE_RELEASE }}.noarch.rpm release/*_${{ env.NPM }}-${{ env.PACKAGE_RELEASE }}_all.ipk release/*-${{ env.VERSION }}${{ env.ARCH_PRERELEASE }}-${{ env.PACKAGE_RELEASE }}-any.pkg.tar.zst + release/*.apk + release/doona-alpine.rsa.pub + release/doona-openwrt.adb + release/doona-openwrt.pem release/SHA256SUMS release/honk-core-debug-*.tar.gz release/honk-source-*.tar.gz diff --git a/changes/feat-package-precompress.md b/changes/feat-package-precompress.md index af2fc973..66677172 100644 --- a/changes/feat-package-precompress.md +++ b/changes/feat-package-precompress.md @@ -1,3 +1,4 @@ Added - The optional `doona-precompressed` package and archive install `.br` and `.gz` copies of the text assets next to doona's files, so servers can send compressed responses; the main package stays the same size. +- Releases include Alpine and OpenWrt 25.12 apk packages for doona, doona-fonts and doona-precompressed, with the public signing key of each release. diff --git a/install/README.md b/install/README.md index 4836185d..2518652a 100644 --- a/install/README.md +++ b/install/README.md @@ -3,41 +3,51 @@ Each file follows a package that already exists in the target repository; keep them in step with that model rather than with each other. -| File | Modelled on | -| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `nfpm/doona.yaml`, `nfpm/doona-fonts.yaml` | the nfpm configs in [daeuniverse/repo-for-linux](https://github.com/daeuniverse/repo-for-linux/tree/main/nfpm) (`dae.yaml`, `v2ray-rules-dat.yaml`) | -| `openwrt/doona/Makefile` | [openwrt/packages](https://github.com/openwrt/packages) `net/v2ray-geodata` (data-only, `PKGARCH:=all`, `Download/` blocks) and `net/v2raya` (unpacking a release tarball in `Build/Prepare`) | -| `alpine/APKBUILD` | [aports](https://gitlab.alpinelinux.org/alpine/aports) `community/font-noto-cjk` (noarch, subpackage) | -| `gentoo/net-proxy/doona` | the [gentoo-zh overlay](https://github.com/gentoo-zh/overlay)'s dashboards (`net-proxy/zashboard`, `net-proxy/daed` with its upstream `web.zip`): release archives in `SRC_URI`, `doins -r`, fonts behind a USE flag | -| `nix/package.nix` | [nixpkgs](https://github.com/NixOS/nixpkgs) prebuilt web packages using `fetchurl` and `stdenvNoCC` | -| the AUR `doona-bin` (separate repository) | v2rayA's `install/aur/v2raya-bin/PKGBUILD` | +| File | Modelled on | +| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `nfpm/doona.yaml`, `nfpm/doona-fonts.yaml`, `nfpm/doona-precompressed.yaml` | the nfpm configs in [daeuniverse/repo-for-linux](https://github.com/daeuniverse/repo-for-linux/tree/main/nfpm) (`dae.yaml`, `v2ray-rules-dat.yaml`) | +| `openwrt/doona/Makefile` | [openwrt/packages](https://github.com/openwrt/packages) `net/v2ray-geodata` (data-only, `PKGARCH:=all`, `Download/` blocks) and `net/v2raya` (unpacking a release tarball in `Build/Prepare`) | +| `alpine/APKBUILD` | [aports](https://gitlab.alpinelinux.org/alpine/aports) `community/font-noto-cjk` (noarch, subpackage) | +| `gentoo/net-proxy/doona` | the [gentoo-zh overlay](https://github.com/gentoo-zh/overlay)'s dashboards (`net-proxy/zashboard`, `net-proxy/daed` with its upstream `web.zip`): release archives in `SRC_URI`, `doins -r`, fonts behind a USE flag | +| `nix/package.nix` | [nixpkgs](https://github.com/NixOS/nixpkgs) prebuilt web packages using `fetchurl` and `stdenvNoCC` | +| the AUR `doona-bin` (separate repository) | v2rayA's `install/aur/v2raya-bin/PKGBUILD` | -The OpenWrt, Alpine, Gentoo and Nix recipes are unpublished templates, not ready for distribution. -All four consume the prebuilt program archive, with the font archive where enabled. +The OpenWrt, Alpine, Gentoo and Nix recipes are not yet submitted to their repositories. +All four consume the prebuilt program archive, with the font archive where enabled; the OpenWrt and Alpine recipes +also package the precompressed archive. Before submission, replace the marked OpenWrt and Nix hashes using `SHA256SUMS`, generate Alpine checksums with `abuild checksum`, and generate the Gentoo `Manifest` with `ebuild … manifest`. The release workflow generates and attaches `SHA256SUMS`; it does not replace recipe placeholders. -After publishing the assets, fill both OpenWrt hashes, run `abuild checksum`, generate the Gentoo `Manifest` +After publishing the assets, fill the three OpenWrt hashes, run `abuild checksum`, generate the Gentoo `Manifest` with `ebuild doona-0.1.0_beta13.ebuild manifest`, and replace both Nix `lib.fakeHash` values. + +The release workflow builds Alpine and OpenWrt 25.12 apk packages from the APKBUILD and the OpenWrt Makefile, using the +archives of the same run instead of the download URLs: `tools/package-alpine.sh` runs `abuild` in an Alpine 3.24 +container and `tools/package-openwrt.sh` runs the OpenWrt 25.12 SDK. Either script can be run locally the same way; +the usage line at the top of each gives the `docker run` command. The Gentoo template keeps the existing `metadata.xml`; no version-specific metadata change is needed. ## Version spellings The recipes use tag `v0.1.0-beta.13`. Release assets keep the upstream version without the tag's `v`; -package metadata follows each package manager's ordering rules. The same names and versions apply to `doona-fonts`, which the deb names `doona-web-fonts`. +package metadata follows each package manager's ordering rules. The same names and versions apply to `doona-fonts` and +`doona-precompressed`, which the deb names `doona-web-fonts` and `doona-web-precompressed`. -| Format | `doona` asset | Version in package or recipe | -| ---------------- | --------------------------------------------- | --------------------------------------------------- | -| Program archive | `doona-0.1.0-beta.13.tar.gz` | n/a | -| Fonts archive | `doona-fonts-0.1.0-beta.13.tar.gz` | n/a | -| Debian | `doona-web_0.1.0-beta.13-1_all.deb` | `0.1.0~beta.13-1` | -| RPM | `doona-0.1.0-beta.13-1.noarch.rpm` | Version `0.1.0~beta.13`, Release `1` | -| OpenWrt ipk | `doona_0.1.0-beta.13-1_all.ipk` | `0.1.0~beta.13-1` | -| Arch | `doona-0.1.0beta13-1-any.pkg.tar.zst` | pkgver `0.1.0beta13`, pkgrel `1`, default epoch `0` | -| Alpine APKBUILD | Download the program and fonts archives above | pkgver `0.1.0_beta13`, pkgrel `0` | -| Gentoo ebuild | Download the program and fonts archives above | PV `0.1.0_beta13` | -| OpenWrt Makefile | Download the program and fonts archives above | PKG_VERSION `0.1.0_beta13`, PKG_RELEASE `1` | -| Nix recipe | Download the program and fonts archives above | `0.1.0-beta.13` | +| Format | `doona` asset | Version in package or recipe | +| ------------------------------------- | --------------------------------------------- | --------------------------------------------------- | +| Program archive | `doona-0.1.0-beta.13.tar.gz` | n/a | +| Fonts archive | `doona-fonts-0.1.0-beta.13.tar.gz` | n/a | +| Precompressed archive | `doona-precompressed-0.1.0-beta.13.tar.gz` | n/a | +| Debian | `doona-web_0.1.0-beta.13-1_all.deb` | `0.1.0~beta.13-1` | +| RPM | `doona-0.1.0-beta.13-1.noarch.rpm` | Version `0.1.0~beta.13`, Release `1` | +| OpenWrt ipk (24.10 and earlier, opkg) | `doona_0.1.0-beta.13-1_all.ipk` | `0.1.0~beta.13-1` | +| OpenWrt apk (25.12, apk-tools 3) | `doona-0.1.0_beta13-r1.apk` | `0.1.0_beta13-r1` | +| Alpine apk | `doona-0.1.0-beta.13-r0.alpine.apk` | `0.1.0_beta13-r0` | +| Arch | `doona-0.1.0beta13-1-any.pkg.tar.zst` | pkgver `0.1.0beta13`, pkgrel `1`, default epoch `0` | +| Alpine APKBUILD | Download the three archives above | pkgver `0.1.0_beta13`, pkgrel `0` | +| Gentoo ebuild | Download the program and fonts archives above | PV `0.1.0_beta13` | +| OpenWrt Makefile | Download the three archives above | PKG_VERSION `0.1.0_beta13`, PKG_RELEASE `1` | +| Nix recipe | Download the program and fonts archives above | `0.1.0-beta.13` | The beta binary recipes were last exercised against a local `pnpm package` build: `abuild -r` in an Alpine 3.22 container, the OpenWrt SDK for 24.10 (ipk) and 25.12 (apk), and nfpm 2.47 for deb, rpm, ipk and Arch, each @@ -72,6 +82,8 @@ archive has a `fonts/` directory containing the Vite-bundled [Fontsource subsets separate staging directories and install them under `/usr/share/doona` and `/usr/share/doona/fonts`. Nix unpacks the release archives under `$out/share/doona`. nfpm stages the same archives for its packages. The default local invocation uses the version in `package.json`. +The precompressed archive holds a `.br` (brotli -q 11) and a `.gz` (gzip -9 -n) copy of each text asset of at least +1 KiB, at the asset's own path, keeping only the copies that are smaller than the original. For local distribution, run `pnpm build && pnpm package` from the repository root and deploy the program archive from `release/`, plus the font archive if needed. Do not distribute raw `dist/`: it lacks the program's licence @@ -80,6 +92,47 @@ and notice files. For staged installs from a local build, `make install` installs the program and notices, and `make install-fonts` installs the optional Noto subsets and their licence. Both targets accept `DESTDIR` and `PREFIX`. +## Precompressed assets + +`doona-precompressed` installs the `.br` and `.gz` copies next to doona's files, in the same directory, and requires +the doona package of the same version. A server that finds those copies sends the compressed file to a browser that +accepts it, so the UI loads with fewer bytes over the network. Install it on servers and desktops; on a router it is +optional and costs about 1.6 MB of storage. The main package does not grow without it. + +```sh +sudo apt install ./doona-web_-1_all.deb ./doona-web-precompressed_-1_all.deb # Debian, Ubuntu +sudo dnf install ./doona--1.noarch.rpm ./doona-precompressed--1.noarch.rpm # Fedora; zypper on openSUSE +sudo pacman -U doona--1-any.pkg.tar.zst doona-precompressed--1-any.pkg.tar.zst # Arch +opkg install doona_-1_all.ipk doona-precompressed_-1_all.ipk # OpenWrt 24.10 +``` + +For a manual install, extract `doona-precompressed-.tar.gz` into the directory holding doona's files. + +## Installing the apk packages + +Each release builds its apk packages with a signing key generated for that run and attaches the public key. + +Alpine signs every package. Install the key, then the packages: + +```sh +wget -O /etc/apk/keys/doona-alpine.rsa.pub https://github.com/Zakkaus/doona/releases/download//doona-alpine.rsa.pub +apk add ./doona--r0.alpine.apk ./doona-precompressed--r0.alpine.apk +``` + +Without the key, `apk add --allow-untrusted` installs the same files. apk finds the key by its file name, so keep +`doona-alpine.rsa.pub`; a later release replaces it. + +OpenWrt 25.12 signs only the package index, `doona-openwrt.adb`, which names the packages by the file names they are +released under. Download the index and the packages into one directory, install the key, and install from the index: + +```sh +cp doona-openwrt.pem /etc/apk/keys/ +apk add -X /tmp/doona/doona-openwrt.adb doona doona-precompressed +``` + +Alternatively, install the package files directly with `apk add --allow-untrusted ./doona--r1.apk`. +OpenWrt 24.10 and earlier use the ipk files above. + ## Debian package name Debian and Ubuntu ship an unrelated `doona` package, a network fuzzer at version 1.0 that installs into diff --git a/tools/ci-workflows.test.mjs b/tools/ci-workflows.test.mjs index c9054cbc..d699d039 100644 --- a/tools/ci-workflows.test.mjs +++ b/tools/ci-workflows.test.mjs @@ -13,9 +13,16 @@ it('keeps the release write token away from dependency and build steps', () => { expect(writers.map(([name]) => name)).toEqual(['release']); const {build, release: publish} = release.jobs; expect(build.permissions).toEqual({contents: 'read'}); - expect(publish.needs).toContain('build'); + expect(publish.needs).toEqual(expect.arrayContaining(['build', 'nfpm', 'alpine', 'openwrt-apk', 'sums'])); expect(publish.steps.some(step => step.run || step.uses?.startsWith('actions/checkout@'))).toBe(false); - expect(uses(publish, 'actions/download-artifact').with.name).toBe(uses(build, 'actions/upload-artifact').with.name); + expect(uses(publish, 'actions/download-artifact').with.name).toBe(uses(release.jobs.sums, 'actions/upload-artifact').with.name); +}); + +it('publishes and waits for Check only on a tag push', () => { + expect(release.on.push.tags).toEqual(['v*']); + expect(release.on).toHaveProperty('workflow_dispatch'); + expect(release.jobs.verified.if).toBe("github.event_name == 'push'"); + expect(release.jobs.release.if).toBe("github.event_name == 'push'"); }); it('builds the release once, after the Check run on the tagged commit passed', () => { diff --git a/tools/package-alpine.sh b/tools/package-alpine.sh new file mode 100755 index 00000000..d14ce7ee --- /dev/null +++ b/tools/package-alpine.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Builds the Alpine packages from install/alpine/APKBUILD and the archives in release/, as root in an Alpine container: +# docker run --rm -v "$PWD:/src" -w /src alpine:3.24 sh tools/package-alpine.sh 0.1.0-beta.13 +# abuild signs each package with a key generated for this run; release/alpine/ receives the packages and the public +# key as doona-alpine.rsa.pub. +set -eu + +cd "$(dirname "$0")/.." +[ "$#" -eq 1 ] || { echo "Usage: $0 " >&2; exit 1; } +eval "$(tools/version.sh "v$1")" +pkgver=$VERSION${ARCH_PRERELEASE:+_$ARCH_PRERELEASE} +for name in doona doona-fonts doona-precompressed; do + [ -f "release/$name-$NPM.tar.gz" ] || { echo "Missing release/$name-$NPM.tar.gz; run tools/package.sh first" >&2; exit 1; } +done + +apk add --no-cache --quiet abuild +work=$(mktemp -d) +trap 'rm -rf "$work"' 0 +trap 'exit 1' HUP INT TERM +# abuild names the repository after the APKBUILD's grandparent directory. +mkdir -p "$work/alpine/doona" "$work/distfiles" +cp "release/doona-$NPM.tar.gz" "release/doona-fonts-$NPM.tar.gz" "release/doona-precompressed-$NPM.tar.gz" "$work/distfiles/" +sed -e "s/^pkgver=.*/pkgver=$pkgver/" -e "s/^_tag=.*/_tag=v$NPM/" install/alpine/APKBUILD > "$work/alpine/doona/APKBUILD" + +# apk finds the key by the file name abuild records in each signature, so it takes a fixed name. +export PACKAGER='Zakkaus ' +abuild-keygen -n -q +mv "$HOME"/.abuild/*.rsa "$work/doona-alpine.rsa" +mv "$HOME"/.abuild/*.rsa.pub "$work/doona-alpine.rsa.pub" +export PACKAGER_PRIVKEY="$work/doona-alpine.rsa" +# abuild checks the packages against the trusted keys when it indexes them. +cp "$work/doona-alpine.rsa.pub" /etc/apk/keys/ +export SRCDEST="$work/distfiles" REPODEST="$work/packages" + +(cd "$work/alpine/doona" && abuild -F checksum && abuild -F -d) + +pkgrel=$(sed -n 's/^pkgrel=//p' install/alpine/APKBUILD) +mkdir -p release/alpine +for package in "$REPODEST"/alpine/*/*.apk; do + name=${package##*/} + name=${name%-"$pkgver-r$pkgrel".apk} + cp "$package" "release/alpine/$name-$NPM-r$pkgrel.alpine.apk" +done +cp "$work/doona-alpine.rsa.pub" release/alpine/ +ls -l release/alpine diff --git a/tools/package-openwrt.sh b/tools/package-openwrt.sh new file mode 100755 index 00000000..49934192 --- /dev/null +++ b/tools/package-openwrt.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Builds the OpenWrt apk packages from install/openwrt/doona/Makefile and the archives in release/, in the OpenWrt SDK +# container (any target: the packages are PKGARCH all): +# docker run --rm -v "$PWD:/src" -w /src openwrt/sdk:x86-64-25.12.5 sh tools/package-openwrt.sh 0.1.0-beta.13 +# The SDK signs only the package index, with a key generated for this run. release/openwrt/ receives the packages +# under the names that index records, the index as doona-openwrt.adb and its public key as doona-openwrt.pem. +set -eu + +cd "$(dirname "$0")/.." +[ "$#" -eq 1 ] || { echo "Usage: $0 " >&2; exit 1; } +eval "$(tools/version.sh "v$1")" +pkgver=$VERSION${ARCH_PRERELEASE:+_$ARCH_PRERELEASE} +for name in doona doona-fonts doona-precompressed; do + [ -f "release/$name-$NPM.tar.gz" ] || { echo "Missing release/$name-$NPM.tar.gz; run tools/package.sh first" >&2; exit 1; } +done +repo=$PWD +sdk=${OPENWRT_SDK:-/builder} + +mkdir -p "$sdk/package/doona" "$sdk/dl" +# The archives in dl/ stand in for the Download blocks; their hashes were checked when release/ was built. +sed -e "s/^PKG_VERSION:=.*/PKG_VERSION:=$pkgver/" -e "s/^PKG_REAL_VERSION:=.*/PKG_REAL_VERSION:=$NPM/" \ + -e 's/^\([[:space:]]*\(PKG_\)\{0,1\}HASH:=\).*/\1skip/' \ + install/openwrt/doona/Makefile > "$sdk/package/doona/Makefile" +cp "release/doona-$NPM.tar.gz" "release/doona-fonts-$NPM.tar.gz" "release/doona-precompressed-$NPM.tar.gz" "$sdk/dl/" + +cd "$sdk" +printf 'CONFIG_PACKAGE_%s=m\n' doona doona-fonts doona-precompressed >> .config +make defconfig +make package/doona/compile package/index V=s + +pkgrel=$(sed -n 's/^PKG_RELEASE:=//p' "$repo/install/openwrt/doona/Makefile") +mkdir -p "$repo/release/openwrt" +for name in doona doona-fonts doona-precompressed; do + cp bin/packages/*/base/"$name-$pkgver-r$pkgrel.apk" "$repo/release/openwrt/" +done +cp bin/packages/*/base/packages.adb "$repo/release/openwrt/doona-openwrt.adb" +cp public-key.pem "$repo/release/openwrt/doona-openwrt.pem" +ls -l "$repo/release/openwrt"