From a1c7663fd9cade2f4261b004a6ef4d6a83b52934 Mon Sep 17 00:00:00 2001 From: vidplace7 Date: Tue, 15 Sep 2026 21:56:51 -0400 Subject: [PATCH] Publish to Cloudflare R2 --- .github/openwrt-repo/README.md | 69 ++++++++++++++++++++++++++ .github/workflows/multi-arch-build.yml | 53 ++++++++++++++++++-- 2 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 .github/openwrt-repo/README.md diff --git a/.github/openwrt-repo/README.md b/.github/openwrt-repo/README.md new file mode 100644 index 0000000..f2c9a75 --- /dev/null +++ b/.github/openwrt-repo/README.md @@ -0,0 +1,69 @@ +# Meshtastic OpenWrt Repo + +Home to our APK and OPKG repositories for easily installing Meshtastic on OpenWrt-supported routers. + +If you're looking for the package source code, check out [meshtastic/openwrt](https://github.com/meshtastic/openwrt). + +## Supported OpenWRT versions +- `SNAPSHOT` (master branch) +- `25.12` (stable) +- `24.10` (old-stable) +- `23.05` (old-stable) +- `22.03` (old-stable) + +## How to use + +This repository is hosted on [Cloudflare R2](https://developers.cloudflare.com/r2/). Repositories use HTTPS protocol and require one of the SSL support packages to be installed on your router. + +### APK +Used in the latest stable OpenWrt versions. + +Supported versions: +- `25.12` + +##### Add APK repository to your OpenWrt device + +```sh +WRT_VER=$( . /etc/openwrt_release; echo "${DISTRIB_RELEASE%%-*}" | cut -d. -f1-2 ) +echo "https://openwrt.meshtastic.org/openwrt-${WRT_VER}/$(cat /etc/apk/arch)/packages.adb" > /etc/apk/repositories.d/meshtastic.list +wget https://openwrt.meshtastic.org/meshtastic-apk.pem -O /etc/apk/keys/meshtastic-apk.pem +apk update +``` + +--- + +### OPKG +Used in old-stable versions of OpenWrt. + +Supported versions: +- `24.10` +- `23.05` +- `22.03` + +##### Add OPKG repository to your OpenWrt device + +```sh +opkg update +opkg install wget-ssl +wget -O /tmp/meshtastic-ipk.pub https://openwrt.meshtastic.org/meshtastic-ipk.pub +opkg-key add /tmp/meshtastic-ipk.pub && rm /tmp/meshtastic-ipk.pub +sed -i '/meshtastic/d' /etc/opkg/customfeeds.conf +ARCH=$( . /etc/openwrt_release; echo "$DISTRIB_ARCH" ) +WRT_VER=$( . /etc/openwrt_release; echo "${DISTRIB_RELEASE%%-*}" | cut -d. -f1-2 ) +echo "src/gz meshtastic https://openwrt.meshtastic.org/openwrt-${WRT_VER}/${ARCH}" >> /etc/opkg/customfeeds.conf +opkg update +``` + +--- + +### Snapshot (master) builds + +For testing only. Please do not file issues about SNAPSHOT builds. + +##### Add APK repository to your OpenWrt device + +```sh +echo "https://openwrt.meshtastic.org/main/$(cat /etc/apk/arch)/packages.adb" > /etc/apk/repositories.d/meshtastic.list +wget https://openwrt.meshtastic.org/meshtastic-apk.pem -O /etc/apk/keys/meshtastic-apk.pem +apk update +``` \ No newline at end of file diff --git a/.github/workflows/multi-arch-build.yml b/.github/workflows/multi-arch-build.yml index 827c702..c84b255 100644 --- a/.github/workflows/multi-arch-build.yml +++ b/.github/workflows/multi-arch-build.yml @@ -108,7 +108,7 @@ jobs: - uses: actions/checkout@v7 - name: Build APK packages ${{ matrix.arch }} - if: ${{ github.ref_name == 'main' || github.ref_name == 'openwrt-25.12' }} + if: github.ref_name == 'main' || github.ref_name == 'openwrt-25.12' uses: openwrt/gh-action-sdk@v11 env: ARCH: "${{ matrix.arch }}-${{ github.ref_name }}" @@ -117,7 +117,7 @@ jobs: INDEX: 1 - name: Build IPK packages ${{ matrix.arch }} - if: ${{ github.ref_name == 'openwrt-24.10' || github.ref_name == 'openwrt-22.03' }} + if: github.ref_name == 'openwrt-24.10' || github.ref_name == 'openwrt-22.03' uses: openwrt/gh-action-sdk@v11 env: ARCH: "${{ matrix.arch }}-${{ github.ref_name }}" @@ -126,7 +126,7 @@ jobs: INDEX: 1 - name: Build IPK packages (23.05) ${{ matrix.arch }} - if: ${{ github.ref_name == 'openwrt-23.05' }} + if: github.ref_name == 'openwrt-23.05' uses: openwrt/gh-action-sdk@v11 env: # Override ARCH to use the last supported release, 23.05.6 @@ -148,7 +148,15 @@ jobs: concurrency: # Only run one deploy at a time group: publish-builds + env: + r2_bucket: meshtastic-openwrt-repo steps: + # Only the repo homepage is needed for the deployment. + - name: Fetch openwrt-repo metadata + uses: actions/checkout@v7 + with: + sparse-checkout: .github/openwrt-repo + - name: Download artifacts uses: actions/download-artifact@v8 with: @@ -164,3 +172,42 @@ jobs: user_name: github-actions[bot] user_email: github-actions[bot]@users.noreply.github.com enable_jekyll: true + + # - name: Render README.md to index.html + # if: github.ref_name == 'main' + # run: > + # pandoc .github/openwrt-repo/README.md -t html5 + # -o ${{ github.ref_name }}/index.html + + - name: Upload packages to Cloudflare R2 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + # R2 is single-region; the S3 API still requires a region to be set. + AWS_DEFAULT_REGION: auto + # Cloudflare's documented aws-cli settings for R2. Left at the AWS + # default, CLI >= 2.23 attaches CRC32 request checksums that R2 can + # reject, so both of these must stay at when_required. + AWS_REQUEST_CHECKSUM_CALCULATION: when_required + AWS_RESPONSE_CHECKSUM_VALIDATION: when_required + R2_ENDPOINT: https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com + run: | + set -euo pipefail + aws --version + r2_sync() { + aws s3 sync "./${{ github.ref_name }}" "s3://${r2_bucket}/${{ github.ref_name }}/" \ + --endpoint-url "$R2_ENDPOINT" \ + --no-progress \ + --delete \ + --metadata "commit=${{ github.sha }},run=${{ github.run_id }}" \ + "$@" + } + # Packages carry their version in the filename, so cache them for + # 1 week in browser, and 1 month on the CDN. + # Uploaded first, so the indexes never point at a missing file. + r2_sync --cache-control 'public, max-age=604800, s-maxage=2592000' \ + --exclude '*' --include '*.apk' --include '*.ipk' + # Indexes (Packages*, index.json, packages.adb) are rewritten by every + # build, so cache them for 1 day in browser and on the CDN. + r2_sync --cache-control 'public, max-age=86400, s-maxage=86400' \ + --exclude '*.apk' --exclude '*.ipk'