From d00dcc39aab6c8f9173eb34678da6c57b875e963 Mon Sep 17 00:00:00 2001 From: Matthew Rodusek <7519129+bitwizeshift@users.noreply.github.com> Date: Sat, 16 Dec 2023 14:52:51 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A6=20Add=20workflow=20for=20bundling?= =?UTF-8?q?=20binaries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .github/actions/cargo-bundle/action.yaml | 45 ++++++++++++++++++++++ .github/workflows/bundle.yaml | 49 ++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 .github/actions/cargo-bundle/action.yaml create mode 100644 .github/workflows/bundle.yaml diff --git a/.github/actions/cargo-bundle/action.yaml b/.github/actions/cargo-bundle/action.yaml new file mode 100644 index 0000000..9a60267 --- /dev/null +++ b/.github/actions/cargo-bundle/action.yaml @@ -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 }} diff --git a/.github/workflows/bundle.yaml b/.github/workflows/bundle.yaml new file mode 100644 index 0000000..54c1ed3 --- /dev/null +++ b/.github/workflows/bundle.yaml @@ -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