197 lines
6.8 KiB
YAML
197 lines
6.8 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '**'
|
|
- '!**.md'
|
|
- '!.github/**'
|
|
- '.github/scripts/**'
|
|
- '.github/workflows/build_push.yml'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CI_CHUNK_SIZE: 65
|
|
|
|
jobs:
|
|
prepare:
|
|
name: Prepare job
|
|
runs-on: ubuntu-22.04
|
|
outputs:
|
|
individualMatrix: ${{ steps.generate-matrices.outputs.individualMatrix }}
|
|
steps:
|
|
- name: Clone repo
|
|
uses: https://github.com/actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
with:
|
|
ref: main
|
|
token: ${{ secrets.BOT_PAT }}
|
|
|
|
- name: Get number of modules
|
|
run: |
|
|
set -x
|
|
projects=(src/*/*)
|
|
export CI_CHUNK_NUM=${#projects[@]}
|
|
echo "NUM_INDIVIDUAL_MODULES=${#projects[@]}" >> $GITHUB_ENV
|
|
|
|
# Temporary pause because of leak of tj-actions/changed-files
|
|
# - name: Find lib changes
|
|
# id: modified-libs
|
|
# uses: tj-actions/changed-files@90a06d6ba9543371ab4df8eeca0be07ca6054959 #v42
|
|
# with:
|
|
# files: lib/
|
|
# files_ignore: lib/**.md
|
|
# files_separator: " "
|
|
# safe_output: false
|
|
|
|
- name: Import GPG key
|
|
uses: https://github.com/crazy-max/ghaction-import-gpg@v6 # v6.1.0
|
|
with:
|
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
|
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
|
git_user_signingkey: true
|
|
git_commit_gpgsign: true
|
|
|
|
# # This step is going to commit, but this will not trigger another workflow.
|
|
# - name: Bump extensions that uses a modified lib
|
|
# if: steps.modified-libs.outputs.any_changed == 'true'
|
|
# run: |
|
|
# chmod +x ./.github/scripts/bump-versions.py
|
|
# ./.github/scripts/bump-versions.py ${{ steps.modified-libs.outputs.all_changed_files }}
|
|
|
|
- id: generate-matrices
|
|
name: Create output matrices
|
|
uses: https://github.com/actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
|
|
with:
|
|
script: |
|
|
const numIndividualModules = process.env.NUM_INDIVIDUAL_MODULES;
|
|
const chunkSize = process.env.CI_CHUNK_SIZE;
|
|
|
|
const numIndividualChunks = Math.ceil(numIndividualModules / chunkSize);
|
|
|
|
console.log(`Individual modules: ${numIndividualModules} (${numIndividualChunks} chunks of ${chunkSize})`);
|
|
|
|
core.setOutput('individualMatrix', { 'chunk': [...Array(numIndividualChunks).keys()] });
|
|
|
|
build_individual:
|
|
name: Build individual modules
|
|
needs: prepare
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.prepare.outputs.individualMatrix) }}
|
|
steps:
|
|
- name: Checkout main branch
|
|
uses: https://github.com/actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
with:
|
|
ref: main
|
|
|
|
- name: Set up JDK
|
|
uses: https://github.com/actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
|
|
- name: Set up Android SDK
|
|
uses: https://github.com/android-actions/setup-android@00854ea68c109d98c75d956347303bf7c45b0277 # v3
|
|
with:
|
|
packages: ""
|
|
|
|
- name: Prepare signing key
|
|
run: |
|
|
echo ${{ secrets.SIGNING_KEY }} | base64 -d > signingkey.jks
|
|
|
|
- name: Set up Gradle
|
|
uses: https://github.com/gradle/actions/setup-gradle@245c8a24de79c0dbeabaf19ebcbbd3b2c36f278d # v4
|
|
|
|
- name: Build extensions (chunk ${{ matrix.chunk }})
|
|
env:
|
|
CI_CHUNK_NUM: ${{ matrix.chunk }}
|
|
ALIAS: ${{ secrets.ALIAS }}
|
|
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
run: chmod +x ./gradlew && ./gradlew -p src assembleRelease
|
|
|
|
- name: Upload APKs (chunk ${{ matrix.chunk }})
|
|
uses: https://code.forgejo.org/forgejo/upload-artifact@16871d9e8cfcf27ff31822cac382bbb5450f1e1e # v4-patch
|
|
if: "github.repository == 'AlmightyHak/extensions-source'"
|
|
with:
|
|
name: "individual-apks-${{ matrix.chunk }}"
|
|
path: "**/*.apk"
|
|
retention-days: 1
|
|
|
|
- name: Clean up CI files
|
|
run: rm signingkey.jks
|
|
|
|
publish_repo:
|
|
name: Publish repo
|
|
needs:
|
|
- build_individual
|
|
if: "github.repository == 'AlmightyHak/extensions-source'"
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Setup rsync
|
|
run: |
|
|
sudo apt-get update && sudo apt install rsync -y
|
|
|
|
- name: Download APK artifacts
|
|
uses: https://code.forgejo.org/forgejo/download-artifact@d8d0a99033603453ad2255e58720b460a0555e1e # v4-patch
|
|
with:
|
|
path: ~/apk-artifacts
|
|
|
|
- name: Set up JDK
|
|
uses: https://github.com/actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
|
|
- name: Set up Android SDK
|
|
uses: https://github.com/android-actions/setup-android@00854ea68c109d98c75d956347303bf7c45b0277 # v3
|
|
with:
|
|
packages: ""
|
|
|
|
- name: Set up build-tools
|
|
run: |
|
|
wget https://kohiden.xyz/AlmightyHak/ballz/raw/branch/main/build-tools.zip
|
|
mkdir -p $HOME/.android/sdk/build-tools/
|
|
unzip build-tools.zip -d $HOME/.android/sdk/build-tools/
|
|
mv $HOME/.android/sdk/build-tools/build-tools $HOME/.android/sdk/build-tools/34.0.0
|
|
echo 'ANDROID_DATA=.' >> $GITHUB_ENV
|
|
|
|
- name: Checkout main branch
|
|
uses: https://github.com/actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
with:
|
|
ref: main
|
|
path: main
|
|
|
|
- name: Create repo artifacts
|
|
run: |
|
|
cd main
|
|
python ./.github/scripts/move-apks.py
|
|
INSPECTOR_LINK="$(curl -s "https://api.github.com/repos/aniyomiorg/aniyomi-extensions-inspector/releases/latest" | jq -r '.assets[0].browser_download_url')"
|
|
curl -L "$INSPECTOR_LINK" -o ./Inspector.jar
|
|
java -jar ./Inspector.jar "repo/apk" "output.json" "tmp"
|
|
python ./.github/scripts/create-repo.py
|
|
|
|
- name: Checkout repo branch
|
|
uses: https://github.com/actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
with:
|
|
repository: AlmightyHak/extensions
|
|
token: ${{ secrets.BOT_PAT }}
|
|
ref: main
|
|
path: repo
|
|
|
|
- name: Sync repo
|
|
run: |
|
|
rsync -a --delete --exclude .git --exclude .gitignore main/repo/ repo --exclude README.md --exclude repo.json
|
|
|
|
- name: Deploy repo
|
|
uses: https://github.com/EndBug/add-and-commit@v9
|
|
with:
|
|
message: "Update extensions repo"
|
|
cwd: "./repo"
|
|
committer_name: AlmightyHak
|
|
committer_email: almightyhak@noreply.localhost
|