Skip to content
This repository was archived by the owner on Oct 31, 2026. It is now read-only.

Commit 0bc4378

Browse files
committed
Go live on the redirect worker for APT pool serving
Client root is now the worker URL (install.sh, list, README); APT_POOL_MODE=none so the branch holds metadata only; worker.js uses string matching (no regex literals) after the bundler proved unable to parse them.
1 parent 78a7357 commit 0bc4378

8 files changed

Lines changed: 58 additions & 39 deletions

File tree

‎.github/workflows/apt-repo.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: apt-repo
22

33
# Publishes .deb files from *-android releases to the signed APT repository
4-
# on the gh-pages branch (https://astreele.github.io/opencode-android).
4+
# on the gh-pages branch (https://opencode-android-apt.psmsword148.workers.dev).
55
# install.sh registers that source, so `pkg install opencode2` works and
66
# later updates arrive through `pkg upgrade` like any other program.
77
#
@@ -41,8 +41,8 @@ jobs:
4141
GH_TOKEN: ${{ github.token }}
4242
PAGES_BRANCH: gh-pages
4343
# pool: store .debs on the branch. none: index only (pool/… is served
44-
# by the redirect worker in apt-worker/ — flip once it is live).
45-
APT_POOL_MODE: pool
44+
# by the redirect worker in apt-worker/ — live, so this stays none).
45+
APT_POOL_MODE: none
4646
steps:
4747
- name: Checkout packaging scripts
4848
uses: actions/checkout@v4

‎README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ from just `opencode` — no `opencode2` name, no symlink.
2323
`aarch64`; there is no 32-bit build).
2424
- **~500 MB free** while installing (~200 MB once installed: the
2525
single-binary build plus its `ripgrep`/`libc++` dependencies).
26-
- **Network access** to `astreele.github.io` (package repository),
27-
`raw.githubusercontent.com` and `github.com` (installer/key fallback),
28-
plus your provider's API endpoints at runtime.
26+
- **Network access** to `opencode-android-apt.psmsword148.workers.dev`
27+
(package repository), `raw.githubusercontent.com` and `github.com`
28+
(installer/key fallback), plus your provider's API endpoints at runtime.
2929
- No root needed. The installer fetches its own dependencies (`curl`;
3030
the package pulls in `ripgrep` and `libc++` automatically).
3131

@@ -43,7 +43,7 @@ opencode # TUI
4343
```
4444

4545
The installer registers the signed APT repository
46-
(`https://astreele.github.io/opencode-android`), installs the `opencode2`
46+
(`https://opencode-android-apt.psmsword148.workers.dev`), installs the `opencode2`
4747
package with the system package manager (linking `opencode` → `opencode2`),
4848
and verifies with `opencode2 --version`. Later updates arrive through
4949
`pkg upgrade`, like any other program.
@@ -113,9 +113,9 @@ pkg upgrade # updates opencode2 together with everything else
113113
Manual setup (if you ever need to redo it by hand — the installer does this):
114114

115115
```sh
116-
curl -fsSL https://astreele.github.io/opencode-android/opencode-android.gpg \
116+
curl -fsSL https://opencode-android-apt.psmsword148.workers.dev/opencode-android.gpg \
117117
-o "$PREFIX/etc/apt/trusted.gpg.d/opencode-android.gpg"
118-
echo "deb https://astreele.github.io/opencode-android stable main" \
118+
echo "deb https://opencode-android-apt.psmsword148.workers.dev stable main" \
119119
> "$PREFIX/etc/apt/sources.list.d/opencode-android.list"
120120
pkg update
121121
pkg install opencode2

‎apt-worker/README.md‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,21 @@ release tag `v<ver>-android` (verified: both live 2.0.25/2.0.26 assets
1212
resolve). Non-pool paths are proxied straight to the Pages origin, so the
1313
worker's own domain serves the whole repository from a single `deb` line.
1414

15-
## Deploy (one time, maintainer)
15+
## Deploy (one time, maintainer) — DONE
1616

17-
```sh
18-
npm install -g wrangler
19-
wrangler login
20-
wrangler deploy # note the https://<worker>.<account>.workers.dev URL
21-
```
17+
Live at `https://opencode-android-apt.psmsword148.workers.dev` (deployed
18+
via `wrangler deploy` from this directory; redeploy the same way after any
19+
`worker.js` change).
2220

2321
## Go live checklist
2422

25-
The repository currently runs in `pool` mode (debs stored on the branch) so
26-
nothing breaks while the worker doesn't exist yet. To switch:
27-
28-
1. Deploy the worker above; call its URL `WORKER_URL`.
29-
2. `.github/workflows/apt-repo.yml`: set `APT_POOL_MODE: none`.
30-
3. Point clients at it — replace `https://astreele.github.io/opencode-android`
31-
with `WORKER_URL` in: `install.sh` (`APT_ROOT`), `apt/opencode-android.list`,
32-
`README.md` (install section + manual setup), and here.
23+
1. ~~Deploy the worker~~ — done, URL above.
24+
2. ~~Set `APT_POOL_MODE: none`~~ — done in `.github/workflows/apt-repo.yml`.
25+
3. ~~Point clients at the worker URL~~ — `install.sh` (`APT_ROOT`),
26+
`apt/opencode-android.list`, and `README.md` all use it.
3327
4. Dispatch the `apt-repo` workflow with `reset: true`: the branch is
3428
recreated metadata-only, evicting the stored debs (and their history).
29+
Until this runs, the branch still serves its stored pool — harmless.
3530
5. Verify on a device: fresh `install.sh` run, `apt-cache policy opencode2`,
3631
and a `--download-only` install.
3732

