Skip to content

build

build #126

Workflow file for this run

name: build
on:
push:
tags:
- "v*.*.*"
schedule:
- cron: "0 20 * * 0"
workflow_dispatch:
defaults:
run:
shell: bash
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
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 }}
buildEnvScript: ${{ matrix.plan.platform.buildEnvScript }}
extraRustTargetsToInstall: ${{ join(matrix.plan.platform.extraTargetsToInstall, ' ') }}
timeout-minutes: 10
- name: Run cargo ${{ matrix.plan.mode.cargoCommand }}
uses: actions-rs/cargo@v1
with:
command: ${{ matrix.plan.mode.cargoCommand }}
args: >
${{ matrix.plan.mode.cargoArgs }}
${{ matrix.plan.platform.buildTarget && format('--target {0}', matrix.plan.platform.buildTarget) || '' }}
- name: Archive the binaries for release
env:
TARGET_DIR: ${{ matrix.plan.platform.buildTargetDir && format('{0}/release', matrix.plan.platform.buildTargetDir) || 'release' }}
run: |
./utils/build/package \
target/build-package \
"target/$TARGET_DIR" \
""
- 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_path: target/build-package/archives/*.tar.gz
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{runner.os}}-${{runner.arch}}
path: target/build-package/archives/*.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
});