omega-packages
aien-dev/omega-packages
Brought by drakestapleton
omega-packages / .github / workflows / release.yml
| 1 | name: release |
| 2 | # On a v* tag: birth omc from the seed, package it, push ghcr.io/aien-dev/omc, attest everything with |
| 3 | # GitHub artifact attestations (SLSA build provenance; SPDX SBOM for omc), verify the attestations with |
| 4 | # `gh attestation verify`, and publish a GitHub Release carrying SHA256SUMS. |
| 5 | on: |
| 6 | push: |
| 7 | tags: ['v*'] |
| 8 | permissions: |
| 9 | contents: read |
| 10 | jobs: |
| 11 | build: |
| 12 | runs-on: ubuntu-24.04-arm |
| 13 | timeout-minutes: 30 |
| 14 | permissions: |
| 15 | contents: read |
| 16 | steps: |
| 17 | - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 18 | with: |
| 19 | persist-credentials: false |
| 20 | - name: Birth omc from the seed |
| 21 | run: sh scripts/omc-from-seed.sh build |
| 22 | - name: Assemble dist/ |
| 23 | run: | |
| 24 | set -eu |
| 25 | . ./pins.env |
| 26 | mkdir -p dist |
| 27 | cp build/omc dist/omc-linux-arm64 |
| 28 | sh debian/build-deb.sh build/omc dist |
| 29 | sh scripts/sbom.sh "build/omega-mv-$OMEGA_MV_COMMIT" build/omc > dist/omc.spdx.json |
| 30 | pipx run --spec 'spdx-tools==0.8.3' pyspdxtools -i dist/omc.spdx.json |
| 31 | (cd dist && sha256sum omc-linux-arm64 omc_*_arm64.deb omc.spdx.json > SHA256SUMS && cat SHA256SUMS) |
| 32 | - name: dpkg -i the .deb and compile hello.om |
| 33 | run: | |
| 34 | set -eu |
| 35 | sudo dpkg -i dist/omc_*_arm64.deb |
| 36 | d=$(mktemp -d); cp examples/hello.om "$d"; cd "$d" |
| 37 | omc < hello.om > hello; chmod +x hello; [ "$(./hello)" = "omega 55" ] |
| 38 | - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 39 | with: |
| 40 | name: dist |
| 41 | path: dist/ |
| 42 | |
| 43 | image: |
| 44 | needs: [build] |
| 45 | runs-on: ubuntu-24.04-arm |
| 46 | timeout-minutes: 30 |
| 47 | permissions: |
| 48 | contents: read |
| 49 | packages: write |
| 50 | id-token: write |
| 51 | attestations: write |
| 52 | outputs: |
| 53 | digest: ${{ steps.push.outputs.digest }} |
| 54 | tag: ${{ steps.tag.outputs.tag }} |
| 55 | steps: |
| 56 | - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 57 | with: |
| 58 | persist-credentials: false |
| 59 | - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 60 | with: |
| 61 | name: dist |
| 62 | path: dist |
| 63 | - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 |
| 64 | with: |
| 65 | subject-path: | |
| 66 | dist/omc-linux-arm64 |
| 67 | dist/omc_*_arm64.deb |
| 68 | - uses: actions/attest-sbom@bd218ad0dbcb3e146bd073d1d9c6d78e08aa8a0b # v2.4.0 |
| 69 | with: |
| 70 | subject-path: dist/omc-linux-arm64 |
| 71 | sbom-path: dist/omc.spdx.json |
| 72 | - id: tag |
| 73 | run: | |
| 74 | . ./pins.env |
| 75 | echo "tag=$(printf '%s' "$OMC_VERSION" | tr '+' '-')" >> "$GITHUB_OUTPUT" |
| 76 | # Default image is the floating tag moby/buildkit:buildx-stable-1. |
| 77 | # Pinned to that tag's index digest (BuildKit v0.33.1). |
| 78 | - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 |
| 79 | with: |
| 80 | driver-opts: image=moby/buildkit@sha256:cec9f139f45e93c5c69c60f8b07cfad9f43f4ef6b6a6cd917527fea5ff2e3dea |
| 81 | - uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0 |
| 82 | with: |
| 83 | registry: ghcr.io |
| 84 | username: ${{ github.actor }} |
| 85 | password: ${{ secrets.GITHUB_TOKEN }} |
| 86 | - id: push |
| 87 | uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 |
| 88 | with: |
| 89 | context: docker |
| 90 | platforms: linux/arm64 |
| 91 | push: true |
| 92 | provenance: false |
| 93 | tags: | |
| 94 | ghcr.io/aien-dev/omc:${{ steps.tag.outputs.tag }} |
| 95 | ghcr.io/aien-dev/omc:latest |
| 96 | - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 |
| 97 | with: |
| 98 | subject-name: ghcr.io/aien-dev/omc |
| 99 | subject-digest: ${{ steps.push.outputs.digest }} |
| 100 | push-to-registry: true |
| 101 | - name: The pushed image (by digest) compiles hello.om |
| 102 | env: |
| 103 | DIGEST: ${{ steps.push.outputs.digest }} |
| 104 | run: | |
| 105 | set -eu |
| 106 | docker run --rm -i "ghcr.io/aien-dev/omc@$DIGEST" < examples/hello.om > hello |
| 107 | chmod +x hello; out=$(./hello); echo "hello prints: $out"; [ "$out" = "omega 55" ] |
| 108 | |
| 109 | publish: |
| 110 | needs: [build, image] |
| 111 | runs-on: ubuntu-24.04-arm |
| 112 | permissions: |
| 113 | contents: write |
| 114 | packages: read |
| 115 | steps: |
| 116 | - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 117 | with: |
| 118 | persist-credentials: false |
| 119 | - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 120 | with: |
| 121 | name: dist |
| 122 | path: dist |
| 123 | - uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0 |
| 124 | with: |
| 125 | registry: ghcr.io |
| 126 | username: ${{ github.actor }} |
| 127 | password: ${{ secrets.GITHUB_TOKEN }} |
| 128 | - name: gh attestation verify (binary, .deb, SBOM, image) |
| 129 | env: |
| 130 | GH_TOKEN: ${{ github.token }} |
| 131 | DIGEST: ${{ needs.image.outputs.digest }} |
| 132 | run: | |
| 133 | set -eu |
| 134 | cd dist && sha256sum -c SHA256SUMS |
| 135 | gh attestation verify omc-linux-arm64 --repo "$GITHUB_REPOSITORY" |
| 136 | gh attestation verify omc_*_arm64.deb --repo "$GITHUB_REPOSITORY" |
| 137 | gh attestation verify omc-linux-arm64 --repo "$GITHUB_REPOSITORY" --predicate-type https://spdx.dev/Document/v2.3 |
| 138 | gh attestation verify "oci://ghcr.io/aien-dev/omc@$DIGEST" --repo "$GITHUB_REPOSITORY" |
| 139 | - name: Publish the GitHub Release |
| 140 | env: |
| 141 | GH_TOKEN: ${{ github.token }} |
| 142 | DIGEST: ${{ needs.image.outputs.digest }} |
| 143 | TAG: ${{ needs.image.outputs.tag }} |
| 144 | run: | |
| 145 | set -eu |
| 146 | . ./pins.env |
| 147 | { |
| 148 | echo "omc $OMC_VERSION, born from the 408-byte seed of aien-dev/omega-mv at \`$OMEGA_MV_COMMIT\`." |
| 149 | echo |
| 150 | echo "AArch64 (arm64) Linux only. omc reads .om on stdin and writes a static AArch64 Linux ELF to stdout." |
| 151 | echo |
| 152 | echo '```' |
| 153 | cat dist/SHA256SUMS |
| 154 | echo '```' |
| 155 | echo |
| 156 | echo "Container: \`ghcr.io/aien-dev/omc:$TAG\` = \`ghcr.io/aien-dev/omc@$DIGEST\`" |
| 157 | echo |
| 158 | echo "Every file and the image carry a GitHub artifact attestation (SLSA build provenance); omc-linux-arm64 also carries its SPDX SBOM. Check one with:" |
| 159 | echo |
| 160 | echo '```' |
| 161 | echo 'gh attestation verify omc-linux-arm64 --repo aien-dev/omega-packages' |
| 162 | echo '```' |
| 163 | } > notes.md |
| 164 | gh release create "$GITHUB_REF_NAME" dist/omc-linux-arm64 dist/omc_*_arm64.deb dist/omc.spdx.json dist/SHA256SUMS \ |
| 165 | --title "omc $OMC_VERSION" --notes-file notes.md |