|
| 1 | +name: Release TDX Quote Provider |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "tdx-quote-provider/v*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + draft-release: |
| 10 | + default: false |
| 11 | + description: "Draft Release" |
| 12 | + required: false |
| 13 | + type: boolean |
| 14 | + features: |
| 15 | + default: "" |
| 16 | + description: "Binary Compilation Features" |
| 17 | + options: |
| 18 | + - "" |
| 19 | + required: false |
| 20 | + type: choice |
| 21 | + |
| 22 | +jobs: |
| 23 | + extract-version: |
| 24 | + name: Extract version |
| 25 | + runs-on: warp-ubuntu-latest-x64-16x |
| 26 | + outputs: |
| 27 | + VERSION: ${{ steps.extract_version.outputs.VERSION }} |
| 28 | + steps: |
| 29 | + - name: Extract version |
| 30 | + id: extract_version |
| 31 | + run: | |
| 32 | + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then |
| 33 | + VERSION="${GITHUB_REF#refs/tags/}" |
| 34 | + else |
| 35 | + VERSION="$(echo ${GITHUB_SHA} | cut -c1-7)" |
| 36 | + fi |
| 37 | + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT |
| 38 | +
|
| 39 | + echo "| | |" >> $GITHUB_STEP_SUMMARY |
| 40 | + echo "| ------------------- | ---------------------- |" >> $GITHUB_STEP_SUMMARY |
| 41 | + echo "| \`GITHUB_REF_TYPE\` | \`${GITHUB_REF_TYPE}\` |" >> $GITHUB_STEP_SUMMARY |
| 42 | + echo "| \`GITHUB_REF_NAME\` | \`${GITHUB_REF_NAME}\` |" >> $GITHUB_STEP_SUMMARY |
| 43 | + echo "| \`GITHUB_REF\` | \`${GITHUB_REF}\` |" >> $GITHUB_STEP_SUMMARY |
| 44 | + echo "| \`GITHUB_SHA\` | \`${GITHUB_SHA}\` |" >> $GITHUB_STEP_SUMMARY |
| 45 | + echo "| \`VERSION\` | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY |
| 46 | + echo "| \`FEATURES\` | \`${{ github.event.inputs.features || 'none' }}\` |" >> $GITHUB_STEP_SUMMARY |
| 47 | +
|
| 48 | + build-binary: |
| 49 | + name: Build binary |
| 50 | + needs: extract-version |
| 51 | + runs-on: ${{ matrix.configs.runner }} |
| 52 | + container: |
| 53 | + image: ubuntu:22.04 |
| 54 | + permissions: |
| 55 | + contents: write |
| 56 | + packages: write |
| 57 | + strategy: |
| 58 | + matrix: |
| 59 | + configs: |
| 60 | + - target: x86_64-unknown-linux-gnu |
| 61 | + runner: warp-ubuntu-latest-x64-32x |
| 62 | + - target: aarch64-unknown-linux-gnu |
| 63 | + runner: warp-ubuntu-latest-arm64-32x |
| 64 | + # Paused until docker is pre-installed https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md |
| 65 | + # - target: aarch64-apple-darwin |
| 66 | + # runner: warp-macos-14-arm64-6x |
| 67 | + features: |
| 68 | + - ${{ github.event.inputs.features || '' }} |
| 69 | + |
| 70 | + steps: |
| 71 | + - name: Install dependencies |
| 72 | + run: | |
| 73 | + apt-get update |
| 74 | + apt-get install -y \ |
| 75 | + build-essential \ |
| 76 | + curl \ |
| 77 | + git \ |
| 78 | + libclang-dev \ |
| 79 | + libssl-dev \ |
| 80 | + libtss2-dev \ |
| 81 | + pkg-config \ |
| 82 | + protobuf-compiler |
| 83 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 84 | +
|
| 85 | + - uses: actions/checkout@v4 # must install git before checkout and set safe.directory after checkout because of container |
| 86 | + |
| 87 | + - name: Build tdx-quote-provider binary |
| 88 | + run: | |
| 89 | + git config --global --add safe.directory "$(pwd)" |
| 90 | + . $HOME/.cargo/env |
| 91 | + cargo build --release --features=${{ matrix.features }} --target ${{ matrix.configs.target }} --package tdx-quote-provider |
| 92 | + mkdir -p artifacts |
| 93 | + mv target/${{ matrix.configs.target }}/release/tdx-quote-provider artifacts/tdx-quote-provider-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.configs.target }}${{ matrix.features && '-' }}${{ matrix.features }} |
| 94 | +
|
| 95 | + - name: Upload artifacts |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: tdx-quote-provider-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.configs.target }}${{ matrix.features && '-' }}${{ matrix.features }} |
| 99 | + path: artifacts |
| 100 | + |
| 101 | + draft-release: |
| 102 | + name: Draft release |
| 103 | + if: ${{ github.event.inputs.draft-release == 'true' || github.event_name == 'push'}} # when manually triggered or version tagged |
| 104 | + needs: [extract-version, build-binary] |
| 105 | + runs-on: warp-ubuntu-latest-x64-16x |
| 106 | + env: |
| 107 | + VERSION: op-${{ needs.extract-version.outputs.VERSION }} |
| 108 | + permissions: |
| 109 | + contents: write |
| 110 | + steps: |
| 111 | + - name: Checkout |
| 112 | + uses: actions/checkout@v4 |
| 113 | + |
| 114 | + - name: Download artifacts |
| 115 | + uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + merge-multiple: true |
| 118 | + path: artifacts |
| 119 | + |
| 120 | + - name: Record artifacts checksums |
| 121 | + working-directory: artifacts |
| 122 | + run: | |
| 123 | + find ./ || true |
| 124 | + for file in *; do sha256sum "$file" >> sha256sums.txt; done; |
| 125 | + cat sha256sums.txt |
| 126 | +
|
| 127 | + - name: Create release draft |
| 128 | + |
| 129 | + id: create-release-draft |
| 130 | + with: |
| 131 | + draft: true |
| 132 | + files: artifacts/* |
| 133 | + generate_release_notes: true |
| 134 | + name: ${{ env.VERSION }} |
| 135 | + tag_name: ${{ env.VERSION }} |
| 136 | + |
| 137 | + - name: Write Github Step Summary |
| 138 | + run: | |
| 139 | + echo "---" |
| 140 | + echo "### Release Draft: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY |
| 141 | + echo "${{ steps.create-release-draft.outputs.url }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments