Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
seanaye/ci/attach desktop artifact to release (#4331)
Sean Aye469735c506fb
diff --git a/.github/workflows/build_appimage_on_tag.yml b/.github/workflows/build_appimage_on_tag.ymlindex 41dd9cd34f..a2d2ca78ef 100644--- a/.github/workflows/build_appimage_on_tag.yml+++ b/.github/workflows/build_appimage_on_tag.yml@@ -118,7 +118,7 @@ jobs:ficp -v "${appimages[@]}" artifacts/chmod 0755 artifacts/*.AppImage- (cd artifacts && sha256sum -- *.AppImage > SHA256SUMS)+ (cd artifacts && sha256sum -- *.AppImage > macro-appimage-SHA256SUMS)shell: bash- name: Upload macro-appimage-${{ steps.metadata.outputs.safe_tag }} artifactuses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02@@ -130,3 +130,37 @@ jobs:- name: Teardown Nixif: always()uses: './.github/actions/teardown-nix'+ publish-appimage:+ needs:+ - build-appimage+ name: Upload Release Artifacts+ runs-on: ubuntu-latest+ permissions:+ contents: write+ steps:+ - id: metadata+ name: Derive artifact metadata+ run: |+ set -euo pipefail+ tag="${RAW_REF#refs/tags/}"+ if [ -z "$tag" ]; then+ tag="${GITHUB_REF_NAME:-untagged}"+ fi+ safe_tag=$(printf '%s' "$tag" | sed 's#[/\\:*?"<>|]#-#g' | tr -d '\r\n')+ echo "tag=$tag" >> "$GITHUB_OUTPUT"+ echo "safe_tag=$safe_tag" >> "$GITHUB_OUTPUT"+ shell: bash+ env:+ RAW_REF: ${{ inputs.ref }}+ - name: Download Build Artifacts+ uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0+ with:+ path: release-artifacts+ merge-multiple: 'true'+ - name: Upload Release Artifacts+ if: startsWith(steps.metadata.outputs.tag, 'v')+ uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65+ with:+ tag_name: ${{ steps.metadata.outputs.tag }}+ files: release-artifacts/*+ fail_on_unmatched_files: 'true'diff --git a/.github/workflows/build_desktop_on_tag.yml b/.github/workflows/build_desktop_on_tag.ymlindex fb7de0c22d..2086dcaa67 100644--- a/.github/workflows/build_desktop_on_tag.yml+++ b/.github/workflows/build_desktop_on_tag.yml@@ -5,16 +5,11 @@ name: Build Desktop on Tagpush:tags:- v[0-9]*- create: {}workflow_dispatch:inputs:ref:description: Release tag to build (v* or refs/tags/v*). Defaults to the selected protected ref or release tag.- required: falsetype: string-concurrency:- group: desktop-${{ inputs.ref || (github.event.ref_type == 'tag' && github.event.ref || github.ref_name) }}- cancel-in-progress: truejobs:resolve-ref:if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'create' && github.event.ref_type == 'tag')@@ -78,14 +73,334 @@ jobs:build-appimage:needs:- resolve-ref- uses: './.github/workflows/build_appimage_on_tag.yml'- with:- ref: ${{ needs.resolve-ref.outputs.ref }}- secrets: inherit+ name: Build AppImage+ runs-on: namespace-profile-linux-rust-ci+ steps:+ - name: Checkout Repo+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10+ with:+ ref: ${{ needs.resolve-ref.outputs.ref }}+ persist-credentials: 'false'+ - name: Mount /nix cache volume+ uses: namespacelabs/nscloud-cache-action@15799a6b54e5765f85b2aac25b3f0df43ed571c0+ with:+ path: /nix+ continue-on-error: true+ - name: Setup Nix+ uses: './.github/actions/setup-nix'+ - name: Configure Cachix fallback+ uses: './.github/actions/setup-cachix'+ with:+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}+ - id: metadata+ name: Derive artifact metadata+ run: |+ set -euo pipefail+ tag="${RAW_REF#refs/tags/}"+ if [ -z "$tag" ]; then+ tag="${GITHUB_REF_NAME:-untagged}"+ fi+ safe_tag=$(printf '%s' "$tag" | sed 's#[/\\:*?"<>|]#-#g' | tr -d '\r\n')+ echo "tag=$tag" >> "$GITHUB_OUTPUT"+ echo "safe_tag=$safe_tag" >> "$GITHUB_OUTPUT"+ shell: bash+ env:+ RAW_REF: ${{ needs.resolve-ref.outputs.ref }}+ - name: Build AppImage with Nix+ run: |+ set -euo pipefail+ cachix_pid=+ if command -v cachix >/dev/null 2>&1 && [ -n "${CACHIX_CACHE_NAME:-}" ]; then+ cachix watch-store "$CACHIX_CACHE_NAME" >/tmp/cachix-watch-store.log 2>&1 &+ cachix_pid=$!+ trap 'if [ -n "${cachix_pid:-}" ]; then kill "$cachix_pid" 2>/dev/null || true; wait "$cachix_pid" 2>/dev/null || true; fi' EXIT+ fi+ restart_nix_daemon() {+ echo "::warning::Restarting nix-daemon before retrying AppImage build."+ sudo systemctl restart nix-daemon.service 2>/dev/null || true+ sudo pkill -x nix-daemon 2>/dev/null || true+ sudo rm -f /nix/var/nix/daemon-socket/socket+ sudo mkdir -p /nix/var/nix/daemon-socket+ sudo sh -c 'nohup /nix/var/nix/profiles/default/bin/nix-daemon >/tmp/nix-daemon-retry.log 2>&1 &'+ for _ in $(seq 1 30); do+ if sudo test -S /nix/var/nix/daemon-socket/socket; then+ return 0+ fi+ sleep 1+ done+ echo "nix-daemon failed to restart; log follows:" >&2+ sudo cat /tmp/nix-daemon-retry.log >&2 || true+ return 1+ }++ build_appimage() {+ local attempt="$1"+ local -a fallback_args=()+ if [ "$attempt" -eq 3 ]; then+ fallback_args=(--fallback)+ fi++ # Force a hermetic Nix sandbox for linuxdeploy. Namespace's restored+ # Nix daemon can otherwise run unsandboxed under /nix/var/nix/builds,+ # where linuxdeploy sees host libraries/tools and can fail with only+ # `failed to run linuxdeploy` in Tauri's default output.+ nix build \+ "${fallback_args[@]}" \+ --option sandbox true \+ --option sandbox-build-dir /build \+ --option download-attempts 10 \+ --print-build-logs \+ ".#tauri-desktop-appimage"+ }++ for attempt in 1 2 3; do+ if build_appimage "$attempt"; then+ break+ fi+ if [ "$attempt" -eq 3 ]; then+ exit 1+ fi+ echo "::warning::AppImage nix build failed on attempt $attempt; retrying."+ restart_nix_daemon+ sleep $((attempt * 10))+ done+ if command -v cachix >/dev/null 2>&1 && [ -n "${CACHIX_CACHE_NAME:-}" ]; then+ cachix push "$CACHIX_CACHE_NAME" result || echo "::warning::Failed to push AppImage result closure to Cachix."+ fi+ shell: bash+ - name: Collect AppImage artifact+ run: |+ set -euo pipefail+ mkdir -p artifacts+ shopt -s nullglob+ appimages=(result/*.AppImage)+ if [ "${#appimages[@]}" -eq 0 ]; then+ echo "No AppImage files found in nix build result" >&2+ find -L result -maxdepth 2 -type f -print >&2 || true+ exit 1+ fi+ cp -v "${appimages[@]}" artifacts/+ chmod 0755 artifacts/*.AppImage+ (cd artifacts && sha256sum -- *.AppImage > macro-appimage-SHA256SUMS)+ shell: bash+ - name: Upload macro-appimage-${{ steps.metadata.outputs.safe_tag }} artifact+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02+ with:+ name: macro-appimage-${{ steps.metadata.outputs.safe_tag }}+ path: artifacts/*+ if-no-files-found: error+ retention-days: '30'+ - name: Teardown Nix+ if: always()+ uses: './.github/actions/teardown-nix'build-dmg:needs:- resolve-ref- uses: './.github/workflows/build_dmg_on_tag.yml'- with:- ref: ${{ needs.resolve-ref.outputs.ref }}- secrets: inherit+ name: Build macOS DMG+ runs-on: macos-15+ steps:+ - name: Checkout Repo+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10+ with:+ ref: ${{ needs.resolve-ref.outputs.ref }}+ persist-credentials: 'false'+ - name: Assert arm64 runner+ run: |+ set -euo pipefail+ if [ "$(uname -m)" != "arm64" ]; then+ echo "macOS DMG builds must run on an arm64/aarch64 runner, got $(uname -m)" >&2+ exit 1+ fi+ shell: bash+ - name: Install Nix+ run: |+ set -euo pipefail+ if ! command -v nix >/dev/null 2>&1; then+ curl --http1.1 --retry 5 --retry-delay 5 --retry-all-errors \+ --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \+ sh -s -- install macos --no-confirm \+ --extra-conf "experimental-features = nix-command flakes" \+ --extra-conf "sandbox = false" \+ --extra-conf "trusted-users = root runner"+ fi+ echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"+ echo "NIX_REMOTE=daemon" >> "$GITHUB_ENV"+ export PATH="/nix/var/nix/profiles/default/bin:$PATH"+ export NIX_REMOTE=daemon+ nix --version+ shell: bash+ - name: Configure Cachix fallback+ uses: './.github/actions/setup-cachix'+ with:+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}+ - name: Configure signing identity+ run: |+ set -euo pipefail+ if [ -z "${MACOS_DEVELOPER_ID_CERTIFICATE_BASE64}" ] || [ -z "${MACOS_DEVELOPER_ID_CERTIFICATE_PASSWORD}" ]; then+ echo "Developer ID certificate secrets are not configured; using ad-hoc signing for build validation."+ echo "APPLE_SIGNING_IDENTITY=-" >> "$GITHUB_ENV"+ exit 0+ fi++ certificate_path="$RUNNER_TEMP/developer-id-application.p12"+ printf '%s' "$MACOS_DEVELOPER_ID_CERTIFICATE_BASE64" | base64 --decode > "$certificate_path" 2>/dev/null \+ || printf '%s' "$MACOS_DEVELOPER_ID_CERTIFICATE_BASE64" | base64 -D > "$certificate_path"++ # Nix's macOS daemon builds as _nixbld users, not the runner user.+ # Put the Developer ID identity in the system keychain so codesign can+ # find it from inside the Nix build without embedding certificate+ # secrets into the derivation.+ sudo security import "$certificate_path" \+ -k /Library/Keychains/System.keychain \+ -P "$MACOS_DEVELOPER_ID_CERTIFICATE_PASSWORD" \+ -A \+ -T /usr/bin/codesign \+ -T /usr/bin/security+ sudo security set-key-partition-list \+ -S apple-tool:,apple:,codesign: \+ -s \+ -k "" \+ /Library/Keychains/System.keychain || true++ identity=$(security find-identity -v -p codesigning /Library/Keychains/System.keychain \+ | awk -F '"' '/Developer ID Application/ { print $2; exit }')+ if [ -z "$identity" ]; then+ echo "No Developer ID Application identity found in System.keychain" >&2+ security find-identity -v -p codesigning /Library/Keychains/System.keychain >&2 || true+ exit 1+ fi+ echo "APPLE_SIGNING_IDENTITY=$identity" >> "$GITHUB_ENV"+ echo "Using signing identity: $identity"+ shell: bash+ env:+ MACOS_DEVELOPER_ID_CERTIFICATE_BASE64: ${{ secrets.MACOS_DEVELOPER_ID_CERTIFICATE_BASE64 }}+ MACOS_DEVELOPER_ID_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_DEVELOPER_ID_CERTIFICATE_PASSWORD }}+ - id: metadata+ name: Derive artifact metadata+ run: |+ set -euo pipefail+ tag="${RAW_REF#refs/tags/}"+ if [ -z "$tag" ]; then+ tag="${GITHUB_REF_NAME:-untagged}"+ fi+ safe_tag=$(printf '%s' "$tag" | sed 's#[/\\:*?"<>|]#-#g' | tr -d '\r\n')+ echo "tag=$tag" >> "$GITHUB_OUTPUT"+ echo "safe_tag=$safe_tag" >> "$GITHUB_OUTPUT"+ shell: bash+ env:+ RAW_REF: ${{ needs.resolve-ref.outputs.ref }}+ - name: Build DMG with Nix+ run: |+ set -euo pipefail+ cachix_pid=+ if command -v cachix >/dev/null 2>&1 && [ -n "${CACHIX_CACHE_NAME:-}" ]; then+ cachix watch-store "$CACHIX_CACHE_NAME" >/tmp/cachix-watch-store.log 2>&1 &+ cachix_pid=$!+ trap 'if [ -n "${cachix_pid:-}" ]; then kill "$cachix_pid" 2>/dev/null || true; wait "$cachix_pid" 2>/dev/null || true; fi' EXIT+ fi+ nix build --impure --option sandbox false --print-build-logs ".#packages.aarch64-darwin.tauri-desktop-dmg"+ if command -v cachix >/dev/null 2>&1 && [ -n "${CACHIX_CACHE_NAME:-}" ]; then+ cachix push "$CACHIX_CACHE_NAME" result || echo "::warning::Failed to push DMG result closure to Cachix."+ fi+ shell: bash+ - name: Collect DMG artifact+ run: |+ set -euo pipefail+ mkdir -p artifacts+ shopt -s nullglob+ dmgs=(result/*.dmg)+ if [ "${#dmgs[@]}" -eq 0 ]; then+ echo "No DMG files found in nix build result" >&2+ find -L result -maxdepth 2 -type f -print >&2 || true+ exit 1+ fi+ cp -v "${dmgs[@]}" artifacts/+ shell: bash+ - name: Validate signed DMG+ run: |+ set -euo pipefail+ dmg=$(find artifacts -maxdepth 1 -type f -name '*.dmg' -print -quit)+ if [ -z "$dmg" ]; then+ echo "No DMG found to validate" >&2+ exit 1+ fi+ codesign --verify --strict --verbose=2 "$dmg"++ mount_dir=$(mktemp -d)+ hdiutil attach -readonly -nobrowse -mountpoint "$mount_dir" "$dmg"+ trap 'hdiutil detach "$mount_dir" >/dev/null 2>&1 || true; rmdir "$mount_dir" >/dev/null 2>&1 || true' EXIT+ app=$(find "$mount_dir" -maxdepth 2 -type d -name '*.app' -print -quit)+ if [ -z "$app" ] && [ -d "$mount_dir/Contents" ]; then+ app="$mount_dir"+ fi+ if [ -z "$app" ]; then+ echo "No app bundle found in DMG" >&2+ find "$mount_dir" -maxdepth 2 -print >&2 || true+ exit 1+ fi+ codesign --verify --deep --strict --verbose=2 "$app"++ dylib_refs=$(mktemp)+ search_roots=("$app/Contents/MacOS")+ if [ -d "$app/Contents/Frameworks" ]; then+ search_roots+=("$app/Contents/Frameworks")+ fi+ while IFS= read -r -d '' file; do+ otool -L "$file" 2>/dev/null \+ | awk -v file="$file" 'NR > 1 && $1 ~ "^/nix/store/.*\\.dylib$" { print file ": " $1 }' \+ >> "$dylib_refs" || true+ done < <(find "${search_roots[@]}" -type f -print0)+ if [ -s "$dylib_refs" ]; then+ echo "App bundle contains absolute Nix dylib references:" >&2+ cat "$dylib_refs" >&2+ exit 1+ fi++ (cd artifacts && shasum -a 256 -- *.dmg > macro-dmg-SHA256SUMS)+ shell: bash+ - name: Upload macro-dmg-${{ steps.metadata.outputs.safe_tag }} artifact+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02+ with:+ name: macro-dmg-${{ steps.metadata.outputs.safe_tag }}+ path: artifacts/*+ if-no-files-found: error+ retention-days: '30'+ publish-release:+ needs:+ - resolve-ref+ - build-appimage+ - build-dmg+ name: Upload Release Artifacts+ runs-on: ubuntu-latest+ permissions:+ contents: write+ steps:+ - id: metadata+ name: Derive artifact metadata+ run: |+ set -euo pipefail+ tag="${RAW_REF#refs/tags/}"+ if [ -z "$tag" ]; then+ tag="${GITHUB_REF_NAME:-untagged}"+ fi+ safe_tag=$(printf '%s' "$tag" | sed 's#[/\\:*?"<>|]#-#g' | tr -d '\r\n')+ echo "tag=$tag" >> "$GITHUB_OUTPUT"+ echo "safe_tag=$safe_tag" >> "$GITHUB_OUTPUT"+ shell: bash+ env:+ RAW_REF: ${{ needs.resolve-ref.outputs.ref }}+ - name: Download Build Artifacts+ uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0+ with:+ path: release-artifacts+ merge-multiple: 'true'+ - name: Upload Release Artifacts+ if: startsWith(steps.metadata.outputs.tag, 'v')+ uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65+ with:+ tag_name: ${{ steps.metadata.outputs.tag }}+ files: release-artifacts/*+ fail_on_unmatched_files: 'true'+concurrency:+ group: desktop-${{ inputs.ref || (github.event.ref_type == 'tag' && github.event.ref || github.ref_name) }}+ cancel-in-progress: truediff --git a/.github/workflows/build_dmg_on_tag.yml b/.github/workflows/build_dmg_on_tag.ymlindex 065e8251bb..988e5b4c75 100644--- a/.github/workflows/build_dmg_on_tag.yml+++ b/.github/workflows/build_dmg_on_tag.yml@@ -170,7 +170,7 @@ jobs:exit 1fi- (cd artifacts && shasum -a 256 -- *.dmg > SHA256SUMS)+ (cd artifacts && shasum -a 256 -- *.dmg > macro-dmg-SHA256SUMS)shell: bash- name: Upload macro-dmg-${{ steps.metadata.outputs.safe_tag }} artifactuses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02@@ -179,3 +179,37 @@ jobs:path: artifacts/*if-no-files-found: errorretention-days: '30'+ publish-dmg:+ needs:+ - build-dmg+ name: Upload Release Artifacts+ runs-on: ubuntu-latest+ permissions:+ contents: write+ steps:+ - id: metadata+ name: Derive artifact metadata+ run: |+ set -euo pipefail+ tag="${RAW_REF#refs/tags/}"+ if [ -z "$tag" ]; then+ tag="${GITHUB_REF_NAME:-untagged}"+ fi+ safe_tag=$(printf '%s' "$tag" | sed 's#[/\\:*?"<>|]#-#g' | tr -d '\r\n')+ echo "tag=$tag" >> "$GITHUB_OUTPUT"+ echo "safe_tag=$safe_tag" >> "$GITHUB_OUTPUT"+ shell: bash+ env:+ RAW_REF: ${{ inputs.ref }}+ - name: Download Build Artifacts+ uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0+ with:+ path: release-artifacts+ merge-multiple: 'true'+ - name: Upload Release Artifacts+ if: startsWith(steps.metadata.outputs.tag, 'v')+ uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65+ with:+ tag_name: ${{ steps.metadata.outputs.tag }}+ files: release-artifacts/*+ fail_on_unmatched_files: 'true'diff --git a/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs b/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rsindex 8b2a6275fd..fa4f0a44ba 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs@@ -1,7 +1,9 @@//! `Build AppImage` — reusable workflow that builds the Tauri desktop AppImage//! via Nix. Called from [`super::build_desktop_on_tag`].-use gh_workflow::{Event, Job, Run, Step, Workflow, WorkflowCall, WorkflowCallInput};+use gh_workflow::{+ Event, Job, Level, Permissions, Run, Step, Workflow, WorkflowCall, WorkflowCallInput,+};use crate::workflows::{runners, steps};@@ -23,18 +25,23 @@ pub fn build_appimage() -> Workflow {},)),)- .add_job("build-appimage", build_appimage_job())+ .add_job("build-appimage", build_appimage_job("${{ inputs.ref }}"))+ .add_job(+ "publish-appimage",+ publish_appimage_job("${{ inputs.ref }}").add_needs("build-appimage"),+ )}-fn build_appimage_job() -> Job {+/// Build the AppImage job, checking out and naming artifacts from `ref_expr`.+pub fn build_appimage_job(ref_expr: &str) -> Job {Job::default().name("Build AppImage").runs_on(runners::Runner::LinuxRustCi.to_string())- .add_step(steps::checkout_ref("${{ inputs.ref }}"))+ .add_step(steps::checkout_ref(ref_expr)).add_step(steps::mount_nix_cache_volume()).add_step(steps::setup_nix()).add_step(steps::setup_cachix())- .add_step(steps::derive_artifact_metadata("${{ inputs.ref }}"))+ .add_step(steps::derive_artifact_metadata(ref_expr)).add_step(nix_build_appimage()).add_step(collect_appimage()).add_step(steps::upload_artifact(@@ -44,6 +51,25 @@ fn build_appimage_job() -> Job {.add_step(steps::teardown_nix())}+/// Publish AppImage artifacts from the workflow run to the release tag.+pub fn publish_appimage_job(ref_expr: &str) -> Job {+ publish_job(ref_expr, "release-artifacts/*")+}++/// Publish desktop artifacts from the workflow run to the release tag.+pub fn publish_job(ref_expr: &str, artifacts_path: &str) -> Job {+ Job::default()+ .name("Upload Release Artifacts")+ .runs_on("ubuntu-latest")+ .permissions(Permissions {+ contents: Some(Level::Write),+ ..Default::default()+ })+ .add_step(steps::derive_artifact_metadata(ref_expr))+ .add_step(steps::download_artifacts("release-artifacts"))+ .add_step(steps::upload_release_artifacts(artifacts_path))+}+fn nix_build_appimage() -> Step<Run> {Step::new("Build AppImage with Nix").run(include_str!("scripts/build_appimage.sh"))diff --git a/rust/cloud-storage/tools/xtask/src/workflows/build_desktop_on_tag.rs b/rust/cloud-storage/tools/xtask/src/workflows/build_desktop_on_tag.rsindex a09c0cee6e..3bb6a830a8 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/build_desktop_on_tag.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/build_desktop_on_tag.rs@@ -2,87 +2,88 @@//! builds in parallel when a release tag is pushed. Also supports manual//! dispatch. Generated into `build_desktop_on_tag.yml`.//!-//! The actual build logic lives in the reusable workflows defined in-//! [`super::build_appimage_on_tag`] and [`super::build_dmg_on_tag`].-//!-//! This workflow is rendered by hand because `gh-workflow` 0.8's `Job` struct-//! cannot represent reusable-workflow calling jobs (`with:` +-//! `secrets: inherit`), and we don't want to add a direct YAML serializer-//! dependency to `xtask` just for this one workflow.+//! The reusable job definitions live in [`super::build_appimage_on_tag`] and+//! [`super::build_dmg_on_tag`].++use std::collections::HashMap;++use gh_workflow::{+ Concurrency, Event, Expression, Job, Push, Run, Step, Workflow, WorkflowDispatch,+ WorkflowDispatchInput,+};-use crate::workflows::build_appimage_on_tag;+use crate::workflows::{build_appimage_on_tag, build_dmg_on_tag};++const RESOLVED_REF: &str = "${{ needs.resolve-ref.outputs.ref }}";++/// Build the workflow.+pub fn build_desktop_on_tag() -> Workflow {+ Workflow::new("Build Desktop on Tag")+ .on(desktop_events())+ .concurrency(+ Concurrency::new(Expression::new("desktop-${{ inputs.ref || (github.event.ref_type == 'tag' && github.event.ref || github.ref_name) }}"))+ .cancel_in_progress(true),+ )+ .add_job("resolve-ref", resolve_ref())+ .add_job(+ "build-appimage",+ build_appimage_on_tag::build_appimage_job(RESOLVED_REF).add_needs("resolve-ref"),+ )+ .add_job(+ "build-dmg",+ build_dmg_on_tag::build_dmg_job(RESOLVED_REF).add_needs("resolve-ref"),+ )+ .add_job(+ "publish-release",+ build_appimage_on_tag::publish_job(RESOLVED_REF, "release-artifacts/*")+ .add_needs("resolve-ref")+ .add_needs("build-appimage")+ .add_needs("build-dmg"),+ )+}++fn desktop_events() -> Event {+ Event::default()+ .push(Push::default().add_tag(build_appimage_on_tag::DESKTOP_TAG_PATTERN))+ .workflow_dispatch(workflow_dispatch())+}++fn workflow_dispatch() -> WorkflowDispatch {+ let mut inputs = HashMap::new();+ inputs.insert(+ "ref".into(),+ WorkflowDispatchInput {+ description: "Release tag to build (v* or refs/tags/v*). Defaults to the selected protected ref or release tag.".into(),+ required: false,+ input_type: "string".into(),+ default: None,+ },+ );++ WorkflowDispatch { inputs }+}-/// Build the workflow YAML body.-pub fn build_desktop_on_tag() -> String {- format!(- indoc::indoc! {r#"- name: Build Desktop on Tag- 'on':- push:- tags:- - {desktop_tag_pattern}- create: {{}}- workflow_dispatch:- inputs:- ref:- description: Release tag to build (v* or refs/tags/v*). Defaults to the selected protected ref or release tag.- required: false- type: string- concurrency:- group: desktop-${{{{ inputs.ref || (github.event.ref_type == 'tag' && github.event.ref || github.ref_name) }}}}- cancel-in-progress: true- jobs:- resolve-ref:- if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'create' && github.event.ref_type == 'tag')- name: Resolve build ref- runs-on: ubuntu-latest- outputs:- ref: ${{{{ steps.resolve.outputs.ref }}}}- steps:- - id: resolve- name: Resolve ref- run: |- {resolve_ref_script}- shell: bash- env:- EVENT_NAME: ${{{{ github.event_name }}}}- INPUT_REF: ${{{{ inputs.ref }}}}- GITHUB_EVENT_REF: ${{{{ github.event.ref }}}}- GITHUB_EVENT_REF_TYPE: ${{{{ github.event.ref_type }}}}- SELECTED_REF: ${{{{ github.ref }}}}- SELECTED_REF_NAME: ${{{{ github.ref_name }}}}- SELECTED_REF_PROTECTED: ${{{{ github.ref_protected }}}}- build-appimage:- needs:- - resolve-ref- uses: './.github/workflows/build_appimage_on_tag.yml'- with:- ref: ${{{{ needs.resolve-ref.outputs.ref }}}}- secrets: inherit- build-dmg:- needs:- - resolve-ref- uses: './.github/workflows/build_dmg_on_tag.yml'- with:- ref: ${{{{ needs.resolve-ref.outputs.ref }}}}- secrets: inherit- "#},- desktop_tag_pattern = build_appimage_on_tag::DESKTOP_TAG_PATTERN,- resolve_ref_script = indent(include_str!("scripts/resolve_desktop_ref.sh"), 8),- )+fn resolve_ref() -> Job {+ Job::default()+ .cond(Expression::new(+ "github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'create' && github.event.ref_type == 'tag')",+ ))+ .name("Resolve build ref")+ .runs_on("ubuntu-latest")+ .add_output("ref", "${{ steps.resolve.outputs.ref }}")+ .add_step(resolve_ref_step())}-fn indent(value: &str, spaces: usize) -> String {- let prefix = " ".repeat(spaces);- value- .lines()- .map(|line| {- if line.is_empty() {- String::new()- } else {- format!("{prefix}{line}")- }- })- .collect::<Vec<_>>()- .join("\n")+fn resolve_ref_step() -> Step<Run> {+ Step::new("Resolve ref")+ .run(include_str!("scripts/resolve_desktop_ref.sh"))+ .id("resolve")+ .shell("bash")+ .add_env(("EVENT_NAME", "${{ github.event_name }}"))+ .add_env(("INPUT_REF", "${{ inputs.ref }}"))+ .add_env(("GITHUB_EVENT_REF", "${{ github.event.ref }}"))+ .add_env(("GITHUB_EVENT_REF_TYPE", "${{ github.event.ref_type }}"))+ .add_env(("SELECTED_REF", "${{ github.ref }}"))+ .add_env(("SELECTED_REF_NAME", "${{ github.ref_name }}"))+ .add_env(("SELECTED_REF_PROTECTED", "${{ github.ref_protected }}"))}diff --git a/rust/cloud-storage/tools/xtask/src/workflows/build_dmg_on_tag.rs b/rust/cloud-storage/tools/xtask/src/workflows/build_dmg_on_tag.rsindex 7e7c36b5ab..6bd6ccf9f9 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/build_dmg_on_tag.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/build_dmg_on_tag.rs@@ -3,7 +3,7 @@use gh_workflow::{Event, Job, Run, Step, Workflow, WorkflowCall, WorkflowCallInput};-use crate::workflows::{steps, vars};+use crate::workflows::{build_appimage_on_tag, steps, vars};/// Build the reusable workflow.pub fn build_dmg() -> Workflow {@@ -19,19 +19,24 @@ pub fn build_dmg() -> Workflow {},)),)- .add_job("build-dmg", build_dmg_job())+ .add_job("build-dmg", build_dmg_job("${{ inputs.ref }}"))+ .add_job(+ "publish-dmg",+ publish_dmg_job("${{ inputs.ref }}").add_needs("build-dmg"),+ )}-fn build_dmg_job() -> Job {+/// Build the macOS DMG job, checking out and naming artifacts from `ref_expr`.+pub fn build_dmg_job(ref_expr: &str) -> Job {Job::default().name("Build macOS DMG").runs_on("macos-15")- .add_step(steps::checkout_ref("${{ inputs.ref }}"))+ .add_step(steps::checkout_ref(ref_expr)).add_step(assert_arm64()).add_step(install_nix_macos()).add_step(steps::setup_cachix()).add_step(configure_signing_identity())- .add_step(steps::derive_artifact_metadata("${{ inputs.ref }}"))+ .add_step(steps::derive_artifact_metadata(ref_expr)).add_step(nix_build_dmg()).add_step(collect_dmg()).add_step(validate_signed_dmg())@@ -41,6 +46,10 @@ fn build_dmg_job() -> Job {))}+fn publish_dmg_job(ref_expr: &str) -> Job {+ build_appimage_on_tag::publish_job(ref_expr, "release-artifacts/*")+}+fn assert_arm64() -> Step<Run> {Step::new("Assert arm64 runner").run(indoc::indoc! {r#"diff --git a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs b/rust/cloud-storage/tools/xtask/src/workflows/mod.rsindex 9c6b00f9bb..ad0086aa15 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/mod.rs@@ -58,7 +58,7 @@ const WORKFLOWS: &[WorkflowFile] = &[},WorkflowFile {slug: "build_desktop_on_tag",- render_yaml: || Ok(build_desktop_on_tag::build_desktop_on_tag()),+ render_yaml: || render_gh_workflow(build_desktop_on_tag::build_desktop_on_tag)(),},WorkflowFile {slug: "code_check_cloud_storage",diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_appimage.sh b/rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_appimage.shindex 60a139810f..d4574ff438 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_appimage.sh+++ b/rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_appimage.sh@@ -9,4 +9,4 @@ if [ "${#appimages[@]}" -eq 0 ]; thenficp -v "${appimages[@]}" artifacts/chmod 0755 artifacts/*.AppImage-(cd artifacts && sha256sum -- *.AppImage > SHA256SUMS)+(cd artifacts && sha256sum -- *.AppImage > macro-appimage-SHA256SUMS)diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_signed_dmg.sh b/rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_signed_dmg.shindex 80766f44aa..52b2dca033 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_signed_dmg.sh+++ b/rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_signed_dmg.sh@@ -36,4 +36,4 @@ if [ -s "$dylib_refs" ]; thenexit 1fi-(cd artifacts && shasum -a 256 -- *.dmg > SHA256SUMS)+(cd artifacts && shasum -a 256 -- *.dmg > macro-dmg-SHA256SUMS)diff --git a/rust/cloud-storage/tools/xtask/src/workflows/steps.rs b/rust/cloud-storage/tools/xtask/src/workflows/steps.rsindex 0b93646cc6..92b8361868 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/steps.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/steps.rs@@ -179,7 +179,7 @@ pub fn derive_artifact_metadata(raw_ref_expr: &str) -> Step<Run> {.add_env(("RAW_REF", raw_ref_expr))}-/// Upload build artifacts via `actions/upload-artifact`, pinned.+/// Upload build artifacts within the workflow run for a later publish job.pub fn upload_artifact(name: &str, path: &str) -> Step<Use> {Step::new(format!("Upload {name} artifact")).uses(@@ -193,6 +193,34 @@ pub fn upload_artifact(name: &str, path: &str) -> Step<Use> {.add_with(("retention-days", 30))}+/// Download all build artifacts into one directory for release publishing.+pub fn download_artifacts(path: &str) -> Step<Use> {+ Step::new("Download Build Artifacts")+ .uses(+ "actions",+ "download-artifact",+ "634f93cb2916e3fdff6788551b99b062d0335ce0",+ ) // v5+ .add_with(("path", path))+ .add_with(("merge-multiple", true))+}++/// Attach build artifacts to the GitHub release for the resolved release tag.+pub fn upload_release_artifacts(path: &str) -> Step<Use> {+ Step::new("Upload Release Artifacts")+ .uses(+ "softprops",+ "action-gh-release",+ "3bb12739c298aeb8a4eeaf626c5b8d85266b0e65",+ ) // v2+ .if_condition(Expression::new(+ "startsWith(steps.metadata.outputs.tag, 'v')",+ ))+ .add_with(("tag_name", "${{ steps.metadata.outputs.tag }}"))+ .add_with(("files", path))+ .add_with(("fail_on_unmatched_files", true))+}+/// Teardown Nix (always runs).pub fn teardown_nix() -> Step<Use> {uses_local("Teardown Nix", "./.github/actions/teardown-nix")