Build Padavan #19
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: Build Padavan | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
env: | |
REPO_URL: https://github.com/MeIsReallyBa/padavan-4.4 | |
REPO_BRANCH: main | |
UPLOAD_RELEASE: true | |
TNAME: RM2100 | |
CONFIG_FILE: RM2100.config | |
XRAYCONFIG_FILE: genxrayconfig.lua | |
SHADOWSOCKSFILE: Shadowsocks.asp | |
XRAY_FILE: xray | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Prepare environment | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo -E apt-get -qq update | |
sudo -E apt-get -qq install libtool-bin gperf python3-docutils autopoint gettext zip | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "Asia/Shanghai" | |
- name: Clone source | |
if: (!cancelled()) | |
run: | | |
df -hT $PWD | |
git clone --depth=1 $REPO_URL -b $REPO_BRANCH /opt/rt-n56u | |
- name: Load custom configuration | |
run: | | |
mv -f $CONFIG_FILE /opt/rt-n56u/trunk/configs/templates/$TNAME.config | |
mv -f $XRAYCONFIG_FILE /opt/rt-n56u/trunk/user/shadowsocks/ss/genxrayconfig.lua | |
mv -f $SHADOWSOCKSFILE /opt/rt-n56u/trunk/user/www/n56u_ribbon_fixed/Shadowsocks.asp | |
mv -f $XRAY_FILE /opt/rt-n56u/trunk/user/xray/xray | |
- name: Download toolchain | |
if: (!cancelled()) | |
run: | | |
cd /opt/rt-n56u/toolchain-mipsel | |
sh dl_toolchain.sh | |
- name: Compile the firmware | |
if: (!cancelled()) | |
id: compile | |
run: | | |
cd /opt/rt-n56u/trunk | |
cp -f configs/templates/$TNAME.config .config | |
sudo ./build_firmware_modify $TNAME 0 | |
echo "status=success" >> $GITHUB_OUTPUT | |
echo "FILE_DATE=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
- name: Upload firmware directory | |
uses: actions/upload-artifact@v3 | |
if: steps.compile.outputs.status == 'success' && !cancelled() | |
with: | |
name: Padavan_firmware_${{ env.TNAME }}_${{ env.FILE_DATE }} | |
path: /opt/rt-n56u/trunk/images | |
- name: Generate release tag | |
id: tag | |
if: steps.compile.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled() | |
run: | | |
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT | |
touch release.txt | |
echo "## MeIsReallyBa Padavan-4.4 Release $(date +"%Y.%m.%d-%H:%M")" >> release.txt | |
echo "- Source code:" >> release.txt | |
echo " ${{ env.REPO_URL }}/tree/${{ env.REPO_BRANCH }}" >> release.txt | |
echo "- ${{ env.TNAME }}.trx" >> release.txt | |
echo " md5sum: $(md5sum /opt/rt-n56u/trunk/images/*.trx | cut -d" " -f1)" >> release.txt | |
echo " sha256: $(sha256sum /opt/rt-n56u/trunk/images/*.trx | cut -d" " -f1)" >> release.txt | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload firmware to release | |
uses: softprops/action-gh-release@v1 | |
if: steps.tag.outputs.status == 'success' && !cancelled() | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
tag_name: ${{ steps.tag.outputs.release_tag }} | |
body_path: release.txt | |
files: | | |
/opt/rt-n56u/trunk/images/*.trx | |
/opt/rt-n56u/trunk/configs/templates/${{ env.TNAME }}.config | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ github.token }} | |
repository: ${{ github.repository }} | |
retain_days: 1 | |
keep_minimum_runs: 3 | |
- name: Remove old Releases | |
uses: dev-drprasad/[email protected] | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
with: | |
keep_latest: 3 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ github.token }} |