|
| 1 | +name: build_push_decent_latex_dev_img |
| 2 | + |
| 3 | + |
| 4 | +on: |
| 5 | + release: |
| 6 | + types: [published] |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + paths: |
| 11 | + - LaTexDev/** |
| 12 | + - .github/workflows/build-latex-dev.yaml |
| 13 | + |
| 14 | + |
| 15 | +jobs: |
| 16 | + build_decent_latex_dev_amd64: |
| 17 | + name: Build and publish Decent LaTex DevContainer image (amd64) |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + permissions: |
| 20 | + packages: write |
| 21 | + contents: read |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Check out the repo |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@v2 |
| 29 | + |
| 30 | + - name: Log in to the Container registry |
| 31 | + uses: docker/login-action@v3 |
| 32 | + with: |
| 33 | + registry: ghcr.io |
| 34 | + username: ${{ github.actor }} |
| 35 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Generate package repo name |
| 38 | + id: ghcr_repo |
| 39 | + run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-latex-dev" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT |
| 40 | + |
| 41 | + - name: Extract metadata (tags, labels) for Docker |
| 42 | + id: meta |
| 43 | + uses: docker/metadata-action@v5 |
| 44 | + with: |
| 45 | + images: | |
| 46 | + ${{ steps.ghcr_repo.outputs.path }} |
| 47 | +
|
| 48 | + - name: Get current commit SHA short |
| 49 | + id: commit_sha |
| 50 | + run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT |
| 51 | + |
| 52 | + - name: Manually generate sha tag |
| 53 | + id: tag_sha |
| 54 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT |
| 55 | + |
| 56 | + - name: Manually generate head tag |
| 57 | + id: tag_head |
| 58 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:head" >> $GITHUB_OUTPUT |
| 59 | + |
| 60 | + - name: Manually generate ver tag |
| 61 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 62 | + id: tag_ver |
| 63 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 64 | + |
| 65 | + - name: Build and push Docker images for each commit |
| 66 | + uses: docker/build-push-action@v5 |
| 67 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 68 | + with: |
| 69 | + context: ./LaTexDev |
| 70 | + platforms: linux/amd64 |
| 71 | + push: true |
| 72 | + tags: | |
| 73 | + ${{ steps.tag_sha.outputs.tag }}-amd64 |
| 74 | + ${{ steps.tag_head.outputs.tag }}-amd64 |
| 75 | + labels: ${{ steps.meta.outputs.labels }} |
| 76 | + |
| 77 | + - name: Create and push a manifest with ver referencing version |
| 78 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 79 | + run: | |
| 80 | + docker buildx imagetools create \ |
| 81 | + -t ${{ steps.tag_ver.outputs.tag }}-amd64 \ |
| 82 | + ${{ steps.tag_head.outputs.tag }}-amd64 |
| 83 | +
|
| 84 | +
|
| 85 | + build_decent_latex_dev_arm64: |
| 86 | + name: Build and publish Decent LaTex DevContainer image (arm64) |
| 87 | + runs-on: ubuntu-24.04-arm |
| 88 | + permissions: |
| 89 | + packages: write |
| 90 | + contents: read |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Check out the repo |
| 94 | + uses: actions/checkout@v4 |
| 95 | + |
| 96 | + - name: Set up Docker Buildx |
| 97 | + uses: docker/setup-buildx-action@v2 |
| 98 | + |
| 99 | + - name: Log in to the Container registry |
| 100 | + uses: docker/login-action@v3 |
| 101 | + with: |
| 102 | + registry: ghcr.io |
| 103 | + username: ${{ github.actor }} |
| 104 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + |
| 106 | + - name: Generate package repo name |
| 107 | + id: ghcr_repo |
| 108 | + run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-latex-dev" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT |
| 109 | + |
| 110 | + - name: Extract metadata (tags, labels) for Docker |
| 111 | + id: meta |
| 112 | + uses: docker/metadata-action@v5 |
| 113 | + with: |
| 114 | + images: | |
| 115 | + ${{ steps.ghcr_repo.outputs.path }} |
| 116 | +
|
| 117 | + - name: Get current commit SHA short |
| 118 | + id: commit_sha |
| 119 | + run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT |
| 120 | + |
| 121 | + - name: Manually generate sha tag |
| 122 | + id: tag_sha |
| 123 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT |
| 124 | + |
| 125 | + - name: Manually generate head tag |
| 126 | + id: tag_head |
| 127 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:head" >> $GITHUB_OUTPUT |
| 128 | + |
| 129 | + - name: Manually generate ver tag |
| 130 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 131 | + id: tag_ver |
| 132 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 133 | + |
| 134 | + - name: Build and push Docker images for each commit |
| 135 | + uses: docker/build-push-action@v5 |
| 136 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 137 | + with: |
| 138 | + context: ./LaTexDev |
| 139 | + platforms: linux/arm64 |
| 140 | + push: true |
| 141 | + tags: | |
| 142 | + ${{ steps.tag_sha.outputs.tag }}-arm64 |
| 143 | + ${{ steps.tag_head.outputs.tag }}-arm64 |
| 144 | + labels: ${{ steps.meta.outputs.labels }} |
| 145 | + |
| 146 | + - name: Create and push a manifest with ver referencing version |
| 147 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 148 | + run: | |
| 149 | + docker buildx imagetools create \ |
| 150 | + -t ${{ steps.tag_ver.outputs.tag }}-arm64 \ |
| 151 | + ${{ steps.tag_head.outputs.tag }}-arm64 |
| 152 | +
|
| 153 | +
|
| 154 | + push_multi_arch_manifest: |
| 155 | + name: Push Docker multi-arch manifest to Container registry |
| 156 | + needs: [build_decent_latex_dev_amd64, build_decent_latex_dev_arm64] |
| 157 | + runs-on: ubuntu-24.04 |
| 158 | + permissions: |
| 159 | + packages: write |
| 160 | + contents: read |
| 161 | + |
| 162 | + steps: |
| 163 | + - name: Check out the repo |
| 164 | + uses: actions/checkout@v4 |
| 165 | + |
| 166 | + - name: Set up Docker Buildx |
| 167 | + uses: docker/setup-buildx-action@v2 |
| 168 | + |
| 169 | + - name: Log in to the Container registry |
| 170 | + uses: docker/login-action@v3 |
| 171 | + with: |
| 172 | + registry: ghcr.io |
| 173 | + username: ${{ github.actor }} |
| 174 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 175 | + |
| 176 | + - name: Generate package repo name |
| 177 | + id: ghcr_repo |
| 178 | + run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-latex-dev" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT |
| 179 | + |
| 180 | + - name: Extract metadata (tags, labels) for Docker |
| 181 | + id: meta |
| 182 | + uses: docker/metadata-action@v5 |
| 183 | + with: |
| 184 | + images: | |
| 185 | + ${{ steps.ghcr_repo.outputs.path }} |
| 186 | +
|
| 187 | + - name: Get current commit SHA short |
| 188 | + id: commit_sha |
| 189 | + run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT |
| 190 | + |
| 191 | + - name: Manually generate sha tag |
| 192 | + id: tag_sha |
| 193 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT |
| 194 | + |
| 195 | + - name: Manually generate head tag |
| 196 | + id: tag_head |
| 197 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:head" >> $GITHUB_OUTPUT |
| 198 | + |
| 199 | + - name: Manually generate ver tag |
| 200 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 201 | + id: tag_ver |
| 202 | + run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 203 | + |
| 204 | + - name: Create and push a manifest referencing git sha |
| 205 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 206 | + run: | |
| 207 | + docker buildx imagetools create \ |
| 208 | + -t ${{ steps.tag_sha.outputs.tag }} \ |
| 209 | + ${{ steps.tag_sha.outputs.tag }}-arm64 \ |
| 210 | + ${{ steps.tag_sha.outputs.tag }}-amd64 |
| 211 | +
|
| 212 | + - name: Create and push a manifest referencing git head |
| 213 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 214 | + run: | |
| 215 | + docker buildx imagetools create \ |
| 216 | + -t ${{ steps.tag_head.outputs.tag }} \ |
| 217 | + ${{ steps.tag_head.outputs.tag }}-arm64 \ |
| 218 | + ${{ steps.tag_head.outputs.tag }}-amd64 |
| 219 | +
|
| 220 | + - name: Create and push a manifest with ver referencing version |
| 221 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 222 | + run: | |
| 223 | + docker buildx imagetools create \ |
| 224 | + -t ${{ steps.tag_ver.outputs.tag }} \ |
| 225 | + ${{ steps.tag_ver.outputs.tag }}-arm64 \ |
| 226 | + ${{ steps.tag_ver.outputs.tag }}-amd64 |
| 227 | +
|
0 commit comments