|
49 | 49 | echo "$MATRIX" |
50 | 50 | echo "matrix=$MATRIX" >> $GITHUB_OUTPUT |
51 | 51 |
|
| 52 | + ARCH_LIST=$(echo "$MATRIX" | jq -r '.[].arch' | jq -R -s -c 'split("\n") | map(select(. != ""))') |
| 53 | + echo "arch_list=$ARCH_LIST" >> $GITHUB_OUTPUT |
| 54 | +
|
52 | 55 | build: |
53 | 56 | runs-on: ubuntu-latest |
54 | 57 | needs: generate-matrix |
@@ -132,3 +135,63 @@ jobs: |
132 | 135 | files: | |
133 | 136 | artifacts/* |
134 | 137 | CHANGES.md |
| 138 | +
|
| 139 | + docker-build: |
| 140 | + runs-on: ubuntu-latest |
| 141 | + needs: [generate-matrix] |
| 142 | + strategy: |
| 143 | + fail-fast: false |
| 144 | + matrix: |
| 145 | + include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} |
| 146 | + env: |
| 147 | + VERSION: ${{ github.event.inputs.release_name || github.ref_name }} |
| 148 | + steps: |
| 149 | + - uses: actions/checkout@v4 |
| 150 | + |
| 151 | + - name: Install Nix |
| 152 | + uses: cachix/install-nix-action@v30 |
| 153 | + with: |
| 154 | + nix_path: nixpkgs=channel:nixos-unstable |
| 155 | + github_access_token: ${{ secrets.GITHUB_TOKEN }} |
| 156 | + extra_nix_config: | |
| 157 | + experimental-features = nix-command flakes |
| 158 | +
|
| 159 | + - name: Build individual images with Nix |
| 160 | + run: | |
| 161 | + nix build .#image-${{ matrix.arch }} |
| 162 | + docker load < ./result |
| 163 | + docker tag grhooks:${{ env.VERSION }} ghcr.io/${{ github.repository_owner }}/grhooks:${{ matrix.arch }} |
| 164 | +
|
| 165 | + - name: Create and push unified manifest |
| 166 | + run: | |
| 167 | + docker manifest create ghcr.io/${{ github.repository_owner }}/grhooks:${{ env.VERSION }} \ |
| 168 | + --amend ghcr.io/${{ github.repository_owner }}/grhooks:${{ matrix.arch }} |
| 169 | +
|
| 170 | + docker-publish: |
| 171 | + runs-on: ubuntu-latest |
| 172 | + needs: [generate-matrix, docker-build] |
| 173 | + env: |
| 174 | + VERSION: ${{ github.event.inputs.release_name || github.ref_name }} |
| 175 | + steps: |
| 176 | + - name: Log in to GHCR |
| 177 | + uses: docker/login-action@v3 |
| 178 | + with: |
| 179 | + registry: ghcr.io |
| 180 | + username: ${{ github.actor }} |
| 181 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 182 | + |
| 183 | + - name: Create and push manifest |
| 184 | + run: | |
| 185 | + IMAGE=ghcr.io/${{ github.repository_owner }}/grhooks:${{ env.VERSION }} |
| 186 | + ARCHS='${{ needs.generate-matrix.outputs.arch_list }}' |
| 187 | +
|
| 188 | + echo "Creating manifest for architectures: $ARCHS" |
| 189 | +
|
| 190 | + manifest_args="" |
| 191 | + for arch in $(echo "$ARCHS" | jq -r '.[]'); do |
| 192 | + manifest_args="$manifest_args --amend ghcr.io/${{ github.repository_owner }}/grhooks:$arch" |
| 193 | + done |
| 194 | +
|
| 195 | + echo "Running docker manifest create $IMAGE $manifest_args" |
| 196 | + eval docker manifest create $IMAGE $manifest_args |
| 197 | + docker manifest push $IMAGE |
0 commit comments