name: JSON Build permissions: contents: read on: workflow_call: inputs: packages: description: "Packages to Build" required: true type: string publish: description: "Whether the package should be published" required: false type: boolean default: true custom_builder: description: "Custom Builder" required: false type: string default: "" bust_cache: description: "Whether to bust the cache" required: false type: boolean default: false workflow_dispatch: inputs: packages: description: "Packages to Build" required: true type: string publish: description: "Whether the package should be published" required: false type: boolean default: true jobs: build: strategy: matrix: pkg: ${{ fromJson(inputs.packages) }} version: ["rawhide"] fail-fast: false runs-on: ${{ inputs.custom_builder && inputs.custom_builder || (matrix.pkg.arch == 'aarch64' && matrix.pkg.labels['large']) && 'arm64-lg' || matrix.pkg.arch == 'aarch64' && 'ubuntu-22.04-arm' || matrix.pkg.labels['large'] && format('cirun-x86-64-lg--{0}', github.run_id) || 'ubuntu-22.04' }} container: image: ghcr.io/terrapkg/builder:f${{ matrix.version }} options: --cap-add=SYS_ADMIN --privileged steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - name: Set up git repository run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Configure sccache id: sccache if: ${{ !contains(matrix.pkg.labels.sccache, '0') }} uses: actions/github-script@v8 env: SCCACHE_GHA_VERSION: ${{ matrix.version }}-${{ matrix.pkg.arch }}-${{ matrix.pkg.pkg }} SCCACHE_GHA_CACHE_FROM: ${{ matrix.version }}-${{ matrix.pkg.arch }}-${{ matrix.pkg.pkg }} with: script: | const script = require('./.github/scripts/configure-sccache.js') await script({github, context, core, exec}) - name: CI Setup Script if: ${{ !contains(matrix.pkg.labels, 'mock') }} run: | dir=$(dirname ${{ matrix.pkg.pkg }}) if [ -f $dir/ci_setup.rhai ]; then anda run $dir/ci_setup.rhai --labels script_path=$dir/ci_setup.rhai fi - name: Install Build Dependencies if: ${{ matrix.pkg.labels.mock != '1' }} run: | dir=$(dirname ${{ matrix.pkg.pkg }}) dnf5 builddep -y ${dir}/*.spec - name: Build with Andaman run: anda build -D "vendor Terra" -D "__python %{__python3}" ${{ matrix.pkg.pkg }} -c terra-${{ matrix.version }}-${{ matrix.pkg.arch }} ${{ !matrix.pkg.labels.mock == '1' && '-rrpmbuild' || '' }} - name: Report Cache Summary if: steps.sccache.outcome == 'success' uses: actions/github-script@v8 with: script: | const script = require('./.github/scripts/sccache-stats.js') await script({github, context, core, exec}) - name: Generating artifact name id: art run: | NAME=${{ matrix.pkg.pkg }}-${{ matrix.pkg.arch }}-${{ matrix.version }} x=${NAME//\//@} echo "name=$x" >> $GITHUB_OUTPUT - uses: actions/upload-artifact@v6 with: name: ${{ steps.art.outputs.name }} compression-level: 0 # The RPMs are already compressed :p path: | anda-build/rpm/rpms/* anda-build/rpm/srpm/* - name: Upload packages to subatomic if: inputs.publish run: | subrepo="${{ matrix.pkg.labels.subrepo }}" subatomic-cli upload --prune \ --server https://subatomic.fyralabs.com \ --token ${{ secrets.SUBATOMIC_TOKEN }} \ terra${{ matrix.version }}${{ matrix.pkg.labels['subrepo'] && '-$subrepo' || '' }} anda-build/rpm/rpms/* - name: Upload source packages to subatomic if: inputs.publish && matrix.pkg.labels['no_upload_srpms'] != '1' run: | subrepo="${{ matrix.pkg.labels.subrepo }}" subatomic-cli upload --prune \ --server https://subatomic.fyralabs.com \ --token ${{ secrets.SUBATOMIC_TOKEN }} \ terra${{ matrix.version }}${{ matrix.pkg.labels['subrepo'] && '-$subrepo' || '' }}-source anda-build/rpm/srpm/* - name: Notify Madoguchi (Success) if: inputs.publish && success() run: ./.github/workflows/mg.sh true "${{matrix.pkg.pkg}}" "${{matrix.version}}" "${{matrix.pkg.arch}}" "${{github.run_id}}" "${{secrets.MADOGUCHI_JWT}}" "$GITHUB_SHA" - name: Notify Madoguchi (Failure) if: inputs.publish && (cancelled() || failure()) run: ./.github/workflows/mg.sh false "${{matrix.pkg.pkg}}" "${{matrix.version}}" "${{matrix.pkg.arch}}" "${{github.run_id}}" "${{secrets.MADOGUCHI_JWT}}" "$GITHUB_SHA"