|
9 | 9 | - master |
10 | 10 | - feature/tree-sitter-markdown |
11 | 11 |
|
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
| 15 | + |
12 | 16 | jobs: |
13 | 17 | build-and-push: |
14 | 18 | name: Build And Push |
15 | | - runs-on: ubuntu-latest |
16 | | - needs: [] |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - platform: linux/amd64 |
| 24 | + runner: ubuntu-latest |
| 25 | + - platform: linux/arm64 |
| 26 | + runner: ubuntu-24.04-arm |
| 27 | + runs-on: ${{ matrix.runner }} |
17 | 28 | steps: |
18 | 29 | - name: Checkout |
19 | 30 | uses: actions/checkout@v3 |
@@ -66,26 +77,118 @@ jobs: |
66 | 77 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
67 | 78 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
68 | 79 |
|
69 | | - - name: Set up QEMU |
70 | | - uses: docker/setup-qemu-action@v2 |
71 | | - |
72 | | - - name: Set up buildx |
| 80 | + - name: Set up Docker Buildx |
73 | 81 | id: buildx |
74 | | - uses: docker/setup-buildx-action@v2 |
75 | | - with: |
76 | | - version: latest |
| 82 | + uses: docker/setup-buildx-action@v3 |
77 | 83 |
|
78 | 84 | - name: Log in to Docker Hub |
79 | | - uses: docker/login-action@v1 |
| 85 | + uses: docker/login-action@v3 |
80 | 86 | with: |
81 | 87 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
82 | 88 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
83 | 89 |
|
84 | | - - name: Push to Docker Hub |
85 | | - uses: docker/build-push-action@v3 |
| 90 | + - name: Log in to GitHub Container Registry |
| 91 | + uses: docker/login-action@v3 |
| 92 | + with: |
| 93 | + registry: ghcr.io |
| 94 | + username: ${{ github.actor }} |
| 95 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + |
| 97 | + - name: Build and push by digest |
| 98 | + id: build |
| 99 | + uses: docker/build-push-action@v6 |
86 | 100 | with: |
87 | 101 | context: . |
| 102 | + file: ./Dockerfile |
88 | 103 | target: STANDARD |
89 | | - platforms: linux/amd64 |
| 104 | + platforms: ${{ matrix.platform }} |
90 | 105 | push: true |
91 | | - tags: ${{ secrets.DOCKERHUB_REPOSITORY }}/codebase-embedder:${{ steps.version.outputs.version }},${{ secrets.DOCKERHUB_REPOSITORY }}/codebase-embedder:latest |
| 106 | + provenance: false |
| 107 | + outputs: type=image,"name=${{ secrets.DOCKERHUB_REPOSITORY }}/codebase-embedder,ghcr.io/${{ github.repository }}",push-by-digest=true,name-canonical=true |
| 108 | + build-args: | |
| 109 | + VERSION=${{ steps.version.outputs.version }} |
| 110 | +
|
| 111 | + - name: Export digest |
| 112 | + run: | |
| 113 | + mkdir -p /tmp/digests |
| 114 | + digest="${{ steps.build.outputs.digest }}" |
| 115 | + touch "/tmp/digests/${digest#sha256:}" |
| 116 | +
|
| 117 | + - name: Upload digest |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + with: |
| 120 | + name: digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} |
| 121 | + path: /tmp/digests/* |
| 122 | + if-no-files-found: error |
| 123 | + retention-days: 1 |
| 124 | + |
| 125 | + merge: |
| 126 | + name: Merge Multi-Arch Manifests |
| 127 | + runs-on: ubuntu-latest |
| 128 | + needs: |
| 129 | + - build-and-push |
| 130 | + steps: |
| 131 | + - name: Download digests |
| 132 | + uses: actions/download-artifact@v4 |
| 133 | + with: |
| 134 | + path: /tmp/digests |
| 135 | + pattern: digests-* |
| 136 | + merge-multiple: true |
| 137 | + |
| 138 | + - name: Set up Docker Buildx |
| 139 | + uses: docker/setup-buildx-action@v3 |
| 140 | + |
| 141 | + - name: Log in to Docker Hub |
| 142 | + uses: docker/login-action@v3 |
| 143 | + with: |
| 144 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 145 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 146 | + |
| 147 | + - name: Log in to GitHub Container Registry |
| 148 | + uses: docker/login-action@v3 |
| 149 | + with: |
| 150 | + registry: ghcr.io |
| 151 | + username: ${{ github.actor }} |
| 152 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 153 | + |
| 154 | + - name: Get version |
| 155 | + id: version |
| 156 | + run: | |
| 157 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 158 | + CURRENT_VERSION=${GITHUB_REF#refs/tags/} |
| 159 | + echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 160 | + else |
| 161 | + LATEST_TAG=$(git tag -l "v*.*.*" | sort -V | tail -n1) |
| 162 | + if [ -z "$LATEST_TAG" ]; then |
| 163 | + NEW_VERSION="v1.0.0" |
| 164 | + else |
| 165 | + VERSION_PART=$(echo $LATEST_TAG | sed 's/v//') |
| 166 | + MAJOR=$(echo $VERSION_PART | cut -d. -f1) |
| 167 | + MINOR=$(echo $VERSION_PART | cut -d. -f2) |
| 168 | + PATCH=$(echo $VERSION_PART | cut -d. -f3) |
| 169 | + PATCH=$((PATCH + 1)) |
| 170 | + NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" |
| 171 | + fi |
| 172 | + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 173 | + fi |
| 174 | +
|
| 175 | + - name: Create manifest list and push to Docker Hub |
| 176 | + working-directory: /tmp/digests |
| 177 | + run: | |
| 178 | + docker buildx imagetools create \ |
| 179 | + -t ${{ secrets.DOCKERHUB_REPOSITORY }}/codebase-embedder:${{ steps.version.outputs.version }} \ |
| 180 | + -t ${{ secrets.DOCKERHUB_REPOSITORY }}/codebase-embedder:latest \ |
| 181 | + $(printf '${{ secrets.DOCKERHUB_REPOSITORY }}/codebase-embedder@sha256:%s ' *) |
| 182 | +
|
| 183 | + - name: Create manifest list and push to GHCR |
| 184 | + working-directory: /tmp/digests |
| 185 | + run: | |
| 186 | + docker buildx imagetools create \ |
| 187 | + -t ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} \ |
| 188 | + -t ghcr.io/${{ github.repository }}:latest \ |
| 189 | + $(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *) |
| 190 | +
|
| 191 | + - name: Inspect image |
| 192 | + run: | |
| 193 | + docker buildx imagetools inspect ${{ secrets.DOCKERHUB_REPOSITORY }}/codebase-embedder:${{ steps.version.outputs.version }} |
| 194 | + docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} |
0 commit comments