build #278
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
schedule: | |
- cron: "0 20 * * 0" | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
env: | |
CARGO_INCREMENTAL: "0" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'merge_group' }} | |
jobs: | |
draft-release: | |
name: Create a release draft | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-22.04 | |
outputs: | |
release-id: ${{ steps.create-release.outputs.id }} | |
upload-url: ${{ steps.create-release.outputs.upload_url }} | |
html-url: ${{ steps.create-release.outputs.html_url }} | |
timeout-minutes: 50 | |
permissions: | |
contents: write | |
steps: | |
- name: Create release | |
id: create-release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: false | |
draft: true | |
generateReleaseNotes: true | |
plan: | |
name: Plan the execution | |
runs-on: ubuntu-22.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Compute matrix | |
uses: ./.github/actions/plan | |
id: set-matrix | |
with: | |
plan-name: build | |
- name: Dump matrix context | |
env: | |
MATRIX_CONTEXT: ${{ toJson(steps.set-matrix.outputs.matrix) }} | |
run: echo "$MATRIX_CONTEXT" | |
build: | |
needs: | |
- plan | |
- draft-release | |
if: ${{ always() && needs.plan.result == 'success' && (!startsWith(github.ref, 'refs/tags/') || needs.draft-release.result == 'success') }} | |
strategy: | |
matrix: ${{ fromJson(needs.plan.outputs.matrix) }} | |
fail-fast: false | |
name: ${{ matrix.plan.platform.name }} / ${{ matrix.plan.mode.name }} | |
runs-on: ${{ matrix.plan.platform.os }} | |
env: ${{ matrix.plan.platform.env }} | |
timeout-minutes: 120 | |
permissions: | |
contents: write | |
steps: | |
- name: Job config | |
run: printf "%s\n" "$MATRIX_CONTEXT" | |
env: | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
timeout-minutes: 5 | |
- uses: ./.github/actions/common-setup | |
with: | |
platformCacheKey: ${{ matrix.plan.platform.cacheKey }} | |
modeCacheKey: ${{ matrix.plan.mode.cargoCacheKey }} | |
isOnSelfHostedRunner: ${{ matrix.plan.platform.isOnSelfHostedRunner }} | |
buildEnvScript: ${{ matrix.plan.platform.buildEnvScript }} | |
timeout-minutes: 10 | |
- name: Run cargo ${{ matrix.plan.mode.cargoCommand }} | |
run: cargo ${{ matrix.plan.mode.cargoCommand }} ${{ matrix.plan.mode.cargoArgs }} | |
- name: Set the upload params | |
id: set-upload-params | |
env: | |
PLATFORM_ARTIFACT_MARKER: ${{ matrix.plan.platform.artifactMarker }} | |
run: | | |
EXECUTABLE_PATH="target/release/humanode-peer" | |
ARTIFACT_NAME="humanode-peer-$(rustc -vV | sed -n 's|host: ||p')" | |
if [[ "$PLATFORM_ARTIFACT_MARKER" != "" ]]; then | |
ARTIFACT_NAME="${ARTIFACT_NAME}-${PLATFORM_ARTIFACT_MARKER}" | |
fi | |
if [[ "${PATHEXT:-""}" != "" ]]; then | |
EXECUTABLE_PATH="${EXECUTABLE_PATH}.exe" | |
fi | |
printf 'executable-path=%s\n' "$EXECUTABLE_PATH" >> "$GITHUB_OUTPUT" | |
printf 'artifact-name=%s\n' "$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" | |
printf 'Packaged `%s` into `%s`.\n' \ | |
"$EXECUTABLE_PATH" \ | |
"$ARTIFACT_NAME" \ | |
>> "$GITHUB_STEP_SUMMARY" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.set-upload-params.outputs.artifact-name }} | |
path: ${{ steps.set-upload-params.outputs.executable-path }} | |
if-no-files-found: error | |
retention-days: 5 | |
- name: Archive the binary for release | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
EXECUTABLE_NAME: ${{ steps.set-upload-params.outputs.executable-path }} | |
run: utils/make-release-archive "$EXECUTABLE_NAME" archive.tar.gz | |
- name: Upload release archive | |
uses: shogo82148/actions-upload-release-asset@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
upload_url: ${{ needs.draft-release.outputs.upload-url }} | |
asset_name: ${{ steps.set-upload-params.outputs.artifact-name }}.tar.gz | |
asset_path: archive.tar.gz | |
publish-release: | |
needs: | |
- draft-release | |
- build | |
name: Publish release | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 50 | |
permissions: | |
contents: write | |
steps: | |
- name: Publish release | |
uses: actions/github-script@v7 | |
env: | |
RELEASE_ID: ${{ needs.draft-release.outputs.release-id }} | |
with: | |
script: | | |
github.rest.repos.updateRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: process.env.RELEASE_ID, | |
draft: false | |
}); |