From 33c7ba8a3697ddce0b34f93c294c1f1518d95013 Mon Sep 17 00:00:00 2001 From: SyscallBrain <61458775+SyscallBrain@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:14:22 +0000 Subject: [PATCH 1/3] ci: manual phone build (static aarch64 binary as a run artifact) Runs only from workflow_dispatch. Builds aarch64-unknown-linux-musl on an ARM runner, optionally runs fmt, clippy and the tests first, and keeps the binary as a 7-day artifact; nothing is published. --- .github/workflows/phone-build.yml | 96 +++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/phone-build.yml diff --git a/.github/workflows/phone-build.yml b/.github/workflows/phone-build.yml new file mode 100644 index 0000000..eed970b --- /dev/null +++ b/.github/workflows/phone-build.yml @@ -0,0 +1,96 @@ +# Compila o ratclone para o telemóvel (Ubuntu no proot, aarch64) SÓ quando o dono +# o lança à mão. Não publica nada: o binário fica como "artifact" do run e é +# apagado ao fim de 7 dias. +# +# Lançar (no Termux, ou em qualquer sítio com o gh): +# gh workflow run phone-build.yml -R SyscallBrain/ratclone --ref +# gh workflow run phone-build.yml -R SyscallBrain/ratclone --ref -f testes=false +# Seguir e descarregar: +# gh run watch -R SyscallBrain/ratclone --exit-status +# gh run download -R SyscallBrain/ratclone --pattern 'ratclone-*' +name: Phone build (manual) + +# Único gatilho: o botão "Run workflow" ou o "gh workflow run". Nada de push, +# pull_request ou schedule, por isso nunca corre sozinho. +on: + workflow_dispatch: + inputs: + testes: + description: Correr fmt, clippy e os testes antes de compilar + type: boolean + default: true + +# O token automático do run só pode ler o repo. +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + RUST_VERSION: 1.99.1 + # Binário estático (musl): corre em qualquer Linux aarch64, incluindo o + # Ubuntu do proot, seja qual for a versão da glibc lá dentro. + TARGET: aarch64-unknown-linux-musl + +jobs: + build: + # Runner ARM nativo (grátis em repos públicos): compila e testa já na + # mesma arquitectura do telemóvel, sem cross-compile. + runs-on: ubuntu-24.04-arm + timeout-minutes: 45 + steps: + - name: Check out source + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install the Rust toolchain + run: | + rustup toolchain install "$RUST_VERSION" --profile minimal \ + --component rustfmt --component clippy --target "$TARGET" + rustup default "$RUST_VERSION" + sudo apt-get update -qq && sudo apt-get install -y -qq musl-tools + + # Guarda ~/.cargo e target/ entre runs: o segundo build é muito mais rápido. + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 + + - name: Install the current rclone (the tests call it) + if: inputs.testes + run: bash scripts/install-test-rclone.sh latest "$RUNNER_TEMP/rclone" + + - name: Format, lints and tests + if: inputs.testes + run: | + export PATH="$RUNNER_TEMP/rclone:$PATH" + RATCLONE_TEST_RCLONE_VERSION=$(cat "$RUNNER_TEMP/rclone/version") + export RATCLONE_TEST_RCLONE_VERSION + cargo fmt --check + cargo clippy --locked --all-targets -- -D warnings + cargo test --locked + + - name: Build the static binary + run: cargo build --release --locked --target "$TARGET" + + - name: Smoke-test and label the binary + run: | + bin="target/$TARGET/release/ratclone" + "$bin" --version + mkdir out + cp "$bin" out/ + short=$(git rev-parse --short HEAD) + echo "SHORT_SHA=$short" >> "$GITHUB_ENV" + { + echo "repo: $GITHUB_REPOSITORY" + echo "branch: $GITHUB_REF_NAME" + echo "commit: $(git rev-parse HEAD)" + echo "run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + echo "target: $TARGET" + } > out/BUILD-INFO.txt + (cd out && sha256sum ratclone > SHA256SUMS && cat SHA256SUMS BUILD-INFO.txt) + + - name: Upload the binary + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: ratclone-aarch64-${{ env.SHORT_SHA }} + path: out/ + if-no-files-found: error + retention-days: 7 From 28213ecdf848e9e4e6eba0d28558cf039d427d21 Mon Sep 17 00:00:00 2001 From: SyscallBrain <61458775+SyscallBrain@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:24:35 +0000 Subject: [PATCH 2/3] ci: phone build workflow in English, job-scoped permissions, chmod note --- .github/workflows/phone-build.yml | 42 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/phone-build.yml b/.github/workflows/phone-build.yml index eed970b..f2a207a 100644 --- a/.github/workflows/phone-build.yml +++ b/.github/workflows/phone-build.yml @@ -1,42 +1,44 @@ -# Compila o ratclone para o telemóvel (Ubuntu no proot, aarch64) SÓ quando o dono -# o lança à mão. Não publica nada: o binário fica como "artifact" do run e é -# apagado ao fim de 7 dias. +# Builds ratclone for the owner's phone (Ubuntu in proot, aarch64), only when it +# is started by hand. Nothing is published: the binary is kept as a run +# artifact for 7 days. # -# Lançar (no Termux, ou em qualquer sítio com o gh): +# Start it (from Termux, or anywhere with gh): # gh workflow run phone-build.yml -R SyscallBrain/ratclone --ref -# gh workflow run phone-build.yml -R SyscallBrain/ratclone --ref -f testes=false -# Seguir e descarregar: +# gh workflow run phone-build.yml -R SyscallBrain/ratclone --ref -f checks=false +# Follow it and fetch the binary (artifacts are zips, which drop the +# executable bit): # gh run watch -R SyscallBrain/ratclone --exit-status # gh run download -R SyscallBrain/ratclone --pattern 'ratclone-*' +# chmod +x ratclone-*/ratclone name: Phone build (manual) -# Único gatilho: o botão "Run workflow" ou o "gh workflow run". Nada de push, -# pull_request ou schedule, por isso nunca corre sozinho. +# The only trigger is "Run workflow" / "gh workflow run": no push, +# pull_request or schedule, so it never starts on its own. on: workflow_dispatch: inputs: - testes: - description: Correr fmt, clippy e os testes antes de compilar + checks: + description: Run fmt, clippy and the tests before building type: boolean default: true -# O token automático do run só pode ler o repo. -permissions: - contents: read +permissions: {} env: CARGO_TERM_COLOR: always RUST_VERSION: 1.99.1 - # Binário estático (musl): corre em qualquer Linux aarch64, incluindo o - # Ubuntu do proot, seja qual for a versão da glibc lá dentro. + # Static (musl) binary: runs on any aarch64 Linux, the proot Ubuntu + # included, whatever its glibc. TARGET: aarch64-unknown-linux-musl jobs: build: - # Runner ARM nativo (grátis em repos públicos): compila e testa já na - # mesma arquitectura do telemóvel, sem cross-compile. + # Native ARM runner (free on public repos): builds and tests on the + # phone's architecture, no cross-compiling. runs-on: ubuntu-24.04-arm timeout-minutes: 45 + permissions: + contents: read steps: - name: Check out source uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -50,15 +52,15 @@ jobs: rustup default "$RUST_VERSION" sudo apt-get update -qq && sudo apt-get install -y -qq musl-tools - # Guarda ~/.cargo e target/ entre runs: o segundo build é muito mais rápido. + # Keeps ~/.cargo and target/ between runs, so later builds are faster. - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - name: Install the current rclone (the tests call it) - if: inputs.testes + if: inputs.checks run: bash scripts/install-test-rclone.sh latest "$RUNNER_TEMP/rclone" - name: Format, lints and tests - if: inputs.testes + if: inputs.checks run: | export PATH="$RUNNER_TEMP/rclone:$PATH" RATCLONE_TEST_RCLONE_VERSION=$(cat "$RUNNER_TEMP/rclone/version") From c0788b8a14fbe4cc8341a44e784f38da5d148a80 Mon Sep 17 00:00:00 2001 From: SyscallBrain <61458775+SyscallBrain@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:33:43 +0000 Subject: [PATCH 3/3] ci: download the artifact from the watched run --- .github/workflows/phone-build.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/phone-build.yml b/.github/workflows/phone-build.yml index f2a207a..d0bc1f8 100644 --- a/.github/workflows/phone-build.yml +++ b/.github/workflows/phone-build.yml @@ -5,10 +5,12 @@ # Start it (from Termux, or anywhere with gh): # gh workflow run phone-build.yml -R SyscallBrain/ratclone --ref # gh workflow run phone-build.yml -R SyscallBrain/ratclone --ref -f checks=false -# Follow it and fetch the binary (artifacts are zips, which drop the -# executable bit): -# gh run watch -R SyscallBrain/ratclone --exit-status -# gh run download -R SyscallBrain/ratclone --pattern 'ratclone-*' +# Follow it and fetch the binary from that same run (the newest run of this +# workflow; gh run download without a run id would ask which run): +# run=$(gh run list -R SyscallBrain/ratclone -w phone-build.yml -L 1 --json databaseId -q '.[0].databaseId') +# gh run watch "$run" -R SyscallBrain/ratclone --exit-status +# gh run download "$run" -R SyscallBrain/ratclone +# Artifacts are zips, which drop the executable bit, so then: # chmod +x ratclone-*/ratclone name: Phone build (manual)