Skip to content

Commit 302d146

Browse files
committed
build termux
1 parent 5780f8f commit 302d146

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/build-termux.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build for Termux
2+
3+
# https://github.com/robertkirkman/termux-on-gha/blob/master/.github/workflows/build-and-test.yml
4+
# https://github.com/termux/termux-docker/issues/64
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- build-termux
11+
12+
jobs:
13+
working:
14+
strategy:
15+
matrix:
16+
include:
17+
- runner: ubuntu-24.04-arm
18+
architecture: aarch64
19+
runs-on: ${{ matrix.runner }}
20+
# prepare writable volume prefix mount for actions/upload-artifact,
21+
# based on the higher-profile workaround for 32-bit GNU/Linux containers explained here
22+
# https://github.com/actions/upload-artifact/issues/616#issuecomment-2350667347
23+
container:
24+
image: termux/termux-docker:${{ matrix.architecture }}
25+
volumes:
26+
- /tmp/node20:/__e/node20
27+
28+
# approximate environment variables for actions that can't be forced to use entrypoint.sh
29+
env:
30+
TERMUX_MAIN_PACKAGE_FORMAT: debian
31+
ANDROID_ROOT: /system
32+
ANDROID_DATA: /data
33+
PREFIX: /data/data/com.termux/files/usr
34+
HOME: /data/data/com.termux/files/home
35+
PATH: /data/data/com.termux/files/usr/bin
36+
TMPDIR: /data/data/com.termux/files/usr/tmp
37+
LANG: en_US.UTF-8
38+
TZ: UTC
39+
steps:
40+
- name: set pkg command to use the packages-cf.termux.dev mirror
41+
run: ln -sf ${PREFIX}/etc/termux/mirrors/default ${PREFIX}/etc/termux/chosen_mirrors
42+
- name: upgrade all packages to prepare for installing nodejs
43+
run: /entrypoint.sh bash -c "yes | pkg upgrade -y"
44+
# actions/checkout will "think" that termux's tar binary isn't executable if it doesn't have
45+
# executable bit actually set for all users, since even though that permissions restriction
46+
# doesn't actually apply to the root user (at least on Android), GitHub Actions' internal
47+
# source code doesn't "care" and would refuse to run the binary anyway.
48+
# relevant internal source code of GitHub Actions:
49+
# https://github.com/actions/toolkit/blob/930c89072712a3aac52d74b23338f00bb0cfcb24/packages/io/src/io-util.ts#L167-L177
50+
- name: fix executable bit for all binaries in $PREFIX/bin for all users
51+
run: chmod -R o+x ${PREFIX}/bin
52+
- name: install bionic-libc nodejs to force compatibility with actions/checkout and actions/upload-artifact
53+
run: |
54+
/entrypoint.sh pkg install -y nodejs-lts
55+
ln -sf ${PREFIX}/bin /__e/node20/bin
56+
- uses: actions/checkout@v4.2.2
57+
- name: fix permissions of repository after actions/checkout, which ran as root user, while entrypoint.sh activates system user (1000)
58+
run: chown -R 1000:1000 .
59+
- name: setup
60+
run: |
61+
# pkg/pip need to be prefixed with /entrypoint.sh because GHA overrode
62+
# the entrypoint.
63+
/entrypoint.sh pkg install -y build-esstial cargo
64+
- name: build
65+
run: |
66+
/entrypoint.sh pkg install -y rust
67+
/entrypoint.sh cargo build --release
68+
69+
# build:
70+
# runs-on: ubuntu-latest # Or another suitable runner
71+
# container: termux/termux-docker:latest # Use the termux-docker image
72+
# steps:
73+
# - name: Checkout code
74+
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4
75+
# with:
76+
# ref: ${{ inputs.ref }}
77+
# fetch-depth: 0
78+
# - name: Build with Cargo for Termux
79+
# run: |
80+
# pkg install -y build-essential cargo
81+
# echo "123"
82+
# cargo build --release

0 commit comments

Comments
 (0)