‎apt-worker/worker.js‎

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,44 @@
99
// Mapping: pool/main/opencode2/opencode2_<ver>-<rev>_aarch64.deb comes from
1010
// release tag v<ver>-android, e.g. opencode2_2.0.26-1_aarch64.deb lives on
1111
// v2.0.26-android under the identical filename.
12+
//
13+
// Note: this file deliberately uses no regular-expression literals.
14+
// Wrangler's bundler misparses them in this project, so all matching is
15+
// plain string operations (same greedy-last-dash semantics as before).
1216
export default {
1317
async fetch(request, env) {
1418
const url = new URL(request.url);
15-
const m = url.pathname.match(
16-
/^\/pool\/[^\/]+\/[^\/]+\/(opencode2_(.+)-(\d+)_aarch64\.deb)$,
17-
);
18-
if (m) {
19-
const file = m[1];
20-
const ver = m[2];
21-
const tag = `v${ver}-android`;
22-
return Response.redirect(
23-
`https://github.com/${env.REPO}/releases/download/${tag}/${file}`,
24-
302,
25-
);
19+
let target = null;
20+
if (url.pathname.startsWith("/pool/")) {
21+
const file = url.pathname.slice(url.pathname.lastIndexOf("/") + 1);
22+
const head = "opencode2_";
23+
const tail = "_aarch64.deb";
24+
if (file.startsWith(head) && file.endsWith(tail)) {
25+
const inner = file.slice(head.length, file.length - tail.length);
26+
const dash = inner.lastIndexOf("-");
27+
const ver = inner.slice(0, dash);
28+
const rev = inner.slice(dash + 1);
29+
let revDigits = rev.length > 0;
30+
for (let i = 0; i < rev.length; i++) {
31+
const c = rev.charCodeAt(i);
32+
if (c < 48 || c > 57) {
33+
revDigits = false;
34+
break;
35+
}
36+
}
37+
if (dash > 0 && ver.length > 0 && revDigits) {
38+
target =
39+
"https://github.com/" +
40+
env.REPO +
41+
"/releases/download/v" +
42+
ver +
43+
"-android/" +
44+
file;
45+
}
46+
}
47+
}
48+
if (target) {
49+
return Response.redirect(target, 302);
2650
}
2751
return fetch(env.ORIGIN + url.pathname + url.search, request);
2852
},

‎apt/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# APT repository (`https://astreele.github.io/opencode-android`)
1+
# APT repository (`https://opencode-android-apt.psmsword148.workers.dev`)
22

33
This directory holds the *client-side* files for the Termux package-manager
44
install path; the published repository itself lives on the `gh-pages` branch

‎apt/opencode-android.list‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deb https://astreele.github.io/opencode-android stable main
1+
deb https://opencode-android-apt.psmsword148.workers.dev stable main

‎install.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# bash <(curl -fsSL https://raw.githubusercontent.com/astreele/opencode-android/master/install.sh)
66
#
77
# Default: registers the signed APT repository
8-
# (https://astreele.github.io/opencode-android) and installs/upgrades the
8+
# (https://opencode-android-apt.psmsword148.workers.dev) and installs/upgrades the
99
# opencode2 package with the system package manager. Later updates then
1010
# arrive through `pkg upgrade`, like any other program.
1111
#
@@ -23,7 +23,7 @@
2323
set -e
2424

2525
REPO="astreele/opencode-android"
26-
APT_ROOT="https://astreele.github.io/opencode-android"
26+
APT_ROOT="https://opencode-android-apt.psmsword148.workers.dev"
2727
# The key URL is overridable for tests; the raw.githubusercontent copy is the
2828
# fallback for devices reaching GitHub before Pages serves the branch.
2929
APT_KEY_URL="${APT_KEY_URL:-$APT_ROOT/opencode-android.gpg}"

‎tests/install.bats‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ teardown() {
206206

207207
# repository registration landed under the sandbox prefix
208208
assert_contains "$(cat "$PREFIX_DIR/etc/apt/sources.list.d/opencode-android.list")" \
209-
"deb https://astreele.github.io/opencode-android stable main"
209+
"deb https://opencode-android-apt.psmsword148.workers.dev stable main"
210210
assert_file_exists "$PREFIX_DIR/etc/apt/trusted.gpg.d/opencode-android.gpg"
211211

212212
# the pkg stub laid the packaged files down like apt would

0 commit comments

Comments
 (0)