|
| 1 | +name: Orion Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "orion-v*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: "Override version tag (e.g. v0.1.1). Required for manual runs." |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: Build orion (linux-amd64) |
| 24 | + runs-on: ubuntu-latest |
| 25 | + timeout-minutes: 30 |
| 26 | + outputs: |
| 27 | + version: ${{ steps.meta.outputs.version }} |
| 28 | + bundle_name: ${{ steps.meta.outputs.bundle_name }} |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Resolve version |
| 34 | + id: meta |
| 35 | + run: | |
| 36 | + set -euo pipefail |
| 37 | + if [[ "${GITHUB_REF}" == refs/tags/orion-* ]]; then |
| 38 | + VERSION="${GITHUB_REF#refs/tags/orion-}" |
| 39 | + else |
| 40 | + VERSION="${{ inputs.version }}" |
| 41 | + fi |
| 42 | + if [[ -z "$VERSION" ]]; then |
| 43 | + echo "::error::Could not resolve version. Push an orion-vX.Y.Z tag or supply 'version'." |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + SHORT_SHA=$(git rev-parse --short=8 HEAD) |
| 47 | + BUNDLE_NAME="orion-${VERSION}-linux-amd64" |
| 48 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 49 | + echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" |
| 50 | + echo "bundle_name=$BUNDLE_NAME" >> "$GITHUB_OUTPUT" |
| 51 | +
|
| 52 | + - name: Install system build deps |
| 53 | + run: | |
| 54 | + sudo apt-get update -qq |
| 55 | + sudo apt-get install -y --no-install-recommends \ |
| 56 | + build-essential \ |
| 57 | + clang \ |
| 58 | + fuse3 \ |
| 59 | + libfuse3-dev \ |
| 60 | + libssl-dev \ |
| 61 | + pkg-config \ |
| 62 | + protobuf-compiler |
| 63 | +
|
| 64 | + - name: Install Rust stable |
| 65 | + uses: dtolnay/rust-toolchain@stable |
| 66 | + with: |
| 67 | + targets: x86_64-unknown-linux-gnu |
| 68 | + |
| 69 | + - name: Cargo cache |
| 70 | + uses: Swatinem/rust-cache@v2 |
| 71 | + with: |
| 72 | + shared-key: orion-release-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} |
| 73 | + cache-on-failure: true |
| 74 | + |
| 75 | + - name: Build orion (release) |
| 76 | + run: cargo build --release -p orion --bin orion --target x86_64-unknown-linux-gnu |
| 77 | + |
| 78 | + - name: Stage bundle |
| 79 | + env: |
| 80 | + BUNDLE_NAME: ${{ steps.meta.outputs.bundle_name }} |
| 81 | + VERSION: ${{ steps.meta.outputs.version }} |
| 82 | + SHORT_SHA: ${{ steps.meta.outputs.short_sha }} |
| 83 | + run: | |
| 84 | + set -euo pipefail |
| 85 | + BUILT_AT=$(date -u +%FT%TZ) |
| 86 | + BUNDLE_ROOT="dist/${BUNDLE_NAME}" |
| 87 | + mkdir -p "${BUNDLE_ROOT}/runner-config" "${BUNDLE_ROOT}/systemd" |
| 88 | +
|
| 89 | + install -m 0755 \ |
| 90 | + target/x86_64-unknown-linux-gnu/release/orion \ |
| 91 | + "${BUNDLE_ROOT}/orion" |
| 92 | + install -m 0644 \ |
| 93 | + orion/runner-config/.env.prod \ |
| 94 | + "${BUNDLE_ROOT}/runner-config/.env.prod" |
| 95 | + install -m 0644 \ |
| 96 | + orion/runner-config/scorpio.toml \ |
| 97 | + "${BUNDLE_ROOT}/runner-config/scorpio.toml" |
| 98 | + install -m 0755 \ |
| 99 | + orion/runner-config/run.sh \ |
| 100 | + "${BUNDLE_ROOT}/runner-config/run.sh" |
| 101 | + install -m 0755 \ |
| 102 | + orion/runner-config/preflight.sh \ |
| 103 | + "${BUNDLE_ROOT}/runner-config/preflight.sh" |
| 104 | + install -m 0755 \ |
| 105 | + orion/runner-config/cleanup.sh \ |
| 106 | + "${BUNDLE_ROOT}/runner-config/cleanup.sh" |
| 107 | + install -m 0644 \ |
| 108 | + orion/systemd/orion-runner.service \ |
| 109 | + "${BUNDLE_ROOT}/systemd/orion-runner.service" |
| 110 | + install -m 0644 \ |
| 111 | + orion/systemd/orion-runner.env.example \ |
| 112 | + "${BUNDLE_ROOT}/systemd/orion-runner.env.example" |
| 113 | +
|
| 114 | + cat > "${BUNDLE_ROOT}/VERSION" <<EOF |
| 115 | + version=${VERSION} |
| 116 | + commit=${GITHUB_SHA} |
| 117 | + commit_short=${SHORT_SHA} |
| 118 | + built_at=${BUILT_AT} |
| 119 | + target=x86_64-unknown-linux-gnu |
| 120 | + EOF |
| 121 | +
|
| 122 | + tar -C dist -czf "dist/${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}" |
| 123 | + (cd dist && sha256sum "${BUNDLE_NAME}.tar.gz" \ |
| 124 | + > "${BUNDLE_NAME}.tar.gz.sha256") |
| 125 | +
|
| 126 | + ls -lh dist/ |
| 127 | +
|
| 128 | + - name: Upload build artifacts |
| 129 | + uses: actions/upload-artifact@v4 |
| 130 | + with: |
| 131 | + name: ${{ steps.meta.outputs.bundle_name }} |
| 132 | + include-hidden-files: true |
| 133 | + path: | |
| 134 | + dist/${{ steps.meta.outputs.bundle_name }}.tar.gz |
| 135 | + dist/${{ steps.meta.outputs.bundle_name }}.tar.gz.sha256 |
| 136 | + if-no-files-found: error |
| 137 | + retention-days: 7 |
| 138 | + |
| 139 | + release: |
| 140 | + name: Publish GitHub Release |
| 141 | + needs: build |
| 142 | + if: startsWith(github.ref, 'refs/tags/orion-') |
| 143 | + runs-on: ubuntu-latest |
| 144 | + permissions: |
| 145 | + contents: write |
| 146 | + steps: |
| 147 | + - name: Checkout |
| 148 | + uses: actions/checkout@v4 |
| 149 | + |
| 150 | + - name: Download build artifacts |
| 151 | + uses: actions/download-artifact@v4 |
| 152 | + with: |
| 153 | + name: ${{ needs.build.outputs.bundle_name }} |
| 154 | + path: dist |
| 155 | + |
| 156 | + - name: Render release notes |
| 157 | + id: notes |
| 158 | + env: |
| 159 | + VERSION: ${{ needs.build.outputs.version }} |
| 160 | + BUNDLE_NAME: ${{ needs.build.outputs.bundle_name }} |
| 161 | + run: | |
| 162 | + set -euo pipefail |
| 163 | + SHA256=$(awk '{print $1}' "dist/${BUNDLE_NAME}.tar.gz.sha256") |
| 164 | + { |
| 165 | + echo "## orion ${VERSION}" |
| 166 | + echo |
| 167 | + echo "Linux amd64 runner bundle for the Orion Buck2 worker." |
| 168 | + echo "The bundle contains the release binary, runner scripts," |
| 169 | + echo "Scorpio config, and the systemd unit used by orion-scheduler." |
| 170 | + echo |
| 171 | + echo "### Download" |
| 172 | + echo |
| 173 | + echo '```bash' |
| 174 | + echo "curl -LO https://github.com/${{ github.repository }}/releases/download/orion-${VERSION}/${BUNDLE_NAME}.tar.gz" |
| 175 | + echo "curl -LO https://github.com/${{ github.repository }}/releases/download/orion-${VERSION}/${BUNDLE_NAME}.tar.gz.sha256" |
| 176 | + echo "sha256sum -c ${BUNDLE_NAME}.tar.gz.sha256" |
| 177 | + echo "tar -xzf ${BUNDLE_NAME}.tar.gz" |
| 178 | + echo '```' |
| 179 | + echo |
| 180 | + echo "Bundle layout:" |
| 181 | + echo |
| 182 | + echo '```text' |
| 183 | + echo "${BUNDLE_NAME}/" |
| 184 | + echo "├── orion" |
| 185 | + echo "├── runner-config/" |
| 186 | + echo "├── systemd/" |
| 187 | + echo "└── VERSION" |
| 188 | + echo '```' |
| 189 | + echo |
| 190 | + echo "### Checksum" |
| 191 | + echo |
| 192 | + echo '```' |
| 193 | + echo "${SHA256} ${BUNDLE_NAME}.tar.gz" |
| 194 | + echo '```' |
| 195 | + } > release-notes.md |
| 196 | + echo "path=release-notes.md" >> "$GITHUB_OUTPUT" |
| 197 | +
|
| 198 | + - name: Create GitHub Release |
| 199 | + uses: softprops/action-gh-release@v2 |
| 200 | + with: |
| 201 | + tag_name: ${{ github.ref_name }} |
| 202 | + name: orion ${{ needs.build.outputs.version }} |
| 203 | + body_path: ${{ steps.notes.outputs.path }} |
| 204 | + draft: false |
| 205 | + prerelease: ${{ contains(needs.build.outputs.version, '-') }} |
| 206 | + files: | |
| 207 | + dist/${{ needs.build.outputs.bundle_name }}.tar.gz |
| 208 | + dist/${{ needs.build.outputs.bundle_name }}.tar.gz.sha256 |
0 commit comments