-
Notifications
You must be signed in to change notification settings - Fork 204
fix: Add back temporary workflow to publish main to ghcr #725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| # Internal reusable workflow for building multi-platform Docker images. | ||
| # | ||
| # This workflow builds Docker images for linux/amd64 and linux/arm64 platforms, | ||
| # pushes them by digest to GHCR, signs them with cosign/Sigstore for supply chain | ||
| # security, and uploads build artifacts for subsequent manifest creation. | ||
| # | ||
| # @ see: https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners | ||
|
|
||
| name: Build Multi-Platform Images | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| git_ref: | ||
| description: "Git ref to checkout" | ||
| required: true | ||
| type: string | ||
| docker_tags: | ||
| description: "Docker tags configuration (JSON array or raw tags)" | ||
| required: true | ||
| type: string | ||
| use_app_token: | ||
| description: "Whether to use GitHub App token for checkout" | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| secrets: | ||
| release_app_id: | ||
| description: "GitHub App ID (required if use_app_token is true)" | ||
| required: false | ||
| release_app_private_key: | ||
| description: "GitHub App private key (required if use_app_token is true)" | ||
| required: false | ||
|
|
||
| env: | ||
| REGISTRY_IMAGE: ghcr.io/sourcebot-dev/sourcebot | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ${{ matrix.runs-on}} | ||
| environment: oss | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| # Required for keyless signing with cosign/Sigstore. | ||
| # Allows workflow to obtain OIDC token for ephemeral certificate from Fulcio. | ||
| id-token: write | ||
| strategy: | ||
| matrix: | ||
| platform: [linux/amd64, linux/arm64] | ||
| include: | ||
| - platform: linux/amd64 | ||
| runs-on: ubuntu-latest | ||
| - platform: linux/arm64 | ||
| runs-on: ubuntu-24.04-arm | ||
|
|
||
| steps: | ||
| - name: Generate GitHub App token | ||
| if: inputs.use_app_token | ||
| id: generate_token | ||
| uses: actions/create-github-app-token@v1 | ||
| with: | ||
| app-id: ${{ secrets.release_app_id }} | ||
| private-key: ${{ secrets.release_app_private_key }} | ||
|
|
||
| - name: Prepare | ||
| run: | | ||
| platform=${{ matrix.platform }} | ||
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ inputs.git_ref }} | ||
| submodules: "true" | ||
| fetch-depth: 0 | ||
| token: ${{ inputs.use_app_token && steps.generate_token.outputs.token || github.token }} | ||
|
|
||
| # Extract metadata (tags, labels) for Docker | ||
| # https://github.com/docker/metadata-action | ||
| - name: Extract Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY_IMAGE }} | ||
| tags: ${{ inputs.docker_tags }} | ||
|
|
||
| # Install the cosign tool except on PR | ||
| # https://github.com/sigstore/cosign-installer | ||
| - name: Install cosign | ||
| uses: sigstore/[email protected] | ||
| with: | ||
| cosign-release: "v2.2.4" | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Login to GitHub Packages Docker Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build Docker image | ||
| id: build | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha,scope=${{ env.PLATFORM_PAIR }} | ||
| cache-to: type=gha,mode=max,scope=${{ env.PLATFORM_PAIR }} | ||
| platforms: ${{ matrix.platform }} | ||
| outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true,annotation.org.opencontainers.image.description=Blazingly fast code search | ||
|
|
||
| - name: Export digest | ||
| run: | | ||
| mkdir -p /tmp/digests | ||
| digest="${{ steps.build.outputs.digest }}" | ||
| touch "/tmp/digests/${digest#sha256:}" | ||
|
|
||
| - name: Upload digest | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: digests-${{ env.PLATFORM_PAIR }} | ||
| path: /tmp/digests/* | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
|
|
||
| # Sign the resulting Docker image digest except on PRs. | ||
| # This will only write to the public Rekor transparency log when the Docker | ||
| # repository is public to avoid leaking data. If you would like to publish | ||
| # transparency data even for private images, pass --force to cosign below. | ||
| # https://github.com/sigstore/cosign | ||
| - name: Sign the published Docker image | ||
| env: | ||
| # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable | ||
| TAGS: ${{ steps.meta.outputs.tags }} | ||
| DIGEST: ${{ steps.build.outputs.digest }} | ||
| # This step uses the identity token to provision an ephemeral certificate | ||
| # against the sigstore community Fulcio instance. | ||
| run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Internal reusable workflow for merging platform-specific image digests into a | ||
| # single multi-platform manifest and pushing to GHCR. | ||
| # | ||
| # This workflow takes the individual platform image digests created by _build.yml, | ||
| # combines them into a multi-platform manifest, and pushes the final tagged images. | ||
|
|
||
| name: Merge Multi-Platform Manifest | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| docker_tags: | ||
| description: "Docker tags configuration (JSON array or raw tags)" | ||
| required: true | ||
| type: string | ||
|
|
||
| env: | ||
| REGISTRY_IMAGE: ghcr.io/sourcebot-dev/sourcebot | ||
|
|
||
| jobs: | ||
| merge: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| packages: write | ||
| steps: | ||
| - name: Download digests | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: /tmp/digests | ||
| pattern: digests-* | ||
| merge-multiple: true | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Extract Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY_IMAGE }} | ||
| tags: ${{ inputs.docker_tags }} | ||
|
|
||
| - name: Login to GitHub Packages Docker Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create manifest list and push | ||
| working-directory: /tmp/digests | ||
| run: | | ||
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | ||
|
|
||
| - name: Inspect image | ||
| run: | | ||
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| name: Release Sourcebot (Development) | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: ./.github/workflows/_build.yml | ||
| with: | ||
| git_ref: ${{ github.ref_name }} | ||
| docker_tags: type=raw,value=main | ||
| use_app_token: false | ||
| secrets: inherit | ||
|
|
||
| publish-to-registry: | ||
|
||
| needs: build | ||
| uses: ./.github/workflows/_merge.yml | ||
| with: | ||
| docker_tags: type=raw,value=main | ||
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.