dev build #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: dev build | |
# description: | |
on: | |
workflow_dispatch: | |
inputs: | |
zt_version: | |
description: 'zt标签/Tag' | |
required: false | |
type: string | |
default: '' | |
# push: | |
# branches: | |
# - dev | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: dev | |
fetch-depth: 0 | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo apt install -y xz-utils make git wget zip bash | |
echo "${{ github.action_path }}" | |
latest_version=$(wget --no-check-certificate -qO- "https://api.github.com/repos/stunnel/static-curl/releases" | grep "tag_name" | grep -oE "[0-9.]*" | head -1) | |
zerotier_latest_version=${{ inputs.zt_version }} | |
if [ -z ${zerotier_latest_version} ];then | |
zerotier_latest_version=$(wget --no-check-certificate -qO- "https://api.github.com/repos/zerotier/ZeroTierOne/releases" | grep "tag_name" | grep -oE "[0-9.]*" | head -1) | |
fi | |
# 将zt最新版写入到环境变量 | |
echo "VERSION=$zerotier_latest_version" >> $GITHUB_ENV | |
download_link="https://github.com/stunnel/static-curl/releases/download/${latest_version}/curl-linux-aarch64-musl-${latest_version}.tar.xz" | |
echo ${download_link} | |
wget -O curl.tar.xz ${download_link} | |
wget -O curl32.tar.xz https://github.com/stunnel/static-curl/releases/download/${latest_version}/curl-linux-armv7-musl-${latest_version}.tar.xz | |
tar -xJf curl.tar.xz -C $PWD/bin curl | |
tar -xJf curl32.tar.xz curl | |
wget -O $PWD/bin/cacert.pem https://curl.se/ca/cacert.pem | |
mkdir $PWD/toolchain | |
wget -O arm64.tar.xz "https://dl.armbian.com/_toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz" | |
wget -O arm.tar.xz "https://dl.armbian.com/_toolchain/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz" | |
xz -d arm64.tar.xz | |
xz -d arm.tar.xz | |
tar -xvf arm64.tar -C $PWD/toolchain | |
tar -xvf arm.tar -C $PWD/toolchain | |
rm -f arm64.tar arm.tar curl.tar.xz curl32.tar.xz | |
- name: Update versionCode | |
run: | | |
module_version=$(grep -w 'version' module.prop |awk -F'=' '{print $2}') | |
module_versionCode=$(grep -w 'versionCode' module.prop |awk -F'=' '{print $2}') | |
echo "Scheduled event triggered this workflow" | |
versionCode=$(expr 10000 + $(git rev-list --count HEAD) + 200) | |
echo "MODULE_VERSION=$versionCode" >> $GITHUB_ENV | |
echo 'id=ZeroTierForKSU' >module.prop | |
echo 'name=ZeroTier For KernelSU' >>module.prop | |
echo "version=${versionCode}" >>module.prop | |
echo "versionCode=${versionCode}" >>module.prop | |
echo 'author=powerAn2020' >>module.prop | |
echo 'description=ZeroTier(${{ env.VERSION }}) with UI interface (DEV)' >>module.prop | |
git config --global user.email "[email protected]" | |
MESSAGE=$(git log -1 --pretty=%B) | |
echo "commit MESSAGE: $MESSAGE" | |
echo $MESSAGE > changelog_dev.md | |
git config --global user.name "github action" | |
git add changelog_dev.md | |
echo "COMMIT=1" >> $GITHUB_ENV | |
- name: Build Zerotier for arm64 | |
run: | | |
export PATH="$PWD/toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin/:${PATH}" | |
git clone https://github.com/zerotier/ZeroTierOne.git --depth=1 -b ${{ env.VERSION }} | |
cp -rf ZeroTierOne ZeroTierOne_ARM | |
cd ZeroTierOne | |
make -j $(nproc) ZT_STATIC=1 ZT_DEBUG=0 ZT_SSO_SUPPORTED=0 CC=aarch64-none-linux-gnu-gcc CXX=aarch64-none-linux-gnu-g++ LDFLAGS="-s" | |
cp -rf zerotier-one ../zerotier-one-arm64 | |
- name: Build Zerotier for arm | |
run: | | |
export PATH="$PWD/toolchain/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/bin/:${PATH}" | |
cd ZeroTierOne_ARM | |
make -j -j $(nproc) ZT_STATIC=1 ZT_DEBUG=0 CC=arm-none-linux-gnueabihf-gcc CXX=arm-none-linux-gnueabihf-g++ LDFLAGS="-s" | |
cp -rf zerotier-one ../zerotier-one-arm | |
- name: Build UI | |
run: | | |
cd ui-src | |
npm install | |
npm audit fix | |
npm run build | |
mv dist/* ../webroot/ | |
- name: Generate module for arm64/arm | |
run: | | |
# rm -rf ZeroTierOne ZeroTierOne_ARM toolchain ui-src update_arm64.json update_arm.json update_arm64_dev.json update_arm_dev.json build.sh changelog_dev.md | |
mv zerotier-one-arm64 zerotier-one | |
ls -la | |
echo 'updateJson=https://raw.githubusercontent.com/powerAn2020/ZeroTierOneForKSU/dev/update_arm64_dev.json' >>module.prop | |
bash build.sh ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}.zip | |
unzip -d ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }} ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}.zip | |
mv -f zerotier-one-arm zerotier-one | |
mv -f curl bin/curl | |
sed -i "s/update_arm64/update_arm/g" module.prop | |
bash build.sh ZeroTierForKSU-arm-${{ env.MODULE_VERSION }}.zip | |
unzip -d ZeroTierForKSU-arm-${{ env.MODULE_VERSION }} ZeroTierForKSU-arm-${{ env.MODULE_VERSION }}.zip | |
- name: Upload artifact | |
id: arm64-zip | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }} | |
path: ./ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}/* | |
retention-days: 7 | |
- name: Upload artifact | |
id: arm-zip | |
# v2版本好像不会压缩包套压缩包,还没试 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ZeroTierForKSU-arm-${{ env.VERSION }} | |
path: ./ZeroTierForKSU-arm-${{ env.VERSION }}/* | |
retention-days: 7 | |
- name: 输出 Artifact 下载地址 | |
run: | | |
echo "Artifact1 下载地址: ${{ steps.arm-zip.outputs.artifact-url }}" | |
echo "Artifact2 下载地址: ${{ steps.arm64-zip.outputs.artifact-url }}" | |
echo '{"version":"${{ env.VERSION }}","versionCode":'${{env.MODULE_VERSION}}',"zipUrl":"${{ steps.arm64-zip.outputs.artifact-url }}","changelog":"https://raw.githubusercontent.com/powerAn2020/ZeroTierOneForKSU/dev/changelog_dev.md"}' >update_arm64_dev.json | |
echo '{"version":"${{ env.VERSION }}","versionCode":'${{env.MODULE_VERSION}}',"zipUrl":"${{ steps.arm-zip.outputs.artifact-url }}","changelog":"https://raw.githubusercontent.com/powerAn2020/ZeroTierOneForKSU/dev/changelog_dev.md"}' >update_arm_dev.json | |
- name: update json | |
run: | | |
git add update_arm64_dev.json update_arm_dev.json changelog_dev.md | |
git commit -m "update Zerotier version:${{env.VERSION}}" | |
echo "COMMIT=1" >> $GITHUB_ENV | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
if: ${{ env.COMMIT == '1' }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: dev | |
- name: Manual Release | |
uses: softprops/action-gh-release@v2 | |
if: github.event_name == 'workflow_dispatch' | |
with: | |
prerelease: true | |
generate_release_notes: true | |
tag_name: ${{ env.MODULE_VERSION }} | |
name: ZeroTierForKSU-dev-${{ env.MODULE_VERSION }} | |
files: | | |
ZeroTierForKSU-arm64-${{ env.MODULE_VERSION }}.zip | |
ZeroTierForKSU-arm-${{ env.MODULE_VERSION }}.zip | |