|
| 1 | +# SPDX-FileCopyrightText: 2026 H2Lab Development Team |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: Build cross-toolchain |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + |
| 13 | + changes: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + pull-requests: read |
| 17 | + outputs: |
| 18 | + devcontainer: ${{ steps.filter.outputs.devcontainer }} |
| 19 | + configs: ${{ steps.filter.outputs.configs }} |
| 20 | + configs_files: ${{ steps.filter.outputs.configs_files }} |
| 21 | + steps: |
| 22 | + - uses: dorny/paths-filter@v4 |
| 23 | + id: filter |
| 24 | + with: |
| 25 | + filters: | |
| 26 | + devcontainer: |
| 27 | + - '.devcontainer/devcontainer.json' |
| 28 | + configs: |
| 29 | + - 'configs/**' |
| 30 | +
|
| 31 | + prebuilt: |
| 32 | + needs: changes |
| 33 | + if: ${{ needs.changes.outputs.devcontainer == 'true' }} |
| 34 | + runs-on: ubuntu-latest |
| 35 | + permissions: |
| 36 | + packages: write |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v6 |
| 39 | + |
| 40 | + - name: Login to GitHub Container Registry |
| 41 | + uses: docker/login-action@v4 |
| 42 | + with: |
| 43 | + registry: ghcr.io |
| 44 | + username: ${{ github.repository_owner }} |
| 45 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Pre-build dev container image |
| 48 | + uses: devcontainers/ci@v0.3 |
| 49 | + with: |
| 50 | + imageName: ghcr.io/camelot-os/prebuilt-ctng-devcontainer |
| 51 | + cacheFrom: ghcr.io/camelot-os/prebuilt-ctng-devcontainer |
| 52 | + push: always |
| 53 | + |
| 54 | + cache_update: |
| 55 | + needs: [changes, prebuilt] |
| 56 | + # if: ${{ !cancelled() && needs.changes.outputs.configs == 'true' }} |
| 57 | + if: ${{ !cancelled() }} |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v6 |
| 61 | + - name: Restore cached sources dir |
| 62 | + id: cache-restore |
| 63 | + uses: actions/cache/restore@v5 |
| 64 | + with: |
| 65 | + path: | |
| 66 | + src |
| 67 | + key: package-sources |
| 68 | + - name: Download sources |
| 69 | + uses: devcontainers/ci@v0.3 |
| 70 | + with: |
| 71 | + cacheFrom: ghcr.io/camelot-os/prebuilt-ctng-devcontainer |
| 72 | + push: never |
| 73 | + runCmd: | |
| 74 | + DEFCONFIG=configs/arm-none-eabi.defconfig ct-ng defconfig |
| 75 | + # patch config for donwload only in cache directory |
| 76 | + sed -i `s/.*CT_ONLY_DOWNLOAD.*/CT_ONLY_DOWNLOAD=y/` .config |
| 77 | + sed -i `s/.*CT_LOCAL_TARBALLS_DIR.*/CT_LOCAL_TARBALLS_DIR=src/` .config |
| 78 | + sed -i `s/.*CT_SAVE_TARBALLS.*/CT_SAVE_TARBALLS=y/` .config |
| 79 | + ct-ng build |
| 80 | + - name: Save cached sources dir |
| 81 | + id: cache-save |
| 82 | + uses: actions/cache/save@v5 |
| 83 | + with: |
| 84 | + path: | |
| 85 | + src |
| 86 | + key: ${{ steps.cache-restore.outputs.cache-primary-key }} |
0 commit comments