|
| 1 | +name: release-tee |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: "Release tag (e.g., v1.7.0). If empty, uses version from Cargo.toml" |
| 8 | + type: string |
| 9 | + required: false |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + |
| 14 | +permissions: |
| 15 | + id-token: write # OIDC token for Sigstore signing |
| 16 | + attestations: write # Persist attestations |
| 17 | + contents: write # Release artifact upload |
| 18 | + |
| 19 | +jobs: |
| 20 | + prepare: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + tag_name: ${{ steps.release_info.outputs.tag_name }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Get version |
| 27 | + id: release_info |
| 28 | + run: | |
| 29 | + if [[ -n "${{ github.event.inputs.tag }}" ]]; then |
| 30 | + echo "tag_name=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT |
| 31 | + else |
| 32 | + cargo install cargo-get |
| 33 | + echo "tag_name=v$(cargo get workspace.package.version)" >> $GITHUB_OUTPUT |
| 34 | + fi |
| 35 | +
|
| 36 | + build-contracts: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + needs: prepare |
| 39 | + container: |
| 40 | + image: ghcr.io/dojoengine/katana-dev:latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + - name: Build contracts |
| 44 | + run: make contracts |
| 45 | + - name: Upload contract artifacts |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: contract-artifacts |
| 49 | + path: ./crates/contracts/build |
| 50 | + retention-days: 1 |
| 51 | + |
| 52 | + reproducible-build: |
| 53 | + name: Reproducible TEE Build |
| 54 | + needs: [prepare, build-contracts] |
| 55 | + runs-on: ubuntu-latest-8-cores |
| 56 | + outputs: |
| 57 | + binary-hash: ${{ steps.hash.outputs.sha384 }} |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Download contract artifacts |
| 64 | + uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + name: contract-artifacts |
| 67 | + path: ./crates/contracts/build |
| 68 | + |
| 69 | + - name: Set up Docker Buildx |
| 70 | + uses: docker/setup-buildx-action@v3 |
| 71 | + |
| 72 | + - name: Build reproducible binary |
| 73 | + run: | |
| 74 | + docker build \ |
| 75 | + -f reproducible.Dockerfile \ |
| 76 | + -t katana-reproducible:${{ needs.prepare.outputs.tag_name }} \ |
| 77 | + --no-cache \ |
| 78 | + . |
| 79 | +
|
| 80 | + - name: Extract binary from container |
| 81 | + run: | |
| 82 | + docker create --name katana-extract katana-reproducible:${{ needs.prepare.outputs.tag_name }} |
| 83 | + docker cp katana-extract:/katana ./katana-reproducible |
| 84 | + docker rm katana-extract |
| 85 | +
|
| 86 | + - name: Calculate binary hash |
| 87 | + id: hash |
| 88 | + run: | |
| 89 | + SHA384=$(sha384sum ./katana-reproducible | cut -d ' ' -f 1) |
| 90 | + echo "sha384=${SHA384}" >> $GITHUB_OUTPUT |
| 91 | + echo "Binary SHA-384: ${SHA384}" |
| 92 | +
|
| 93 | + - name: Archive reproducible binary |
| 94 | + env: |
| 95 | + VERSION_NAME: ${{ needs.prepare.outputs.tag_name }} |
| 96 | + run: | |
| 97 | + tar -czvf "katana_${VERSION_NAME}_linux_amd64_tee.tar.gz" katana-reproducible |
| 98 | + sha384sum katana-reproducible > "katana_${VERSION_NAME}_linux_amd64_tee.sha384" |
| 99 | +
|
| 100 | + - name: Generate build provenance attestation |
| 101 | + id: attest |
| 102 | + uses: actions/attest-build-provenance@v2 |
| 103 | + with: |
| 104 | + subject-path: ./katana-reproducible |
| 105 | + |
| 106 | + - name: Upload release artifacts |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: tee-release-artifacts |
| 110 | + path: | |
| 111 | + katana_${{ needs.prepare.outputs.tag_name }}_linux_amd64_tee.tar.gz |
| 112 | + katana_${{ needs.prepare.outputs.tag_name }}_linux_amd64_tee.sha384 |
| 113 | +
|
| 114 | + - name: Summary |
| 115 | + run: | |
| 116 | + echo "## TEE Reproducible Build Complete" >> $GITHUB_STEP_SUMMARY |
| 117 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 118 | + echo "**Version:** ${{ needs.prepare.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY |
| 119 | + echo "**SHA-384:** \`${{ steps.hash.outputs.sha384 }}\`" >> $GITHUB_STEP_SUMMARY |
| 120 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 121 | + echo "### Verify Attestation" >> $GITHUB_STEP_SUMMARY |
| 122 | + echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY |
| 123 | + echo "gh attestation verify ./katana-reproducible --repo ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY |
| 124 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
0 commit comments