| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
name: Release |
| 17 |
permissions: |
| 18 |
"contents": "write" |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
on: |
| 42 |
pull_request: |
| 43 |
push: |
| 44 |
tags: |
| 45 |
- '**[0-9]+.[0-9]+.[0-9]+*' |
| 46 |
|
| 47 |
jobs: |
| 48 |
|
| 49 |
plan: |
| 50 |
runs-on: "ubuntu-22.04" |
| 51 |
outputs: |
| 52 |
val: ${{ steps.plan.outputs.manifest }} |
| 53 |
tag: ${{ !github.event.pull_request && github.ref_name || '' }} |
| 54 |
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} |
| 55 |
publishing: ${{ !github.event.pull_request }} |
| 56 |
env: |
| 57 |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 |
steps: |
| 59 |
- uses: actions/checkout@v4 |
| 60 |
with: |
| 61 |
persist-credentials: false |
| 62 |
submodules: recursive |
| 63 |
- name: Install dist |
| 64 |
|
| 65 |
|
| 66 |
shell: bash |
| 67 |
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.3/cargo-dist-installer.sh | sh" |
| 68 |
- name: Cache dist |
| 69 |
uses: actions/upload-artifact@v4 |
| 70 |
with: |
| 71 |
name: cargo-dist-cache |
| 72 |
path: ~/.cargo/bin/dist |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
- id: plan |
| 79 |
run: | |
| 80 |
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json |
| 81 |
echo "dist ran successfully" |
| 82 |
cat plan-dist-manifest.json |
| 83 |
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" |
| 84 |
- name: "Upload dist-manifest.json" |
| 85 |
uses: actions/upload-artifact@v4 |
| 86 |
with: |
| 87 |
name: artifacts-plan-dist-manifest |
| 88 |
path: plan-dist-manifest.json |
| 89 |
|
| 90 |
|
| 91 |
build-local-artifacts: |
| 92 |
name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) |
| 93 |
|
| 94 |
needs: |
| 95 |
- plan |
| 96 |
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} |
| 97 |
strategy: |
| 98 |
fail-fast: false |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} |
| 110 |
runs-on: ${{ matrix.runner }} |
| 111 |
container: ${{ matrix.container && matrix.container.image || null }} |
| 112 |
env: |
| 113 |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 114 |
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json |
| 115 |
steps: |
| 116 |
- name: enable windows longpaths |
| 117 |
run: | |
| 118 |
git config --global core.longpaths true |
| 119 |
- uses: actions/checkout@v4 |
| 120 |
with: |
| 121 |
persist-credentials: false |
| 122 |
submodules: recursive |
| 123 |
- name: Install Rust non-interactively if not already installed |
| 124 |
if: ${{ matrix.container }} |
| 125 |
run: | |
| 126 |
if ! command -v cargo > /dev/null 2>&1; then |
| 127 |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 128 |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 129 |
fi |
| 130 |
- name: Install dist |
| 131 |
run: ${{ matrix.install_dist.run }} |
| 132 |
|
| 133 |
- name: Fetch local artifacts |
| 134 |
uses: actions/download-artifact@v4 |
| 135 |
with: |
| 136 |
pattern: artifacts-* |
| 137 |
path: target/distrib/ |
| 138 |
merge-multiple: true |
| 139 |
- name: Install dependencies |
| 140 |
run: | |
| 141 |
${{ matrix.packages_install }} |
| 142 |
- name: Build artifacts |
| 143 |
run: | |
| 144 |
# Actually do builds and make zips and whatnot |
| 145 |
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json |
| 146 |
echo "dist ran successfully" |
| 147 |
- id: cargo-dist |
| 148 |
name: Post-build |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
shell: bash |
| 153 |
run: | |
| 154 |
# Parse out what we just built and upload it to scratch storage |
| 155 |
echo "paths<<EOF" >> "$GITHUB_OUTPUT" |
| 156 |
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT" |
| 157 |
echo "EOF" >> "$GITHUB_OUTPUT" |
| 158 |
|
| 159 |
cp dist-manifest.json "$BUILD_MANIFEST_NAME" |
| 160 |
- name: "Upload artifacts" |
| 161 |
uses: actions/upload-artifact@v4 |
| 162 |
with: |
| 163 |
name: artifacts-build-local-${{ join(matrix.targets, '_') }} |
| 164 |
path: | |
| 165 |
${{ steps.cargo-dist.outputs.paths }} |
| 166 |
${{ env.BUILD_MANIFEST_NAME }} |
| 167 |
|
| 168 |
|
| 169 |
build-global-artifacts: |
| 170 |
needs: |
| 171 |
- plan |
| 172 |
- build-local-artifacts |
| 173 |
runs-on: "ubuntu-22.04" |
| 174 |
env: |
| 175 |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 176 |
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json |
| 177 |
steps: |
| 178 |
- uses: actions/checkout@v4 |
| 179 |
with: |
| 180 |
persist-credentials: false |
| 181 |
submodules: recursive |
| 182 |
- name: Install cached dist |
| 183 |
uses: actions/download-artifact@v4 |
| 184 |
with: |
| 185 |
name: cargo-dist-cache |
| 186 |
path: ~/.cargo/bin/ |
| 187 |
- run: chmod +x ~/.cargo/bin/dist |
| 188 |
|
| 189 |
- name: Fetch local artifacts |
| 190 |
uses: actions/download-artifact@v4 |
| 191 |
with: |
| 192 |
pattern: artifacts-* |
| 193 |
path: target/distrib/ |
| 194 |
merge-multiple: true |
| 195 |
- id: cargo-dist |
| 196 |
shell: bash |
| 197 |
run: | |
| 198 |
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json |
| 199 |
echo "dist ran successfully" |
| 200 |
|
| 201 |
# Parse out what we just built and upload it to scratch storage |
| 202 |
echo "paths<<EOF" >> "$GITHUB_OUTPUT" |
| 203 |
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" |
| 204 |
echo "EOF" >> "$GITHUB_OUTPUT" |
| 205 |
|
| 206 |
cp dist-manifest.json "$BUILD_MANIFEST_NAME" |
| 207 |
- name: "Upload artifacts" |
| 208 |
uses: actions/upload-artifact@v4 |
| 209 |
with: |
| 210 |
name: artifacts-build-global |
| 211 |
path: | |
| 212 |
${{ steps.cargo-dist.outputs.paths }} |
| 213 |
${{ env.BUILD_MANIFEST_NAME }} |
| 214 |
|
| 215 |
host: |
| 216 |
needs: |
| 217 |
- plan |
| 218 |
- build-local-artifacts |
| 219 |
- build-global-artifacts |
| 220 |
|
| 221 |
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} |
| 222 |
env: |
| 223 |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 224 |
runs-on: "ubuntu-22.04" |
| 225 |
outputs: |
| 226 |
val: ${{ steps.host.outputs.manifest }} |
| 227 |
steps: |
| 228 |
- uses: actions/checkout@v4 |
| 229 |
with: |
| 230 |
persist-credentials: false |
| 231 |
submodules: recursive |
| 232 |
- name: Install cached dist |
| 233 |
uses: actions/download-artifact@v4 |
| 234 |
with: |
| 235 |
name: cargo-dist-cache |
| 236 |
path: ~/.cargo/bin/ |
| 237 |
- run: chmod +x ~/.cargo/bin/dist |
| 238 |
|
| 239 |
- name: Fetch artifacts |
| 240 |
uses: actions/download-artifact@v4 |
| 241 |
with: |
| 242 |
pattern: artifacts-* |
| 243 |
path: target/distrib/ |
| 244 |
merge-multiple: true |
| 245 |
- id: host |
| 246 |
shell: bash |
| 247 |
run: | |
| 248 |
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json |
| 249 |
echo "artifacts uploaded and released successfully" |
| 250 |
cat dist-manifest.json |
| 251 |
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" |
| 252 |
- name: "Upload dist-manifest.json" |
| 253 |
uses: actions/upload-artifact@v4 |
| 254 |
with: |
| 255 |
|
| 256 |
name: artifacts-dist-manifest |
| 257 |
path: dist-manifest.json |
| 258 |
|
| 259 |
- name: "Download GitHub Artifacts" |
| 260 |
uses: actions/download-artifact@v4 |
| 261 |
with: |
| 262 |
pattern: artifacts-* |
| 263 |
path: artifacts |
| 264 |
merge-multiple: true |
| 265 |
- name: Cleanup |
| 266 |
run: | |
| 267 |
# Remove the granular manifests |
| 268 |
rm -f artifacts/*-dist-manifest.json |
| 269 |
- name: Create GitHub Release |
| 270 |
env: |
| 271 |
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}" |
| 272 |
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}" |
| 273 |
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}" |
| 274 |
RELEASE_COMMIT: "${{ github.sha }}" |
| 275 |
run: | |
| 276 |
# Write and read notes from a file to avoid quoting breaking things |
| 277 |
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt |
| 278 |
|
| 279 |
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/* |
| 280 |
|
| 281 |
announce: |
| 282 |
needs: |
| 283 |
- plan |
| 284 |
- host |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
if: ${{ always() && needs.host.result == 'success' }} |
| 289 |
runs-on: "ubuntu-22.04" |
| 290 |
env: |
| 291 |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 292 |
steps: |
| 293 |
- uses: actions/checkout@v4 |
| 294 |
with: |
| 295 |
persist-credentials: false |
| 296 |
submodules: recursive |