Source Code Update #42
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
# | |
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
# https://github.com/P3TERX/Actions-OpenWrt | |
# Description: Build OpenWrt using GitHub Actions | |
# | |
name: Build ImmortalWrt | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
ssh: | |
description: 'SSH connection to Actions' | |
required: false | |
default: 'false' | |
type: boolean | |
nocache: | |
description: 'Clean Building Cache' | |
required: false | |
default: 'false' | |
type: boolean | |
env: | |
REPO_URL: https://github.com/immortalwrt/immortalwrt | |
REPO_BRANCH: openwrt-24.10 | |
BRANCH_NAME: ImmortalWrt | |
FEEDS_CONF: feeds.conf.default | |
CONFIG_FILE: .config | |
DIY_P1_SH: diy-part1.sh | |
DIY_P2_SH: diy-part2.sh | |
UPLOAD_BIN_DIR: false | |
UPLOAD_FIRMWARE: true | |
UPLOAD_RELEASE: true | |
TZ: UTC | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Free up disk space | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo timedatectl set-timezone "$TZ" | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo bash -c 'bash <(curl -s https://build-scripts.immortalwrt.org/init_build_environment.sh)' | |
sudo -E apt -y autoremove --purge | |
sudo mkdir -p /workdir | |
sudo chown $USER:$GROUPS /workdir | |
- name: Free up disk space again | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: true | |
android: false | |
dotnet: false | |
haskell: false | |
large-packages: false | |
docker-images: false | |
swap-storage: false | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Clone source code | |
working-directory: /workdir | |
run: | | |
df -hT $PWD | |
git clone --depth=1 $REPO_URL -b $REPO_BRANCH openwrt | |
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt | |
- name: Free up disk space again again | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo mkdir -p -m 777 /mnt/openwrt/dl /mnt/openwrt/staging_dir /mnt/openwrt/build_dir | |
ln -sf /mnt/openwrt/dl openwrt/dl | |
ln -sf /mnt/openwrt/staging_dir openwrt/staging_dir | |
ln -sf /mnt/openwrt/build_dir openwrt/build_dir | |
- name: Cache | |
uses: stupidloud/cachewrtbuild@main | |
with: | |
ccache: 'true' | |
prefix: ${{ github.workspace }}/openwrt | |
clean: ${{ inputs.nocache }} | |
mixkey: 'x86-64' | |
- name: Load custom feeds | |
run: | | |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default | |
chmod +x $DIY_P1_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$DIY_P1_SH | |
- name: Update feeds | |
run: cd openwrt && ./scripts/feeds update -a | |
- name: Install feeds | |
run: cd openwrt && ./scripts/feeds install -a -f | |
- name: Load custom configuration | |
run: | | |
[ -e files ] && mv files openwrt/files | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config | |
chmod +x $DIY_P2_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$DIY_P2_SH | |
cat package/emortal/default-settings/files/99-default-settings | |
- name: Set variables | |
run: | | |
echo "BUILD_TIME=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
echo "BUILD_NUMBER=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
cd openwrt | |
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
- name: Make Easy Update Script happy | |
run: | | |
sed -i "/exit 0/i\sed -i '/DISTRIB_GITHUB/d' /etc/openwrt_release" openwrt/package/emortal/default-settings/files/99-default-settings | |
sed -i "/DISTRIB_GITHUB/a\echo \"DISTRIB_GITHUB=\'https://github.com/${{github.repository}}\'\" >> /etc/openwrt_release" openwrt/package/emortal/default-settings/files/99-default-settings | |
sed -i "/exit 0/i\sed -i '/DISTRIB_VERSIONS/d' /etc/openwrt_release" openwrt/package/emortal/default-settings/files/99-default-settings | |
sed -i "/DISTRIB_VERSIONS/a\echo \"DISTRIB_VERSIONS=\'${{ env.BUILD_TIME }}_${{ env.BUILD_NUMBER }}\'\" >> /etc/openwrt_release" openwrt/package/emortal/default-settings/files/99-default-settings | |
sudo chmod +x openwrt/files/usr/bin/easyupdate.sh | |
- name: SSH connection to Actions | |
uses: lhotari/action-upterm@main | |
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh') | |
- name: Download package | |
id: package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile the firmware | |
id: compile | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 || make -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Check space usage | |
if: (!cancelled()) | |
run: df -hT | |
- name: Upload bin directory | |
uses: actions/upload-artifact@main | |
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' && !cancelled() | |
with: | |
name: ${{ env.BRANCH_NAME }}_bin_${{ env.DEVICE_NAME }}_${{ env.BUILD_TIME }}_${{ env.BUILD_NUMBER }} | |
path: openwrt/bin | |
- name: Get environment path | |
id: environment | |
if: env.UPLOAD_BIN_DIR == 'true' && !cancelled() | |
run: | | |
cd openwrt/bin/ | |
echo "WORKSPACE_DIR=$PWD" >> $GITHUB_ENV | |
cd targets/*/* | |
echo "UPLOAD_PATH=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Compressed kernel packages | |
uses: thedoctor0/zip-release@master | |
if: steps.environment.outputs.status == 'success' && steps.compile.outputs.status == 'success' && !cancelled() | |
with: | |
type: tar | |
path: packages/ | |
directory: ${{ env.UPLOAD_PATH }}/ | |
filename: ${{ env.UPLOAD_PATH }}/${{ env.BRANCH_NAME }}_firmware_kernel_packages_${{ env.DEVICE_NAME }}_${{ env.BUILD_TIME }}_${{ env.BUILD_NUMBER }}.tar.gz | |
- name: Compressed firmware packages | |
uses: thedoctor0/zip-release@master | |
if: steps.environment.outputs.status == 'success' && steps.compile.outputs.status == 'success' && !cancelled() | |
with: | |
type: tar | |
path: packages/ | |
directory: ${{ env.WORKSPACE_DIR }}/ | |
filename: ${{ env.UPLOAD_PATH }}/${{ env.BRANCH_NAME }}_firmware_packages_${{ env.DEVICE_NAME }}_${{ env.BUILD_TIME }}_${{ env.BUILD_NUMBER }}.tar.gz | |
- name: Organize files | |
id: organize | |
if: env.UPLOAD_FIRMWARE == 'true' && steps.compile.outputs.status == 'success' && !cancelled() | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload firmware directory to artifact | |
uses: actions/upload-artifact@main | |
if: steps.organize.outputs.status == 'success' && !cancelled() | |
with: | |
name: ${{ env.BRANCH_NAME }}_firmware_${{ env.DEVICE_NAME }}_${{ env.BUILD_TIME }}_${{ env.BUILD_NUMBER }} | |
path: ${{ env.FIRMWARE }} | |
- name: Upload firmware to release | |
uses: softprops/action-gh-release@master | |
if: env.UPLOAD_RELEASE == 'true' && steps.compile.outputs.status == 'success' && !cancelled() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: ${{ env.FIRMWARE }}/* | |
name: ${{ env.BRANCH_NAME }} ${{ env.DEVICE_NAME }} | |
tag_name: ${{ env.BRANCH_NAME }}_${{ env.DEVICE_NAME }}_${{ env.BUILD_TIME }}_${{ env.BUILD_NUMBER }} | |