Feat/charger settings #1269
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 | |
| # Controls when the workflow will run | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| clean_build: | |
| description: 'Clean build without cache' | |
| default: false | |
| type: boolean | |
| variant: | |
| description: 'Which variant to build (default/legacy or all)' | |
| required: true | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - default | |
| - legacy | |
| arch: | |
| description: 'Which architecture to build (amd64/arm64 or all)' | |
| required: true | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - amd64 | |
| - arm64 | |
| push: | |
| branches: | |
| - 'main' | |
| - 'releases/**' | |
| - 'v2' | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - 'main' | |
| # Allow stopping obsolete workflows | |
| concurrency: | |
| group: ci-buildtrain-${{ github.ref }}-1 | |
| cancel-in-progress: true | |
| # permissions are needed if pushing to ghcr.io | |
| permissions: | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04-arm | |
| docker_build_arch: arm64 | |
| variant: legacy | |
| dockerfile: ./docker/Dockerfile.Legacy | |
| - os: ubuntu-24.04 | |
| docker_build_arch: amd64 | |
| variant: legacy | |
| dockerfile: ./docker/Dockerfile.Legacy | |
| - os: ubuntu-24.04-arm | |
| docker_build_arch: arm64 | |
| variant: default | |
| dockerfile: ./docker/Dockerfile | |
| - os: ubuntu-24.04 | |
| docker_build_arch: amd64 | |
| variant: default | |
| dockerfile: ./docker/Dockerfile | |
| steps: | |
| - name: Prepare | |
| env: | |
| REPOSITORY: '${{ github.repository }}' | |
| run: | | |
| build_arch=${{ matrix.docker_build_arch }} | |
| echo "BUILD_ARCH=${build_arch//\//-}" >> ${GITHUB_ENV} | |
| echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV} | |
| # Get the repository's code | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| # Setup Python 3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3' | |
| - uses: pre-commit/action@v3.0.1 | |
| - name: Docker meta | |
| if: matrix.variant == 'default' | |
| id: meta_default | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ghcr.io/${{ env.REPOSITORY_LC }} | |
| flavor: | | |
| latest=false | |
| - name: Docker meta (Legacy) | |
| if: matrix.variant == 'legacy' | |
| id: meta_legacy | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ghcr.io/${{ env.REPOSITORY_LC }} | |
| flavor: | | |
| latest=false | |
| suffix=-legacy | |
| - name: Select metadata labels | |
| if: github.event_name != 'workflow_dispatch' || ((inputs.variant == 'all' || inputs.variant == matrix.variant) && (inputs.arch == 'all' || inputs.arch == matrix.docker_build_arch)) | |
| run: | | |
| if [ "${{ matrix.variant }}" = "default" ]; then | |
| echo "META_LABELS=${{ steps.meta_default.outputs.labels }}" >> ${GITHUB_ENV} | |
| else | |
| echo "META_LABELS=${{ steps.meta_legacy.outputs.labels }}" >> ${GITHUB_ENV} | |
| fi | |
| # https://github.com/docker/setup-buildx-action | |
| - name: Set up Docker Buildx | |
| if: github.event_name != 'workflow_dispatch' || ((inputs.variant == 'all' || inputs.variant == matrix.variant) && (inputs.arch == 'all' || inputs.arch == matrix.docker_build_arch)) | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| if: (github.event_name != 'pull_request') && (github.event_name != 'workflow_dispatch' || ((inputs.variant == 'all' || inputs.variant == matrix.variant) && (inputs.arch == 'all' || inputs.arch == matrix.docker_build_arch))) | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| if: github.event_name != 'workflow_dispatch' || ((inputs.variant == 'all' || inputs.variant == matrix.variant) && (inputs.arch == 'all' || inputs.arch == matrix.docker_build_arch)) | |
| id: build-and-push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| platforms: ${{ matrix.docker_build_arch }} | |
| no-cache: ${{ inputs.clean_build == true || false }} | |
| labels: ${{ env.META_LABELS }} | |
| outputs: type=image,name=ghcr.io/${{ env.REPOSITORY_LC }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} | |
| cache-from: type=gha,scope=${{ matrix.os }}-${{ matrix.variant }} | |
| cache-to: type=gha,scope=${{ matrix.os }}-${{ matrix.variant }},mode=max | |
| - name: Export digest | |
| if: github.event_name != 'workflow_dispatch' || ((inputs.variant == 'all' || inputs.variant == matrix.variant) && (inputs.arch == 'all' || inputs.arch == matrix.docker_build_arch)) | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build-and-push.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| if: github.event_name != 'workflow_dispatch' || ((inputs.variant == 'all' || inputs.variant == matrix.variant) && (inputs.arch == 'all' || inputs.arch == matrix.docker_build_arch)) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ env.BUILD_ARCH }}-${{ matrix.variant }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge: | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - build | |
| strategy: | |
| matrix: | |
| include: | |
| - variant: default | |
| - variant: legacy | |
| steps: | |
| - name: Prepare | |
| env: | |
| REPOSITORY: '${{ github.repository }}' | |
| run: | | |
| echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV} | |
| - name: Download digests | |
| if: github.event_name != 'workflow_dispatch' || inputs.variant == 'all' || inputs.variant == matrix.variant | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-*-${{ matrix.variant }} | |
| merge-multiple: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Docker meta (Default) | |
| if: (matrix.variant == 'default') && (github.event_name != 'workflow_dispatch' || inputs.variant == 'all' || inputs.variant == matrix.variant) | |
| id: meta_default | |
| uses: docker/metadata-action@v5 | |
| with: | |
| tags: | | |
| type=edge,branch=main | |
| type=schedule | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=sha | |
| images: ghcr.io/${{ env.REPOSITORY_LC }} | |
| flavor: | | |
| latest=auto | |
| # Legacy — all tags suffixed with -legacy, no `latest` | |
| - name: Docker meta (Legacy) | |
| if: (matrix.variant == 'legacy') && (github.event_name != 'workflow_dispatch' || inputs.variant == 'all' || inputs.variant == matrix.variant) | |
| id: meta_legacy | |
| uses: docker/metadata-action@v5 | |
| with: | |
| tags: | | |
| type=edge,branch=main,prefix=releases- | |
| type=schedule,suffix=-legacy | |
| type=ref,event=branch,suffix=-legacy | |
| type=ref,event=pr,suffix=-legacy | |
| type=semver,pattern={{version}},suffix=-legacy | |
| type=semver,pattern={{major}}.{{minor}},suffix=-legacy | |
| type=semver,pattern={{major}},suffix=-legacy | |
| type=sha,suffix=-legacy | |
| images: ghcr.io/${{ env.REPOSITORY_LC }} | |
| flavor: | | |
| latest=false | |
| - name: Login to GHCR | |
| if: github.event_name != 'workflow_dispatch' || inputs.variant == 'all' || inputs.variant == matrix.variant | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create manifest list and push | |
| if: github.event_name != 'workflow_dispatch' || inputs.variant == 'all' || inputs.variant == matrix.variant | |
| working-directory: /tmp/digests | |
| run: | | |
| echo "Found digest files:" && ls -la || true | |
| if [ "$(ls -1 | wc -l)" -eq 0 ]; then | |
| echo "No digests found, skipping manifest creation for ${{ matrix.variant }}" | |
| exit 0 | |
| fi | |
| TAG_ARGS=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") | |
| echo "Creating manifest with tags: $TAG_ARGS" | |
| docker buildx imagetools create ${TAG_ARGS} \ | |
| $(printf 'ghcr.io/${{ env.REPOSITORY_LC }}@sha256:%s ' *) | |
| - name: Inspect image | |
| if: github.event_name != 'workflow_dispatch' || inputs.variant == 'all' || inputs.variant == matrix.variant | |
| run: | | |
| docker buildx imagetools inspect $(jq -r '.tags[0]' <<< "$DOCKER_METADATA_OUTPUT_JSON") |