|
| 1 | +name: Build Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + IMAGE_NAME: ${{ github.repository }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + name: Release |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + os: ["ubuntu-24.04", "ubuntu-24.04-arm"] |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | + attestations: write |
| 22 | + id-token: write |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + # Extract needed info for use with the other steps |
| 27 | + - id: repo-meta |
| 28 | + name: Extract Metadata |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + echo "fqdn=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_OUTPUT |
| 32 | + echo "name=`basename ${{ github.repository }}`" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + - uses: nixbuild/nix-quick-install-action@v30 |
| 35 | + with: |
| 36 | + nix_conf: ${{ env.nix_conf }} |
| 37 | + - name: Restore and save Nix store |
| 38 | + uses: nix-community/cache-nix-action@v6 |
| 39 | + with: |
| 40 | + primary-key: build-${{ runner.os }}-${{ hashFiles('Cargo.lock', '**/Cargo.toml', 'flake.nix', 'flake.lock', 'rust-toolchain.toml') }} |
| 41 | + # We don't want to affect the cache when building the container |
| 42 | + purge: false |
| 43 | + save: false |
| 44 | + |
| 45 | + - name: Log in to the Container registry |
| 46 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 47 | + with: |
| 48 | + registry: ${{ env.REGISTRY }} |
| 49 | + username: ${{ github.actor }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + - name: Build Container |
| 53 | + run: nix run .#streamImage | docker image load |
| 54 | + |
| 55 | + - name: Tag the Container |
| 56 | + run: | |
| 57 | + docker image tag "${{ steps.repo-meta.outputs.name }}:latest" "${{ steps.repo-meta.outputs.fqdn }}:latest" |
| 58 | + docker image tag "${{ steps.repo-meta.outputs.name }}:latest" "${{ steps.repo-meta.outputs.fqdn }}:${{ github.ref_name }}" |
| 59 | +
|
| 60 | + - name: Push the Container |
| 61 | + run: docker image push --all-tags "${{ steps.repo-meta.outputs.fqdn }}" |
| 62 | + |
| 63 | + - id: digest-meta |
| 64 | + name: Extract the digest |
| 65 | + shell: bash |
| 66 | + run: echo "digest=`docker manifest inspect ${{ steps.repo-meta.outputs.fqdn }}:latest --verbose | nix run nixpkgs#jq -- -r .Descriptor.digest`" >> $GITHUB_OUTPUT |
| 67 | + |
| 68 | + - name: Generate artifact attestation |
| 69 | + uses: actions/attest-build-provenance@v2 |
| 70 | + with: |
| 71 | + subject-name: ${{ steps.repo-meta.outputs.fqdn }} |
| 72 | + subject-digest: ${{ steps.digest-meta.outputs.digest }} |
| 73 | + push-to-registry: true |
0 commit comments