|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + # Build first because some Dockerfiles depend on the builder image |
| 10 | + build-and-push-builder: |
| 11 | + name: Build and push container image (builder) |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 |
| 18 | + with: |
| 19 | + submodules: recursive |
| 20 | + |
| 21 | + - name: Set up QEMU |
| 22 | + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 |
| 23 | + |
| 24 | + - name: Set up Docker Buildx |
| 25 | + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 |
| 26 | + |
| 27 | + - name: Login to ghcr.io |
| 28 | + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 |
| 29 | + with: |
| 30 | + registry: ghcr.io |
| 31 | + username: ${{ github.actor }} |
| 32 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + |
| 34 | + - name: Build and push |
| 35 | + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 |
| 36 | + with: |
| 37 | + platforms: linux/amd64,linux/arm64 |
| 38 | + file: build.Dockerfile |
| 39 | + tags: | |
| 40 | + ghcr.io/dena/unity-meta-check/unity-meta-check-builder:${{ github.ref_name }} |
| 41 | + ghcr.io/dena/unity-meta-check/unity-meta-check-builder:latest |
| 42 | + push: true |
| 43 | + cache-from: type=gha |
| 44 | + cache-to: type=gha,mode=max |
| 45 | + |
| 46 | + build-and-push: |
| 47 | + name: Build and push container image |
| 48 | + needs: build-and-push-builder |
| 49 | + runs-on: ubuntu-latest |
| 50 | + permissions: |
| 51 | + contents: read |
| 52 | + |
| 53 | + strategy: |
| 54 | + matrix: |
| 55 | + images: |
| 56 | + - dockerfile: ./Dockerfile |
| 57 | + image_name: ghcr.io/dena/unity-meta-check/unity-meta-check |
| 58 | + - dockerfile: ./.github/images/Dockerfile |
| 59 | + image_name: ghcr.io/dena/unity-meta-check/unity-meta-check-gh-action |
| 60 | + - dockerfile: ./.circleci/images/Dockerfile |
| 61 | + image_name: ghcr.io/dena/unity-meta-check/unity-meta-check-circleci |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 |
| 65 | + with: |
| 66 | + submodules: recursive |
| 67 | + |
| 68 | + - uses: nowsprinting/check-version-format-action@98485692a883d962227b09f40f29a63de0771299 # v4.0.2 |
| 69 | + id: version |
| 70 | + with: |
| 71 | + prefix: "v" |
| 72 | + |
| 73 | + - name: Set up QEMU |
| 74 | + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 |
| 75 | + |
| 76 | + - name: Set up Docker Buildx |
| 77 | + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 |
| 78 | + |
| 79 | + - name: Login to ghcr.io |
| 80 | + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 |
| 81 | + with: |
| 82 | + registry: ghcr.io |
| 83 | + username: ${{ github.actor }} |
| 84 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + |
| 86 | + - name: Build and push |
| 87 | + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 |
| 88 | + with: |
| 89 | + platforms: linux/amd64,linux/arm64 |
| 90 | + file: ${{ matrix.images.dockerfile }} |
| 91 | + tags: ${{ matrix.images.image_name }}:${{ github.ref_name }} |
| 92 | + push: true |
| 93 | + cache-from: type=gha |
| 94 | + cache-to: type=gha,mode=max |
| 95 | + |
| 96 | + - name: Add latest tag |
| 97 | + if: steps.version.outputs.is_stable == 'true' |
| 98 | + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 |
| 99 | + with: |
| 100 | + platforms: linux/amd64,linux/arm64 |
| 101 | + file: ${{ matrix.images.dockerfile }} |
| 102 | + tags: ${{ matrix.images.image_name }}:latest |
| 103 | + push: true |
| 104 | + cache-from: type=gha |
| 105 | + cache-to: type=gha,mode=max |
0 commit comments