Create and upload rpm package on release #1565
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: # trigger on pull requests | |
push: | |
branches: # array of glob patterns matching against refs/heads. Optional; defaults to all | |
- main | |
env: | |
# Could, potentially automatically parse | |
# the bin name, but let's do it automatically for now. | |
ARTIFACT_BIN: cbsh | |
ARTIFACT_BIN_WINDOWS: cbsh.exe | |
# Space separated paths to include in the archive. | |
# Start relative paths with a dot if you don't want | |
# paths to be preserved. Use "/" as a delimiter. | |
ARTIFACT_ADDS: README.md LICENSE LICENSE_AGREEMENT NOTICES | |
jobs: | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
target: [ x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-msvc ] | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-22.04 | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-22.04 | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
steps: | |
- uses: ilammy/setup-nasm@v1 | |
- uses: actions/checkout@v3 | |
- name: Update Rust Toolchain Target | |
run: | | |
echo "targets = ['${{matrix.target}}']" >> rust-toolchain.toml | |
- name: Setup Rust toolchain and cache | |
uses: actions-rust-lang/setup-rust-toolchain@v1.4.3 | |
- name: Install aarch64-linux gcc | |
run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu -y | |
if: matrix.target == 'aarch64-unknown-linux-gnu' | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: 'aarch64-linux-gnu-gcc' | |
with: | |
command: build | |
args: --verbose --target ${{ matrix.target }} --features static-link-openssl | |
if: matrix.os == 'ubuntu-22.04' | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --verbose --target ${{ matrix.target }} | |
if: matrix.os == 'macos-latest' | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
# We build windows as a release build as debug builds are stack overflowing on startup. | |
args: --verbose --release --target ${{ matrix.target }} | |
env: | |
VCPKGRS_DYNAMIC: 1 | |
RUSTFLAGS: -Ctarget-feature=+crt-static | |
if: matrix.os == 'windows-latest' | |
- name: Test | |
uses: actions-rs/cargo@v1 | |
env: | |
DATA_TIMEOUT: "15s" | |
CBSH_LOG: cbsh=trace | |
RUST_LOG: debug | |
with: | |
command: test | |
args: --bins --quiet | |
- name: Create archive for Linux | |
id: createarchivelinux | |
run: | | |
7z a -ttar -so -an ./target/${{ matrix.target }}/debug/${{ env.ARTIFACT_BIN }} ${{ env.ARTIFACT_ADDS }} | 7z a -si ${{ env.ARTIFACT_BIN }}-${{ matrix.target }}.tar.gz | |
if: matrix.os == 'ubuntu-22.04' | |
- name: Install p7zip | |
# 7Zip not available on MacOS, install p7zip via homebrew. | |
run: brew install p7zip | |
if: matrix.os == 'macos-latest' | |
- name: Create archive for MacOS | |
id: createarchivemacos | |
run: | | |
7z a -tzip ${{ env.ARTIFACT_BIN }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/debug/${{ env.ARTIFACT_BIN }} ${{ env.ARTIFACT_ADDS }} | |
if: matrix.os == 'macos-latest' | |
- name: Create archive for Windows | |
id: createarchivewindows | |
run: | | |
choco install 7zip | |
7z a -tzip ${{ env.ARTIFACT_BIN }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/${{ env.ARTIFACT_BIN_WINDOWS }} ${{ env.ARTIFACT_ADDS }} | |
if: matrix.os == 'windows-latest' | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_BIN }}-${{ matrix.target }} | |
path: ${{ env.ARTIFACT_BIN }}-${{ matrix.target }}* | |
if-no-files-found: error | |
rustfmt: | |
name: Rustfmt | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- run: rustup component add rustfmt | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
machete: | |
name: Cargo Machete | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Machete | |
uses: bnjbvr/cargo-machete@main | |
clippy_check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run Clippy | |
run: cargo clippy --all-targets --all-features | |
nu-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hustcer/setup-nu@main | |
with: | |
version: "*" | |
- run: nu docs/sample_config/prompt_tests.nu | |
check-spelling: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Check Spelling | |
uses: rojopolis/spellcheck-github-actions@0.42.0 | |
with: | |
config_path: .github/workflows/.spellcheck.yml | |
task_name: Markdown |