Build cpak #122
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
| name: Build cpak | |
| on: | |
| push: | |
| branches: ["**"] | |
| tags: ["*"] | |
| schedule: | |
| - cron: '40 7 * * 2' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| concurrency: | |
| group: build-cpak-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e | |
| - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - id: meta | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 | |
| with: | |
| images: ghcr.io/bottlesdevs/bottles | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=sha,prefix=sha- | |
| - id: build | |
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a | |
| with: | |
| context: . | |
| file: build-aux/cpak/Containerfile | |
| platforms: linux/amd64 | |
| push: true | |
| pull: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: mode=max | |
| sbom: true | |
| - name: Publish summary | |
| run: echo "ghcr.io/bottlesdevs/bottles@${{ steps.build.outputs.digest }}" >> "$GITHUB_STEP_SUMMARY" | |
| - name: Pin published image | |
| if: github.ref == 'refs/heads/main' | |
| env: | |
| IMAGE_DIGEST: ${{ steps.build.outputs.digest }} | |
| run: | | |
| repository="$(jq -r '.image | split("@")[0]' cpak.json)" | |
| jq --arg image "${repository}@${IMAGE_DIGEST}" '.image = $image' cpak.json > cpak.json.next | |
| mv cpak.json.next cpak.json | |
| if ! git diff --quiet -- cpak.json; then | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add cpak.json | |
| git commit -m "chore: pin published image [skip ci]" | |
| git push origin "HEAD:${{ github.event.repository.default_branch }}" | |
| fi | |
| - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 | |
| - name: Install cpak-sign | |
| run: | | |
| curl -fsSLO https://github.com/Containerpak/cpak/releases/download/v2.10.4/cpak-sign-linux-amd64 | |
| echo '3f0feeb0c2428de8205ea0380635d9e334bdbd46ff6917647cf1e8f16265e424 cpak-sign-linux-amd64' | sha256sum -c - | |
| install -Dm755 cpak-sign-linux-amd64 /usr/local/bin/cpak-sign | |
| - name: Sign the package state | |
| env: | |
| CPAK_REGISTRY_USERNAME: ${{ github.actor }} | |
| CPAK_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| repository="$(printf '%s' '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" | |
| cpak-sign state \ | |
| --origin "github.com/${repository}" \ | |
| --generation "${{ github.run_number }}" | |
| cosign sign-blob --yes --new-bundle-format=true \ | |
| --bundle cpak-state.sigstore.json cpak-state | |
| cpak-sign attach --image "ghcr.io/${repository}" |