|
| 1 | +name: release-tag |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: [ '[0-9]+.[0-9]+.[0-9]+' ] |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + |
| 10 | +jobs: |
| 11 | + package-amd64: |
| 12 | + runs-on: buildjet-2vcpu-ubuntu-2204 |
| 13 | + permissions: |
| 14 | + packages: write |
| 15 | + contents: read |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v3 |
| 19 | + |
| 20 | + - name: Docker meta |
| 21 | + id: meta |
| 22 | + uses: docker/metadata-action@v4 |
| 23 | + with: |
| 24 | + images: ${{ env.REGISTRY }}/${{ github.repository }} |
| 25 | + |
| 26 | + - name: Set up Docker Buildx |
| 27 | + uses: docker/setup-buildx-action@v2 |
| 28 | + |
| 29 | + - name: Login to CR |
| 30 | + uses: docker/login-action@v2 |
| 31 | + with: |
| 32 | + registry: ${{ env.REGISTRY }} |
| 33 | + username: ${{ github.repository_owner }} |
| 34 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + - name: Build docker image and push |
| 37 | + id: docker_build_amd64 |
| 38 | + uses: docker/build-push-action@v4 |
| 39 | + with: |
| 40 | + push: true |
| 41 | + platforms: linux/amd64 |
| 42 | + labels: ${{ steps.meta.outputs.labels }} |
| 43 | + outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true |
| 44 | + |
| 45 | + - name: Export digest |
| 46 | + run: | |
| 47 | + mkdir -p /tmp/digests |
| 48 | + digest="${{ steps.docker_build_amd64.outputs.digest }}" |
| 49 | + touch "/tmp/digests/${digest#sha256:}" |
| 50 | +
|
| 51 | + - name: Upload digest |
| 52 | + uses: actions/upload-artifact@v3 |
| 53 | + with: |
| 54 | + name: digests |
| 55 | + path: /tmp/digests/* |
| 56 | + if-no-files-found: error |
| 57 | + retention-days: 1 |
| 58 | + |
| 59 | + package-arm64: |
| 60 | + runs-on: buildjet-2vcpu-ubuntu-2204-arm |
| 61 | + permissions: |
| 62 | + packages: write |
| 63 | + contents: read |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v3 |
| 67 | + |
| 68 | + - name: Docker meta |
| 69 | + id: meta |
| 70 | + uses: docker/metadata-action@v4 |
| 71 | + with: |
| 72 | + images: ${{ env.REGISTRY }}/${{ github.repository }} |
| 73 | + |
| 74 | + - name: Set up Docker Buildx |
| 75 | + uses: docker/setup-buildx-action@v2 |
| 76 | + |
| 77 | + - name: Login to CR |
| 78 | + uses: docker/login-action@v2 |
| 79 | + with: |
| 80 | + registry: ${{ env.REGISTRY }} |
| 81 | + username: ${{ github.repository_owner }} |
| 82 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + |
| 84 | + - name: Build docker image and push |
| 85 | + id: docker_build_arm64 |
| 86 | + uses: docker/build-push-action@v4 |
| 87 | + with: |
| 88 | + push: true |
| 89 | + platforms: linux/arm64 |
| 90 | + labels: ${{ steps.meta.outputs.labels }} |
| 91 | + outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true |
| 92 | + |
| 93 | + - name: Export digest |
| 94 | + run: | |
| 95 | + mkdir -p /tmp/digests |
| 96 | + digest="${{ steps.docker_build_arm64.outputs.digest }}" |
| 97 | + touch "/tmp/digests/${digest#sha256:}" |
| 98 | +
|
| 99 | + - name: Upload digest |
| 100 | + uses: actions/upload-artifact@v3 |
| 101 | + with: |
| 102 | + name: digests |
| 103 | + path: /tmp/digests/* |
| 104 | + if-no-files-found: error |
| 105 | + retention-days: 1 |
| 106 | + |
| 107 | + merge: |
| 108 | + runs-on: buildjet-2vcpu-ubuntu-2204 |
| 109 | + needs: |
| 110 | + - package-amd64 |
| 111 | + - package-arm64 |
| 112 | + permissions: |
| 113 | + packages: write |
| 114 | + contents: read |
| 115 | + steps: |
| 116 | + - name: Download digests |
| 117 | + uses: actions/download-artifact@v3 |
| 118 | + with: |
| 119 | + name: digests |
| 120 | + path: /tmp/digests |
| 121 | + |
| 122 | + - name: Set up Docker Buildx |
| 123 | + uses: docker/setup-buildx-action@v2 |
| 124 | + |
| 125 | + - name: Docker meta |
| 126 | + id: meta |
| 127 | + uses: docker/metadata-action@v4 |
| 128 | + with: |
| 129 | + images: ${{ env.REGISTRY }}/${{ github.repository }} |
| 130 | + |
| 131 | + - name: Login to CR |
| 132 | + uses: docker/login-action@v2 |
| 133 | + with: |
| 134 | + registry: ${{ env.REGISTRY }} |
| 135 | + username: ${{ github.repository_owner }} |
| 136 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + |
| 138 | + - name: Create manifest list and push |
| 139 | + working-directory: /tmp/digests |
| 140 | + run: | |
| 141 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 142 | + $(printf '${{ env.REGISTRY }}/${{ github.repository }}@sha256:%s ' *) |
| 143 | +
|
| 144 | + - name: Inspect image |
| 145 | + run: | |
| 146 | + docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.meta.outputs.version }} |
0 commit comments