Skip to content

refactor: route runtime through kamfw #25

refactor: route runtime through kamfw

refactor: route runtime through kamfw #25

Workflow file for this run

name: Build MagicNet
on:
workflow_dispatch:
inputs:
magic-mihomo:
description: Build with mihomo core
required: false
type: boolean
default: true
magic-singbox:
description: Build with sing-box core
required: false
type: boolean
default: true
release:
description: Create GitHub release and upload artifacts
required: false
type: boolean
default: false
push:
branches:
- main
pull_request:
permissions:
contents: write
actions: read
concurrency:
group: magicnet-build-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
env:
MAGIC_MIHOMO: ${{ inputs.magic-mihomo == false && '0' || '1' }}
MAGIC_SINGBOX: ${{ inputs.magic-singbox == false && '0' || '1' }}
KAM_RELEASE_ENABLED: ${{ inputs.release == true && '1' || '0' }}
KAM_SIGN_ENABLED: ${{ inputs.release == true && '1' || '0' }}
KAM_CHANGELOG_ENABLED: '0'
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache Cargo and Rustup
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-
- name: Setup kam
uses: MemDeco-WG/setup-kam@main
with:
github-token: ${{ github.token }}
enable-cache: 'true'
private-key: ${{ secrets.KAM_PRIVATE_KEY }}
- name: Install artifact tools
run: sudo apt-get update && sudo apt-get install -y unzip
- name: Verify tools
shell: bash
run: |
set -euo pipefail
kam --version
gh --version
- name: Build module
shell: bash
run: |
set -euo pipefail
chmod +x hooks/**/*.sh src/MagicNet/*.sh src/MagicNet/system/bin/* || true
rm -rf dist
kam build
- name: Verify artifact contents
shell: bash
run: |
set -euo pipefail
test -f dist/MagicNet.zip
unzip -l dist/MagicNet.zip | grep -F 'lib/kamfw/README.md'
unzip -l dist/MagicNet.zip | grep -F 'lib/magicnet.sh'
unzip -l dist/MagicNet.zip | grep -F 'boot-completed.sh'
unzip -l dist/MagicNet.zip | grep -F 'action.sh'
! unzip -l dist/MagicNet.zip | grep -F 'lib/kamfw/src/'
- name: Upload build artifact
if: always() && hashFiles('dist/*.zip') != ''
uses: actions/upload-artifact@v4
with:
name: MagicNet
path: dist/*.zip
if-no-files-found: error