Skip to content

Commit

Permalink
feat: update ci action
Browse files Browse the repository at this point in the history
  • Loading branch information
luhc228 committed Jun 3, 2024
1 parent a53e50b commit 9a6663b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 52 deletions.
54 changes: 23 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
name: Tests and release
name: Tests and Release

on:
# push:
# branches:
# - main
# tags-ignore:
# - '**'
# pull_request:
# [push]
workflow_dispatch

jobs:
test:
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
name: "unit tests"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
steps:
- uses: hecrj/setup-rust-action@v2
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v4
- name: Run tests
run: cargo test --verbose

build_and_release:
name: ${{ matrix.platform.os_name }} build and release
runs-on: ${{ matrix.platform.os }}
needs: test
if: (startsWith(github.ref, 'refs/tags/cli-v') || github.ref == 'refs/heads/test-release')
strategy:
fail-fast: false
matrix:
platform:
- os_name: windows-x86_64
Expand All @@ -33,53 +42,36 @@ jobs:
target: aarch64-apple-darwin
bin: toolkit
name: toolkit-macOS-aarch64.zip
skip_tests: true
toolchain: [stable]
steps:
- uses: actions/checkout@v4
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: "v2"
- name: Run tests
uses: houseabsolute/actions-rust-cross@v0
with:
command: "test"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--locked --release"
if: ${{ !matrix.platform.skip_tests }}
- uses: Swatinem/rust-cache@v2
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--locked --release"
strip: true
if: (startsWith(github.ref, 'refs/tags/cli-v') || github.ref == 'refs/heads/test-release')
# Windows
- name: Move binary to bin directory
run: |
cd target/${{ matrix.platform.target }}/release
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
if: matrix.platform.os == 'windows-latest' && (startsWith(github.ref, 'refs/tags/cli-v') || github.ref == 'refs/heads/test-release')
if: matrix.platform.os == 'windows-latest'
# Macos & Linux
- name: Move binary to bin directory
run: |
cd target/${{ matrix.platform.target }}/release
zip ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
if: matrix.platform.os != 'windows-latest' && (startsWith(github.ref, 'refs/tags/cli-v') || github.ref == 'refs/heads/test-release')
if: matrix.platform.os != 'windows-latest'
- name: Publish release binary
uses: actions/upload-artifact@v4
with:
name: toolkit-${{ matrix.platform.os_name }}
path: toolkit-*
if: (startsWith(github.ref, 'refs/tags/cli-v') || github.ref == 'refs/heads/test-release')
path: ${{ matrix.platform.name }}
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
draft: true
files: "toolkit-*"
files: ${{ matrix.platform.name }}
body_path: CHANGELOG.md
if: (startsWith(github.ref, 'refs/tags/cli-v') || github.ref == 'refs/heads/test-release')
10 changes: 2 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
name: Lint

on:
# push:
# branches:
# - main
# tags-ignore:
# - '**'
# pull_request:
workflow_dispatch
on: [push]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down
10 changes: 0 additions & 10 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ pub struct Cli {
pub enum Commands {
#[command(name = "install", about = "Install toolkits.")]
Install(InstallOpts),
#[command(name = "git-ssh", about = "Generate Git SSH secret key")]
GitSSH(GitSSHOpts),
}

#[derive(Parser, Debug)]
Expand All @@ -24,11 +22,3 @@ pub struct InstallOpts {
)]
pub manifest: String,
}

#[derive(Parser, Debug)]
pub struct GitSSHOpts {
#[arg(long)]
user_name: String,
#[arg(long)]
user_email: String,
}
3 changes: 0 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ async fn main() -> anyhow::Result<()> {
Commands::Install(opts) => {
install(&opts.manifest).await?;
}
Commands::GitSSH(opts) => {
println!("GitSSH: {:?}", opts);
}
},
None => {
eprintln!("No command provided");
Expand Down

0 comments on commit 9a6663b

Please sign in to comment.