Skip to content

Commit

Permalink
wip(feat): add cargo-multivers GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnychevalier committed Dec 27, 2023
1 parent c07656d commit e968aae
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/action/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

ARGS="${INPUT_OTHER_ARGS:-}"
if [[ -n "${INPUT_MANIFEST_PATH:-}" ]]; then
ARGS+=" --manifest-path ${INPUT_MANIFEST_PATH}"
fi
if [[ -n "${INPUT_TARGET:-}" ]]; then
ARGS+=" --target ${INPUT_TARGET}"
fi
if [[ -n "${INPUT_RUNNER_VERSION:-}" ]]; then
ARGS+=" --runner-version ${INPUT_RUNNER_VERSION}"
fi
if [[ -n "${INPUT_PROFILE:-}" ]]; then
ARGS+=" --profile ${INPUT_PROFILE}"
fi
if [[ -n "${INPUT_OUT_DIR:-}" ]]; then
ARGS+=" --out-dir ${INPUT_OUT_DIR}"
fi

cargo multivers ${ARGS} -- ${INPUT_BUILD_ARGS:-}
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "!/LICENSE-*"
push:
branches:
- main
- '**'
paths:
- '**'
- '!/*.md'
Expand Down Expand Up @@ -98,3 +98,17 @@ jobs:
- uses: EmbarkStudios/cargo-deny-action@v1
with:
rust-version: "1.74.0"
test-action:
name: Test cargo-multivers action
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- uses: ./
with:
manifest_path: tests/test-argv/Cargo.toml
version: main
65 changes: 65 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "cargo-multivers"
description: "Build multiple versions of the same binary, each with a different CPU features set, merged into a single portable optimized binary"
branding:
icon: "cpu"
color: "orange"

inputs:
version:
description: "Version of cargo-multivers to use (e.g., 0.7.0)"
required: false
manifest_path:
description: "Path to Cargo.toml"
required: false
target:
description: "Build for the target triple"
required: false
out_dir:
description: "Copy final artifacts to this directory"
required: true
default: "."
profile:
description: "Build artifacts with the specified profile (default: release)"
required: false
runner_version:
description: "Specify the version of the runner to use"
required: false
other_args:
description: "Other arguments given to cargo multivers"
required: false
build_args:
description: "Arguments given to cargo build"
required: false

runs:
using: 'composite'
steps:
- name: Install cargo-multivers (git main)
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-multivers
git: https://github.com/ronnychevalier/cargo-multivers
branch: main
if: "${{ inputs.version == 'main' }}"
- name: Install cargo-multivers (version)
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-multivers
version: ${{ inputs.version }}
if: "${{ inputs.version != '' }}"
- name: Install cargo-multivers (latest)
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-multivers
if: "${{ inputs.version == '' }}"
- id: cargo-multivers
run: $GITHUB_ACTION_PATH/.github/action/entrypoint.sh
shell: bash
env:
INPUT_MANIFEST_PATH: ${{ inputs.manifest_path }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_OUT_DIR: ${{ inputs.out_dir }}
INPUT_PROFILE: ${{ inputs.profile }}
INPUT_RUNNER_VERSION: ${{ inputs.runner_version }}
INPUT_OTHER_ARGS: ${{ inputs.other_args }}
INPUT_BUILD_ARGS: ${{ inputs.build_args }}

0 comments on commit e968aae

Please sign in to comment.