|
19 | 19 |
|
20 | 20 | jobs: |
21 | 21 | self-hosted: |
22 | | - runs-on: ubuntu-latest |
23 | | - timeout-minutes: 30 |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - os: ubuntu-24.04 |
| 27 | + platform: amd64 |
| 28 | + - os: ubuntu-24.04-arm |
| 29 | + platform: arm64 |
| 30 | + permissions: |
| 31 | + contents: read |
| 32 | + packages: write |
24 | 33 | steps: |
25 | 34 | - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
26 | 35 |
|
@@ -64,29 +73,144 @@ jobs: |
64 | 73 | python3 -m tools.fast_editable --path . |
65 | 74 | python3 -m sentry.build.main |
66 | 75 |
|
67 | | - - run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN" |
| 76 | + - run: docker login --username '${{ github.actor }}' --password '${{ github.token }}' ghcr.io |
| 77 | + if: github.ref_name == 'master' && github.event_name != 'pull_request' |
| 78 | + |
| 79 | + - name: Set up Docker Buildx |
| 80 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 81 | + |
| 82 | + - name: Build |
| 83 | + uses: docker/build-push-action@32945a339266b759abcbdc89316275140b0fc960 # v6.8.10 |
| 84 | + with: |
| 85 | + context: . |
| 86 | + file: '{context}/self-hosted/Dockerfile' |
| 87 | + cache-from: ghcr.io/getsentry/sentry:latest |
| 88 | + cache-to: type=inline |
| 89 | + platforms: linux/${{ matrix.platform }} |
| 90 | + tags: sentry:${{ matrix.platform }} |
| 91 | + outputs: type=docker,dest=/tmp/sentry-${{ matrix.platform }}.tar |
| 92 | + push: false |
| 93 | + build-args: | |
| 94 | + SOURCE_COMMIT=${{ github.sha }} |
| 95 | + TARGETARCH=${{ matrix.platform }} |
| 96 | +
|
| 97 | + - name: Upload Image |
| 98 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 99 | + with: |
| 100 | + name: sentry-${{ matrix.platform }} |
| 101 | + path: /tmp/sentry-${{ matrix.platform }}.tar |
| 102 | + |
| 103 | + assemble: |
| 104 | + needs: [self-hosted] |
| 105 | + if: ${{ github.ref_name == 'master' && github.event_name != 'pull_request' }} |
| 106 | + runs-on: ubuntu-latest |
| 107 | + permissions: |
| 108 | + contents: read |
| 109 | + packages: write |
| 110 | + steps: |
| 111 | + - name: Docker Login |
| 112 | + run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN" |
68 | 113 | env: |
69 | 114 | GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
70 | | - if: github.event_name != 'pull_request' |
71 | 115 |
|
72 | | - - run: docker buildx create --driver docker-container --use |
| 116 | + - name: Set up Docker Buildx |
| 117 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
73 | 118 |
|
74 | | - - run: | |
75 | | - if [ ${{ github.event_name }} = 'push' ]; then |
76 | | - args=( |
77 | | - --tag ghcr.io/getsentry/sentry-self-hosted:latest |
78 | | - --push |
79 | | - ) |
| 119 | + - name: Download amd64 Image |
| 120 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.2 |
| 121 | + with: |
| 122 | + name: sentry-amd64 |
| 123 | + path: /tmp |
| 124 | + |
| 125 | + - name: Load amd64 Image |
| 126 | + run: docker load --input /tmp/sentry-amd64.tar |
| 127 | + |
| 128 | + - name: Download arm64 Image |
| 129 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.2 |
| 130 | + with: |
| 131 | + name: sentry-arm64 |
| 132 | + path: /tmp |
| 133 | + |
| 134 | + - name: Load arm64 Image |
| 135 | + run: docker load --input /tmp/sentry-arm64.tar |
| 136 | + |
| 137 | + - name: Push to GitHub Container Registry |
| 138 | + run: | |
| 139 | + docker tag sentry:amd64 ghcr.io/getsentry/sentry:${{ github.sha }}-amd64 |
| 140 | + docker push ghcr.io/getsentry/sentry:${{ github.sha }}-amd64 |
| 141 | +
|
| 142 | + docker tag sentry:arm64 ghcr.io/getsentry/sentry:${{ github.sha }}-arm64 |
| 143 | + docker push ghcr.io/getsentry/sentry:${{ github.sha }}-arm64 |
| 144 | +
|
| 145 | + docker manifest create \ |
| 146 | + ghcr.io/getsentry/sentry:${{ github.sha }} \ |
| 147 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-amd64 \ |
| 148 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-arm64 |
| 149 | +
|
| 150 | + docker manifest push ghcr.io/getsentry/sentry:${{ github.sha }} |
| 151 | +
|
| 152 | + docker manifest create \ |
| 153 | + ghcr.io/getsentry/sentry:latest \ |
| 154 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-amd64 \ |
| 155 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-arm64 |
| 156 | +
|
| 157 | + docker manifest push ghcr.io/getsentry/sentry:latest |
| 158 | +
|
| 159 | + docker manifest create \ |
| 160 | + ghcr.io/getsentry/sentry:nightly \ |
| 161 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-amd64 \ |
| 162 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-arm64 |
| 163 | +
|
| 164 | + docker manifest push ghcr.io/getsentry/sentry:nightly |
| 165 | +
|
| 166 | + # These manifests below are being used for development purposes. |
| 167 | + # We shall keep it as is. |
| 168 | + docker manifest create \ |
| 169 | + ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }} \ |
| 170 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-amd64 \ |
| 171 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-arm64 |
| 172 | +
|
| 173 | + docker manifest push ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }} |
| 174 | +
|
| 175 | + docker manifest create \ |
| 176 | + ghcr.io/getsentry/sentry-self-hosted:latest \ |
| 177 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-amd64 \ |
| 178 | + --amend ghcr.io/getsentry/sentry:${{ github.sha }}-arm64 |
| 179 | +
|
| 180 | + docker manifest push ghcr.io/getsentry/sentry-self-hosted:latest |
| 181 | +
|
| 182 | + publish-dockerhub: |
| 183 | + needs: [assemble] |
| 184 | + runs-on: ubuntu-latest |
| 185 | + if: ${{ (github.ref_name == 'master') }} |
| 186 | + steps: |
| 187 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 188 | + - name: Get short SHA for docker tag |
| 189 | + id: short_sha |
| 190 | + shell: bash |
| 191 | + run: | |
| 192 | + SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA") |
| 193 | + if [[ -z "$SHORT_SHA" ]]; then |
| 194 | + echo "Short SHA empty? Re-running rev-parse." |
| 195 | + git rev-parse --short "$GITHUB_SHA" |
80 | 196 | else |
81 | | - args=() |
| 197 | + echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT |
82 | 198 | fi |
| 199 | + - name: Push built docker image |
| 200 | + shell: bash |
| 201 | + env: |
| 202 | + SHORT_SHA: ${{ steps.short_sha.outputs.sha }} |
| 203 | + IMAGE_URL: ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }} |
| 204 | + run: | |
| 205 | + # only login if the password is set |
| 206 | + if [[ "${{ secrets.DOCKER_HUB_RW_TOKEN }}" ]]; then echo "${{ secrets.DOCKER_HUB_RW_TOKEN }}" | docker login --username=sentrybuilder --password-stdin; fi |
| 207 | +
|
| 208 | + # We push 3 tags to Dockerhub: |
| 209 | + # first, the full sha of the commit |
| 210 | + docker buildx imagetools create --tag getsentry/sentry:${GITHUB_SHA} ghcr.io/getsentry/sentry:${{ github.sha }} |
| 211 | +
|
| 212 | + # second, the short sha of the commit |
| 213 | + docker buildx imagetools create --tag getsentry/sentry:${SHORT_SHA} ghcr.io/getsentry/sentry:${{ github.sha }} |
83 | 214 |
|
84 | | - docker buildx build \ |
85 | | - --pull \ |
86 | | - --cache-from ghcr.io/getsentry/sentry-self-hosted:latest \ |
87 | | - --cache-to type=inline \ |
88 | | - --tag ghcr.io/getsentry/sentry-self-hosted:${{ github.sha }} \ |
89 | | - --file self-hosted/Dockerfile \ |
90 | | - --build-arg SOURCE_COMMIT=${{ github.sha }} \ |
91 | | - "${args[@]}" \ |
92 | | - . |
| 215 | + # finally, nightly |
| 216 | + docker buildx imagetools create --tag getsentry/sentry:nightly ghcr.io/getsentry/sentry:${{ github.sha }} |
0 commit comments