mirror of
https://github.com/keiyoushi/extensions-source.git
synced 2024-11-26 04:03:01 +01:00
208 lines
7.0 KiB
YAML
208 lines
7.0 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- '**.md'
|
|
- '.github/workflows/issue_moderator.yml'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CI_CHUNK_SIZE: 65
|
|
|
|
jobs:
|
|
prepare:
|
|
name: Prepare job
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
individualMatrix: ${{ steps.generate-matrices.outputs.individualMatrix }}
|
|
multisrcMatrix: ${{ steps.generate-matrices.outputs.multisrcMatrix }}
|
|
env:
|
|
CI_MODULE_GEN: true
|
|
steps:
|
|
- name: Clone repo
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
|
|
- name: Validate Gradle Wrapper
|
|
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
|
|
- name: Generate multisrc sources
|
|
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2 # v2
|
|
with:
|
|
arguments: :multisrc:generateExtensions
|
|
|
|
- name: Get number of modules
|
|
run: |
|
|
set -x
|
|
./gradlew -q projects | grep '.*extensions\:\(individual\|multisrc\)\:.*\:.*' > projects.txt
|
|
|
|
echo "NUM_INDIVIDUAL_MODULES=$(cat projects.txt | grep '.*\:individual\:.*' | wc -l)" >> $GITHUB_ENV
|
|
echo "NUM_MULTISRC_MODULES=$(cat projects.txt | grep '.*\:multisrc\:.*' | wc -l)" >> $GITHUB_ENV
|
|
|
|
- id: generate-matrices
|
|
name: Create output matrices
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
|
|
with:
|
|
script: |
|
|
const numIndividualModules = process.env.NUM_INDIVIDUAL_MODULES;
|
|
const numMultisrcModules = process.env.NUM_MULTISRC_MODULES;
|
|
const chunkSize = process.env.CI_CHUNK_SIZE;
|
|
|
|
const numIndividualChunks = Math.ceil(numIndividualModules / chunkSize);
|
|
const numMultisrcChunks = Math.ceil(numMultisrcModules / chunkSize);
|
|
|
|
console.log(`Individual modules: ${numIndividualModules} (${numIndividualChunks} chunks of ${chunkSize})`);
|
|
console.log(`Multi-source modules: ${numMultisrcModules} (${numMultisrcChunks} chunks of ${chunkSize})`);
|
|
|
|
core.setOutput('individualMatrix', { 'chunk': [...Array(numIndividualChunks).keys()] });
|
|
core.setOutput('multisrcMatrix', { 'chunk': [...Array(numMultisrcChunks).keys()] });
|
|
|
|
build_multisrc:
|
|
name: Build multisrc modules
|
|
needs: prepare
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.prepare.outputs.multisrcMatrix) }}
|
|
steps:
|
|
- name: Checkout main branch
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
|
|
- name: Prepare signing key
|
|
run: |
|
|
echo ${{ secrets.SIGNING_KEY }} | base64 -d > signingkey.jks
|
|
|
|
- name: Generate sources from the multi-source library
|
|
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2 # v2
|
|
env:
|
|
CI_MODULE_GEN: "true"
|
|
with:
|
|
arguments: :multisrc:generateExtensions
|
|
|
|
- name: Build extensions (chunk ${{ matrix.chunk }})
|
|
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2 # v2
|
|
env:
|
|
CI_MULTISRC: "true"
|
|
CI_CHUNK_NUM: ${{ matrix.chunk }}
|
|
ALIAS: ${{ secrets.ALIAS }}
|
|
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
with:
|
|
arguments: assembleRelease
|
|
|
|
- name: Upload APKs (chunk ${{ matrix.chunk }})
|
|
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4
|
|
if: "github.repository == 'keiyoushi/extensions-source'"
|
|
with:
|
|
name: "multisrc-apks-${{ matrix.chunk }}"
|
|
path: "**/*.apk"
|
|
retention-days: 1
|
|
|
|
- name: Clean up CI files
|
|
run: rm signingkey.jks
|
|
|
|
build_individual:
|
|
name: Build individual modules
|
|
needs: prepare
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.prepare.outputs.individualMatrix) }}
|
|
steps:
|
|
- name: Checkout main branch
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
|
|
- name: Prepare signing key
|
|
run: |
|
|
echo ${{ secrets.SIGNING_KEY }} | base64 -d > signingkey.jks
|
|
|
|
- name: Build extensions (chunk ${{ matrix.chunk }})
|
|
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2 # v2
|
|
env:
|
|
CI_MULTISRC: "false"
|
|
CI_CHUNK_NUM: ${{ matrix.chunk }}
|
|
ALIAS: ${{ secrets.ALIAS }}
|
|
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
with:
|
|
arguments: assembleRelease
|
|
|
|
- name: Upload APKs (chunk ${{ matrix.chunk }})
|
|
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4
|
|
if: "github.repository == 'keiyoushi/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_multisrc
|
|
- build_individual
|
|
if: "github.repository == 'keiyoushi/extensions-source'"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download APK artifacts
|
|
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4
|
|
with:
|
|
path: ~/apk-artifacts
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
|
|
- name: Checkout main branch
|
|
uses: 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/keiyoushi/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: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
with:
|
|
repository: keiyoushi/extensions
|
|
token: ${{ secrets.BOT_PAT }}
|
|
ref: repo
|
|
path: repo
|
|
|
|
- name: Deploy repo
|
|
run: |
|
|
cd repo
|
|
../main/.github/scripts/commit-repo.sh
|