Skip to content

Magisk Build

Magisk Build #67

Workflow file for this run

name: Magisk Build
on:
push:
branches: [master]
paths:
- "app/**"
- "native/**"
- "buildSrc/**"
- "build.py"
- "gradle.properties"
- ".github/workflows/build.yml"
pull_request:
branches: [master]
workflow_dispatch:
inputs:
make_release:
required: false
type: choice
description: Make a forced release
options:
- 0
- 1
default: '0'
workflow_call:
jobs:
build:
name: Build Magisk artifacts
runs-on: macos-14
strategy:
fail-fast: false
steps:
- name: Check out
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Setup environment
uses: ./.github/actions/setup
with:
is-asset-build: true
- name: Setup keystores
run: |
cat > config.prop<< EOF
keyStore=key.jks
keyStorePass=${{ secrets.KEYSTORE_ALIAS_PASSWORD }}
keyAlias=${{ secrets.KEYSTORE_ALIAS_NAME }}
keyPass=${{ secrets.KEYSTORE_PASSWORD }}
EOF
echo '${{ secrets.KEYSTORE_FILE }}' > keystore.jks.asc
gpg -d --passphrase '${{ secrets.KEYSTORE_PASSWORD_GPG }}' --batch keystore.jks.asc > key.jks
- name: Build release
run: ./build.py -vr all
- name: Build debug
run: ./build.py -v all
- name: Stop gradle daemon
run: ./gradlew --stop
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
path: out
compression-level: 9
- name: Check for Release
id: check_release
run: |
RELEASE_COMMIT=0
echo "RELEASE_COMMIT=$(( $(git log -10 --oneline | grep 'Release new canary build' | wc -l) + RELEASE_COMMIT ))" >> $GITHUB_ENV
if [[ "${{ inputs.make_release }}" == "1" ]]; then
(( RELEASE_COMMIT += 1 ))
echo "RELEASE_COMMIT=$RELEASE_COMMIT" >> $GITHUB_ENV
fi
if [[ $RELEASE_COMMIT > 0 ]]; then
echo "Found recent canary build releases."
else
echo "No recent canary build releases found."
fi
- name: Setup Git
if: ${{ env.RELEASE_COMMIT > 0 }}
run: git config --global user.email ${{ secrets.EMAIL }} && git config --global user.name PiX
- name: Fetch commit hash and Magisk version
if: ${{ env.RELEASE_COMMIT > 0 }}
run: |
git fetch origin
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "MAGISK_VERSION=$(grep 'magisk.versionCode=' gradle.properties | awk -F= '{print $2}')" >> $GITHUB_ENV
- name: Update configs
if: ${{ env.RELEASE_COMMIT > 0 }}
run: |
git checkout magisk-files
echo "Updating Configs for the new release"
jq --arg version "${COMMIT_HASH}" \
--arg versionCode "${MAGISK_VERSION}" \
'.magisk.version = $version |
.magisk.versionCode = $versionCode |
.magisk.link |= sub("canary-[0-9]{5}"; "canary-" + $versionCode) |
.magisk.note |= sub("canary-[0-9]{5}"; "canary-" + $versionCode)' canary.json > canary.json.tmp
mv canary.json.tmp canary.json
jq --arg version "${COMMIT_HASH}" \
--arg versionCode "${MAGISK_VERSION}" \
'.magisk.version = $version |
.magisk.versionCode = $versionCode |
.magisk.link |= sub("canary-[0-9]{5}"; "canary-" + $versionCode) |
.magisk.note |= sub("canary-[0-9]{5}"; "canary-" + $versionCode)' debug.json > debug.json.tmp
mv debug.json.tmp debug.json
git add canary.json debug.json
git commit -m "release: new canary build ${COMMIT_HASH}"
git push origin magisk-files
git checkout master
wget -qO- "https://github.com/topjohnwu/Magisk/releases/download/canary-${MAGISK_VERSION}/notes.md" >> notes.md
echo -e '\n## Diffs to Official Magisk\n\nAdded support for GrapheneOS for personal use' >> notes.md
- name: Release APK
if: ${{ env.RELEASE_COMMIT > 0 }}
uses: "dciborow/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "canary-${{ env.MAGISK_VERSION }}"
prerelease: true
title: "Magisk (${{ env.COMMIT_HASH }}) (${{ env.MAGISK_VERSION }})"
files: |
out/app-release.apk
out/app-debug.apk
notes.md
- name: Upload mapping and native debug symbols
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-symbols
path: app/apk/build/outputs
compression-level: 9
test-build:
name: Test building on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
steps:
- name: Check out
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Setup environment
uses: ./.github/actions/setup
- name: Test build
run: python build.py -v -c .github/ci.prop all
- name: Stop gradle daemon
run: ./gradlew --stop
avd-test:
name: Test API ${{ matrix.version }} (x86_64)
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
version: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
type: [""]
include:
- version: 35
type: "google_apis"
steps:
- name: Check out
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}
path: out
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run AVD test
timeout-minutes: 10
env:
AVD_TEST_LOG: 1
run: scripts/avd_test.sh ${{ matrix.version }} ${{ matrix.type }}
- name: Upload logs on error
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: "avd-logs-${{ matrix.version }}"
path: |
kernel.log
logcat.log
avd-test-32:
name: Test API ${{ matrix.version }} (x86)
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
version: [23, 24, 25, 26, 27, 28, 29, 30]
steps:
- name: Check out
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}
path: out
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run AVD test
timeout-minutes: 10
env:
FORCE_32_BIT: 1
AVD_TEST_LOG: 1
run: scripts/avd_test.sh ${{ matrix.version }}
- name: Upload logs on error
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: "avd32-logs-${{ matrix.version }}"
path: |
kernel.log
logcat.log
cf_test:
name: Test ${{ matrix.device }}
runs-on: ubuntu-24.04
needs: build
env:
CF_HOME: /home/runner/aosp_cf_phone
strategy:
fail-fast: false
matrix:
include:
- branch: "aosp-main"
device: "aosp_cf_x86_64_phone"
- branch: "aosp-main-throttled"
device: "aosp_cf_x86_64_phone_pgagnostic"
steps:
- name: Check out
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}
path: out
- name: Setup Cuttlefish environment
run: |
scripts/cuttlefish.sh setup
scripts/cuttlefish.sh download ${{ matrix.branch }} ${{ matrix.device }}
- name: Run Cuttlefish test
timeout-minutes: 10
run: su $USER -c 'scripts/cuttlefish.sh test'
- name: Upload logs on error
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: "cvd-logs-${{ matrix.device }}"
path: |
/home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/logs
/home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/cuttlefish_config.json