Skip to content

Commit

Permalink
Merge pull request #82 from NREL/feature/github-action-for-cli
Browse files Browse the repository at this point in the history
GitHub Action for Building CLI Programs
  • Loading branch information
calbaker authored Jan 8, 2024
2 parents 99d0bfc + b77b254 commit 5910d9d
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/build-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: build-cli

on:
release:
types: [published]
workflow_dispatch:

jobs:
build:
name: build command line interfaces for ${{ matrix.platform || matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu
- macos
- windows
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir

runs-on: ${{ format('{0}-latest', matrix.os) }}

steps:
- uses: actions/checkout@v3

- name: set up rust
if: matrix.os != 'ubuntu'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: set up rust for ubuntu
if: matrix.os == 'ubuntu'
run: >
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y &&
rustup show
- run: rustup target add aarch64-apple-darwin
if: matrix.os == 'macos'

- name: run cargo tests
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- run: cd rust/fastsim-cli/ && cargo test

- run: cd rust/fastsim-cli/ && cargo build --release

- name: list current directory files
run: ${{ matrix.ls || 'ls -lh' }} ./rust/target/release/

- name: copy cli programs to new directory
if: matrix.os == 'windows'
run: |
mkdir cli
copy ./rust/target/release/vehicle-import-cli.exe cli
copy ./rust/target/release/fastsim-cli.exe cli
- name: copy cli programs to new directory (non-windows)
if: matrix.os != 'windows'
run: |
mkdir cli
cp ./rust/target/release/vehicle-import-cli cli
cp ./rust/target/release/fastsim-cli cli
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-cli
path: ./cli

0 comments on commit 5910d9d

Please sign in to comment.