Skip to content

Build Mihomo Alpha.apk #1366

Build Mihomo Alpha.apk

Build Mihomo Alpha.apk #1366

Workflow file for this run

name: Build Mihomo Alpha.apk
on:
workflow_dispatch:
schedule:
- cron: '0 */2 * * *'
permissions:
actions: write
contents: write
jobs:
build:
name: Build ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [aarch64_generic, x86_64]
steps:
- name: Checkout source tree
uses: actions/checkout@v4
- name: Install deps
run: |
sudo apt update
sudo apt install -y build-essential clang flex bison g++ gawk \
gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev \
python3-setuptools rsync swig unzip zlib1g-dev file wget
- name: Generate build keys
run: |
sudo apt-get update
sudo apt-get install -y signify-openbsd
signify-openbsd -G -n -c 'DO NOT USE - OpenWrt packages feed CI' -p packages_ci.pub -s packages_ci.sec
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "KEY_BUILD<<$EOF" >> $GITHUB_ENV
cat packages_ci.sec >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Setup latest golang release
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Show go version
run: |
go version
- name: Get Mihomo Alpha
run: |
git clone https://github.com/MetaCubeX/mihomo.git -b Alpha
cd mihomo
VER=$(git log -1 --format="%cd" --date=format:'%Y%m%d%H%M%S' | sed s/-//g)
echo "PKG_VER=$VER" >> $GITHUB_ENV
echo "HEAD_REF=$(git rev-parse HEAD)" >> $GITHUB_ENV
cd -
- name: Build
run: |
case "${{ matrix.arch }}" in
aarch64_generic)
TARGET_URL="https://downloads.immortalwrt.org/snapshots/targets/rockchip/armv8/"
;;
x86_64)
TARGET_URL="https://downloads.immortalwrt.org/snapshots/targets/x86/64/"
;;
esac
SDK=$(curl -s -L "${TARGET_URL}sha256sums" | grep sdk | sed 's/.* \*//')
wget "${TARGET_URL}${SDK}" -O sdk.tar.xz
mkdir sdk
tar -I zstd -xf sdk.tar.xz --strip-components=1 -C sdk
cd sdk
./scripts/feeds update -a
wget "${TARGET_URL}config.buildinfo" -O .config
make defconfig
cp -a ../net package/
mv package/net/mihomo/git.Makefile package/net/mihomo/Makefile
sed -i 's/PKG_VERSION:=alpha/PKG_VERSION:=${{ env.PKG_VER }}/g' package/net/mihomo/Makefile
sed -i 's/PKG_SOURCE_VERSION:=Alpha/PKG_SOURCE_VERSION:=${{ env.HEAD_REF }}/g' package/net/mihomo/Makefile
make package/net/mihomo/{download,check} FIXUP=1 V=s
make package/net/mihomo/compile V=s
find bin/packages -name '*.apk' -exec sh -c 'mv "$1" "${1%.apk}_${{ matrix.arch }}.apk"' _ {} \;
FN=$(find bin/packages -name '*.apk' | sort | head -1 | xargs basename)
echo "PKG_NAME=$FN" >> $GITHUB_ENV
cd -
- name: Publishing to GitHub Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: |
sdk/bin/packages/*/*/mihomo*.apk
- name: Read release.md and use it as a body of new release
id: read_release
shell: bash
run: |
r=$(cat README.md)
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/'%0D'}"
echo "RELEASE_BODY=$r" >> $GITHUB_OUTPUT
tag=$(date +"%Y%m%d")
echo "RELEASE_TAG=$tag" >> $GITHUB_OUTPUT
- name: Delete old release assets
uses: mknejp/delete-release-assets@v1
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.read_release.outputs.RELEASE_TAG }}
assets: |
mihomo*_${{ matrix.arch }}.apk
- name: Publishing to GitHub Releases
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: sdk/bin/packages/*/*/mihomo*.apk
tag: ${{ steps.read_release.outputs.RELEASE_TAG }}
file_glob: true
overwrite: true
body: |
${{ steps.read_release.outputs.RELEASE_BODY }}