Build plugin artifacts #7
This file contains hidden or 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
| name: Build plugin artifacts | |
| # Builds every example plugin's .cgp and exposes them as downloadable | |
| # workflow artifacts. Unlike "Update libs from CodeOnTheGo", this never | |
| # commits refreshed libs, never publishes a GitHub release, and never | |
| # deploys to the website — it only produces artifacts you can download | |
| # from the run summary. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| codeonthego_ref: | |
| description: CodeOnTheGo branch or tag to build the libs against | |
| required: false | |
| default: stage | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| outputs: | |
| plugins: ${{ steps.stage.outputs.plugins }} | |
| steps: | |
| - name: Checkout plugin-examples | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| cache-disabled: true | |
| add-job-summary: 'never' | |
| - name: Build libs and plugins | |
| env: | |
| CODEONTHEGO_REF: ${{ github.event.inputs.codeonthego_ref }} | |
| run: ./scripts/update-libs.sh --ref "$CODEONTHEGO_REF" | |
| - name: Stage built .cgp artifacts | |
| id: stage | |
| run: | | |
| mkdir -p deploy-staging | |
| # Discover every plugin module the same way scripts/update-libs.sh does | |
| # (a sibling dir whose build.gradle.kts applies the plugin-builder Gradle | |
| # plugin), then stage each plugin's built .cgp under its own name. The | |
| # plugin-builder already names the artifact, so there is no rename map — | |
| # new plugins are picked up automatically. | |
| # Keep in sync with SKIP_PLUGINS in scripts/update-libs.sh. | |
| SKIP_PLUGINS=(pebble-custom-function-template-installer) | |
| staged=0 | |
| names=() | |
| for build_file in */build.gradle.kts; do | |
| [ -f "$build_file" ] || continue | |
| grep -qF "com.itsaky.androidide.plugins.build" "$build_file" || continue | |
| module="$(dirname "$build_file")" | |
| skip=0 | |
| for s in "${SKIP_PLUGINS[@]}"; do | |
| [ "$s" = "$module" ] && skip=1 && break | |
| done | |
| if [ "$skip" -eq 1 ]; then | |
| echo "Skipping $module (in SKIP_PLUGINS)" | |
| continue | |
| fi | |
| src="$(ls "${module}/build/plugin/"*.cgp 2>/dev/null | grep -v -- '-debug\.cgp$' | head -n1)" | |
| if [ -z "$src" ]; then | |
| echo "ERROR: no release .cgp found under ${module}/build/plugin/ (did assemblePlugin run?)" | |
| exit 1 | |
| fi | |
| cp "$src" "deploy-staging/$(basename "$src")" | |
| echo "Staged $src -> deploy-staging/$(basename "$src")" | |
| names+=("$(basename "$src" .cgp)") | |
| staged=$((staged + 1)) | |
| done | |
| if [ "$staged" -eq 0 ]; then | |
| echo "ERROR: no plugin modules discovered under */build.gradle.kts" | |
| exit 1 | |
| fi | |
| # Emit the staged artifact names as a JSON array so the publish job can | |
| # fan out one downloadable artifact per plugin via a matrix. | |
| plugins="$(printf '%s\n' "${names[@]}" | jq -R . | jq -cs .)" | |
| echo "plugins=${plugins}" >> "$GITHUB_OUTPUT" | |
| echo "" | |
| echo "Staged ${staged} plugin artifact(s): ${names[*]}" | |
| ls -la deploy-staging/ | |
| - name: Upload all .cgp as one bundle | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-plugins-cgp | |
| path: deploy-staging/*.cgp | |
| retention-days: 7 | |
| if-no-files-found: error | |
| # publish one downloadable artifact per plugin so each .cgp can be | |
| # grabbed directly from the run summary, not only as part of the bundle. | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| plugin: ${{ fromJson(needs.build.outputs.plugins) }} | |
| steps: | |
| - name: Download bundle | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: all-plugins-cgp | |
| path: deploy-staging | |
| - name: Upload ${{ matrix.plugin }} as its own artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.plugin }} | |
| path: deploy-staging/${{ matrix.plugin }}.cgp | |
| retention-days: 7 | |
| if-no-files-found: error |