Skip to content
Merged

ci #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/merge-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Merge to main

on:
push:
branches: [main]
tags:
- '*'

jobs:
build-test-publish:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}

env:
ARMORY_PASSWORD: ${{ secrets.ARMORY_PASSWORD }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "rust-cache"

- name: Install just
uses: extractions/setup-just@v3

- name: Install Rust target (Linux)
if: runner.os == 'Linux'
run: rustup target add x86_64-unknown-linux-musl

- name: Install musl tools (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y musl-tools

- name: Build
run: just build

- name: Test
run: just test

- name: Check for tag
id: check-tag
shell: bash
run: |
if git tag --points-at HEAD | grep -q .; then
echo "has_tag=true" >> $GITHUB_OUTPUT
else
echo "has_tag=false" >> $GITHUB_OUTPUT
fi

- name: Install Armory (Unix)
if: steps.check-tag.outputs.has_tag == 'true' && runner.os != 'Windows'
run: |
curl https://armory.msmoiz.com/install.sh | sh
echo "$HOME/.armory/bin" >> $GITHUB_PATH

- name: Install Armory (Windows)
if: steps.check-tag.outputs.has_tag == 'true' && runner.os == 'Windows'
run: |
Invoke-RestMethod https://armory.msmoiz.com/install.ps1 | Invoke-Expression
"$env:USERPROFILE\.armory\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Publish
if: steps.check-tag.outputs.has_tag == 'true'
run: just publish
39 changes: 39 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Validate pull request

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build-and-test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "rust-cache"

- name: Install just
uses: extractions/setup-just@v3

- name: Install Rust target (Linux)
if: runner.os == 'Linux'
run: rustup target add x86_64-unknown-linux-musl

- name: Install musl tools (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y musl-tools

- name: Build
run: just build

- name: Test
run: just test
37 changes: 37 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Lists available recipes.
default:
@just --list

# Runs tests.
test:
cargo test

# Builds release artifacts.
[linux]
build:
cargo build --release --target=x86_64-unknown-linux-musl

# Builds release artifacts.
[macos]
build:
cargo build --release --target=aarch64-apple-darwin

# Builds release artifacts.
[windows]
build:
cargo build --release --target=x86_64-pc-windows-msvc

# Publishes the application to the Armory registry.
[linux]
publish: build
armory publish --triple x86_64_linux

# Publishes the application to the Armory registry.
[macos]
publish: build
armory publish --triple aarch64_darwin

# Publishes the application to the Armory registry.
[windows]
publish: build
armory publish --triple x86_64_windows
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl TryFrom<Vec<String>> for Args {
continue;
}

if let Ok(q_type) = QuestionType::from_str(&arg) {
if let Ok(q_type) = QuestionType::from_str(&arg.to_ascii_uppercase()) {
match args.q_type.as_ref() {
Some(_) => bail!("type specified more than once"),
None => args.q_type = Some(q_type),
Expand Down
Loading