From 29d34dcdb2e22729e6fa3b743a4cbffd54b6979e Mon Sep 17 00:00:00 2001 From: cytopia Date: Fri, 25 Mar 2022 01:43:34 +0100 Subject: [PATCH] Go full build chain --- .github/workflows/zzz-reuse.yml | 224 +++++++++++++++++++++++++++++++- 1 file changed, 223 insertions(+), 1 deletion(-) diff --git a/.github/workflows/zzz-reuse.yml b/.github/workflows/zzz-reuse.yml index 05fd10b..96fc05f 100644 --- a/.github/workflows/zzz-reuse.yml +++ b/.github/workflows/zzz-reuse.yml @@ -279,7 +279,6 @@ jobs: uses: actions/download-artifact@v3 with: name: ${{ steps.import.outputs.file }} - path: ${{ steps.import.outputs.file }} - name: "[Import] load" uses: cytopia/shell-command-retry-action@v0.1.2 @@ -332,6 +331,229 @@ jobs: path: ${{ steps.artifact.outputs.file }} + # ----------------------------------------------------------------------------------------------- + # JOB (2/3): BUILD-PROD + # ----------------------------------------------------------------------------------------------- + build-prod: + needs: [configure, build-base, build-mods] + name: Build ${{ matrix.name }}-${{ matrix.version }} (${{ matrix.arch }}) ${{ matrix.refs }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.configure.outputs.matrix_build) }} + if: inputs.enabled + steps: + # ------------------------------------------------------------ + # Setup repository + # ------------------------------------------------------------ + - name: "[SETUP] Checkout repository (current)" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + if: needs.configure.outputs.has_refs == 0 + + - name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ matrix.refs }} + if: needs.configure.outputs.has_refs != 0 + + - name: "[SETUP] Setup QEMU environment" + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + + - name: "[SETUP] Determine Docker tag" + id: tag + uses: cytopia/docker-tag-action@v0.4.15 + + # ------------------------------------------------------------ + # Import + # ------------------------------------------------------------ + - name: "[Import] Set name" + id: import + run: | + PREFIX="${{ needs.configure.outputs.artifact_mods }}" + VERSION="${{ matrix.version }}" + ARCH="${{ matrix.arch }}" + TAG="${{ steps.tag.outputs.docker-tag }}" + NAME="$( echo "${PREFIX}-${VERSION}-${ARCH}-${TAG}" | sed 's|/|-|g' )" + echo "::set-output name=file::${NAME}" + echo "file=${NAME}" + + - name: "[Import] Download" + uses: actions/download-artifact@v3 + with: + name: ${{ steps.import.outputs.file }} + + - name: "[Import] load" + uses: cytopia/shell-command-retry-action@v0.1.2 + with: + command: | + make load VERSION=${{ matrix.version }} FLAVOUR=prod ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} INFILE=${{ steps.import.outputs.file }} + + # ------------------------------------------------------------ + # Build + # ------------------------------------------------------------ + - name: Build + uses: cytopia/shell-command-retry-action@v0.1.2 + with: + command: | + make build VERSION=${{ matrix.version }} FLAVOUR=prod ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} + + # ------------------------------------------------------------ + # Test + # ------------------------------------------------------------ + #- name: Test + # uses: cytopia/shell-command-retry-action@v0.1.2 + # with: + # command: | + # make test VERSION=${{ matrix.version }} FLAVOUR=prod ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} + + # ------------------------------------------------------------ + # Export + # ------------------------------------------------------------ + - name: "[Artifact] Set name" + id: artifact + run: | + PREFIX="${{ needs.configure.outputs.artifact_prod }}" + VERSION="${{ matrix.version }}" + ARCH="${{ matrix.arch }}" + TAG="${{ steps.tag.outputs.docker-tag }}" + NAME="$( echo "${PREFIX}-${VERSION}-${ARCH}-${TAG}" | sed 's|/|-|g' )" + echo "::set-output name=file::${NAME}" + echo "file=${NAME}" + + - name: "[Artifact] Export" + uses: cytopia/shell-command-retry-action@v0.1.2 + with: + command: | + make save VERSION=${{ matrix.version }} FLAVOUR=prod ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} OUTFILE=${{ steps.artifact.outputs.file }} + + - name: "[Artifact] Upload" + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.artifact.outputs.file }} + path: ${{ steps.artifact.outputs.file }} + + + # ----------------------------------------------------------------------------------------------- + # JOB (2/3): BUILD-WORK + # ----------------------------------------------------------------------------------------------- + build-work: + needs: [configure, build-base, build-mods, build-prod] + name: Build ${{ matrix.name }}-${{ matrix.version }} (${{ matrix.arch }}) ${{ matrix.refs }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.configure.outputs.matrix_build) }} + if: inputs.enabled + steps: + # ------------------------------------------------------------ + # Setup repository + # ------------------------------------------------------------ + - name: "[SETUP] Checkout repository (current)" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + if: needs.configure.outputs.has_refs == 0 + + - name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ matrix.refs }} + if: needs.configure.outputs.has_refs != 0 + + - name: "[SETUP] Setup QEMU environment" + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + + - name: "[SETUP] Determine Docker tag" + id: tag + uses: cytopia/docker-tag-action@v0.4.15 + + # ------------------------------------------------------------ + # Import + # ------------------------------------------------------------ + - name: "[Import] Set name" + id: import + run: | + PREFIX="${{ needs.configure.outputs.artifact_prod }}" + VERSION="${{ matrix.version }}" + ARCH="${{ matrix.arch }}" + TAG="${{ steps.tag.outputs.docker-tag }}" + NAME="$( echo "${PREFIX}-${VERSION}-${ARCH}-${TAG}" | sed 's|/|-|g' )" + echo "::set-output name=file::${NAME}" + echo "file=${NAME}" + + - name: "[Import] Download" + uses: actions/download-artifact@v3 + with: + name: ${{ steps.import.outputs.file }} + + - name: "[Import] load" + uses: cytopia/shell-command-retry-action@v0.1.2 + with: + command: | + make load VERSION=${{ matrix.version }} FLAVOUR=work ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} INFILE=${{ steps.import.outputs.file }} + + # ------------------------------------------------------------ + # Build + # ------------------------------------------------------------ + - name: Build + uses: cytopia/shell-command-retry-action@v0.1.2 + with: + command: | + make build VERSION=${{ matrix.version }} FLAVOUR=work ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} + + # ------------------------------------------------------------ + # Test + # ------------------------------------------------------------ + #- name: Test + # uses: cytopia/shell-command-retry-action@v0.1.2 + # with: + # command: | + # make test VERSION=${{ matrix.version }} FLAVOUR=work ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} + + # ------------------------------------------------------------ + # Export + # ------------------------------------------------------------ + - name: "[Artifact] Set name" + id: artifact + run: | + PREFIX="${{ needs.configure.outputs.artifact_work }}" + VERSION="${{ matrix.version }}" + ARCH="${{ matrix.arch }}" + TAG="${{ steps.tag.outputs.docker-tag }}" + NAME="$( echo "${PREFIX}-${VERSION}-${ARCH}-${TAG}" | sed 's|/|-|g' )" + echo "::set-output name=file::${NAME}" + echo "file=${NAME}" + + - name: "[Artifact] Export" + uses: cytopia/shell-command-retry-action@v0.1.2 + with: + command: | + make save VERSION=${{ matrix.version }} FLAVOUR=work ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} OUTFILE=${{ steps.artifact.outputs.file }} + + - name: "[Artifact] Upload" + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.artifact.outputs.file }} + path: ${{ steps.artifact.outputs.file }} + + + + + + + # # ------------------------------------------------------------ # # Deploy # # ------------------------------------------------------------