|
| 1 | +name: Build cuda docker container on publish |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [ created, edited ] |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + tag: |
| 8 | + description: 'tag' |
| 9 | + required: true |
| 10 | + default: 'latest' |
| 11 | + type: string |
| 12 | +jobs: |
| 13 | + var: |
| 14 | + name: Set variables |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + image-cuda-dev: "ghcr.io/mutablelogic/cuda-dev" |
| 18 | + image-cuda-runtime: "ghcr.io/mutablelogic/cuda-rt" |
| 19 | + tag: ${{ steps.var.outputs.tag }} |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + - name: Set variables |
| 26 | + id: var |
| 27 | + run: | |
| 28 | + if [ "${{ github.event_name }}" != "release" ] && [ "${{ inputs.tag }}" != "latest" ]; then |
| 29 | + TAG="${{ inputs.tag }}" && echo "tag=${TAG#v}" >> $GITHUB_OUTPUT |
| 30 | + else |
| 31 | + TAG="$(git describe --tags)" && echo "tag=${TAG#v}" >> $GITHUB_OUTPUT |
| 32 | + fi |
| 33 | + build: |
| 34 | + name: Build |
| 35 | + needs: var |
| 36 | + strategy: |
| 37 | + matrix: |
| 38 | + arch: [ amd64, arm64 ] |
| 39 | + runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || matrix.arch == 'arm64' && 'nx1' }} |
| 40 | + env: |
| 41 | + ARCH: ${{ matrix.arch }} |
| 42 | + OS: linux |
| 43 | + DOCKER_REGISTRY: ghcr.io/mutablelogic |
| 44 | + steps: |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v4 |
| 47 | + with: |
| 48 | + fetch-depth: 0 |
| 49 | + - name: Login |
| 50 | + uses: docker/login-action@v3 |
| 51 | + with: |
| 52 | + registry: ghcr.io |
| 53 | + username: ${{ github.repository_owner }} |
| 54 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + - name: Build and Push |
| 56 | + id: build |
| 57 | + run: | |
| 58 | + git checkout v${{ needs.var.outputs.tag }} |
| 59 | + make docker-cuda-push |
| 60 | + manifest: |
| 61 | + name: Create manifest |
| 62 | + needs: |
| 63 | + - build |
| 64 | + - var |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + image: |
| 68 | + - ${{ needs.var.outputs.image-cuda-dev }} |
| 69 | + - ${{ needs.var.outputs.image-cuda-runtime }} |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Login |
| 73 | + uses: docker/login-action@v3 |
| 74 | + with: |
| 75 | + registry: ghcr.io |
| 76 | + username: ${{ github.repository_owner }} |
| 77 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + - name: Create |
| 79 | + run: | |
| 80 | + docker manifest create ${{ matrix.image }}:${{ needs.var.outputs.tag }} \ |
| 81 | + --amend ${{ matrix.image }}-linux-amd64:${{ needs.var.outputs.tag }} \ |
| 82 | + --amend ${{ matrix.image }}-linux-arm64:${{ needs.var.outputs.tag }} |
| 83 | + - name: Annotate |
| 84 | + run: | |
| 85 | + docker manifest annotate --arch arm64 --os linux \ |
| 86 | + ${{ matrix.image }}:${{ needs.var.outputs.tag }} \ |
| 87 | + ${{ matrix.image }}-linux-arm64:${{ needs.var.outputs.tag }} |
| 88 | + docker manifest annotate --arch amd64 --os linux \ |
| 89 | + ${{ matrix.image }}:${{ needs.var.outputs.tag }} \ |
| 90 | + ${{ matrix.image }}-linux-amd64:${{ needs.var.outputs.tag }} |
| 91 | + - name: Push |
| 92 | + run: | |
| 93 | + docker manifest push ${{ matrix.image }}:${{ needs.var.outputs.tag }} |
0 commit comments