Skip to content

Commit

Permalink
🚦 Add workflow for bundling binaries
Browse files Browse the repository at this point in the history
This adds an automatic workflow that bundles binaries and releases them
as artifacts upon completion. To start with, this only does this
process for macOS binaries; with the intention of adding more in the
near future.

There is a large chance that this process will change several times
over the course of this project, especially seeing as `cargo-bundle` is
not very well fleshed-out and fails to draw values correctly from
workspace `Cargo.toml` files.
  • Loading branch information
bitwizeshift committed Dec 16, 2023
1 parent a3e13e4 commit d00dcc3
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/actions/cargo-bundle/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: cargo-bundle
description: "Performs a cargo bundle step, with caching"
inputs:
profile:
default: dev
description: "The build profile to use"
required: false
path:
description: "Path to the binary that is being bundled"
required: true

runs:
using: "composite"
steps:
- name: Install cargo-bundle
uses: ./.github/actions/cargo-install
with:
target: cargo-bundle

- name: Bundle
id: bundle
shell: bash
working-directory: ${{ inputs.path }}
run:
if [[ ${{ inputs.profile }} = "dev" ]]; then
target_type="debug"
else
target_type="${{ inputs.profile }}"
fi
app_dir=$(find ${{ github.workspace }}/target/${target_type} -type d -name '*.app' | head -n 1)
app_name=$(basename "${app_dir}")
cargo bundle
cp -r ${VULKAN_SDK}/lib/libvulkan* ${app_dir}/Contents/Frameworks
cp -r ${VULKAN_SDK}/lib/libMoltenVK* ${app_dir}/Contents/Frameworks
install_name_tool -add_rpath "@executable_path/../Frameworks" ${app_dir}/Contents/MacOS/*
echo "application=${app_dir}" >> ${GITHUB_OUTPUT}
echo "application_name=${app_name}" >> ${GITHUB_OUTPUT}

- name: Upload Bundle Artifact
uses: actions/upload-artifact@v1
if: steps.bundle.outcome == 'success'
continue-on-error: true
with:
name: ${{ steps.bundle.outputs.application_name }}
path: ${{ steps.bundle.outputs.application }}
49 changes: 49 additions & 0 deletions .github/workflows/bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Bundle Binaries
on:
workflow_run:
workflows: [ build ]
types:
- completed
workflow_dispatch:
inputs:
profile:
description: "The build profile to use"
required: false
default: dev
options:
- dev
- release
type: choice
workflow_call:
inputs:
profile:
description: "The build profile to use"
default: dev
required: false
type: string

jobs:
example-app-macos:
name: Bundle MacOS Binary
runs-on: macos-latest
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare runner
uses: ./.github/actions/prepare-runner

- name: Install toolchain
uses: ./.github/actions/rust-toolchain

- name: Build
uses: ./.github/actions/cargo-build
with:
profile: ${{ inputs.profile }}

- name: Bundle
uses: ./.github/actions/cargo-bundle
with:
profile: ${{ inputs.profile }}
path: example

0 comments on commit d00dcc3

Please sign in to comment.