Skip to content

build

build #171

Workflow file for this run

name: build
on:
push:
tags:
- "v*.*.*"
schedule:
- cron: "0 20 * * 0"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'merge_group' }}
defaults:
run:
shell: bash
jobs:
draft-release:
name: Create a release draft
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-24.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-24.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.mode.platformIndependent == true && matrix.plan.mode.name || format('{0} / {1}', 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 }}
run: cargo ${{ matrix.plan.mode.cargoCommand }} ${{ matrix.plan.mode.cargoArgs }} ${{ matrix.plan.mode.passZigbuildTarget && 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: |
./build-utils/package \
target/build-package \
"target/$TARGET_DIR" \
""
- name: Compute artifact name
env:
ARTIFACT_NAME: |
build-${{ runner.os }}${{ matrix.plan.platform.artifactMarker && format('-{0}', matrix.plan.platform.artifactMarker) || '' }}
run: |
printf "ARTIFACT_NAME=%s\n" "$ARTIFACT_NAME" >>"$GITHUB_ENV"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: target/build-package/archives/*.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_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-24.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
});