add releaser
This commit is contained in:
parent
bd52a2d3bb
commit
98cb397ea9
108
.github/workflows/release.yml
vendored
Normal file
108
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- next
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_INCREMENTAL: 0
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: ${{ matrix.target }}
|
||||
permissions:
|
||||
contents: write
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-musl
|
||||
deb: true
|
||||
- os: ubuntu-latest
|
||||
target: arm-unknown-linux-musleabihf
|
||||
- os: ubuntu-latest
|
||||
target: armv7-unknown-linux-musleabihf
|
||||
- os: ubuntu-latest
|
||||
target: aarch64-unknown-linux-musl
|
||||
deb: true
|
||||
|
||||
- os: macos-11
|
||||
target: x86_64-apple-darwin
|
||||
- os: macos-11
|
||||
target: aarch64-apple-darwin
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: sed -En 's/^version = "(.*)"/value=\1/p' Cargo.toml >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
- name: Setup cache
|
||||
uses: Swatinem/rust-cache@v1
|
||||
with:
|
||||
key: ${{ matrix.target }}
|
||||
|
||||
- name: Build binary
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --locked --target=${{ matrix.target }} --color=always --verbose
|
||||
use-cross: ${{ runner.os == 'Linux' }}
|
||||
|
||||
- name: Install cargo-deb
|
||||
if: ${{ matrix.deb == true }}
|
||||
uses: actions-rs/install@v0.1
|
||||
with:
|
||||
crate: cargo-deb
|
||||
|
||||
- name: Build deb
|
||||
if: ${{ matrix.deb == true }}
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: deb
|
||||
args: --no-build --no-strip --output=. --target=${{ matrix.target }}
|
||||
|
||||
- name: Package (*nix)
|
||||
if: runner.os != 'Windows'
|
||||
run: >
|
||||
tar -cv
|
||||
LICENSE README.md
|
||||
man/
|
||||
-C target/${{ matrix.target }}/release/ toolkit
|
||||
| gzip --best
|
||||
> 'toolkit-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz'
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.target }}
|
||||
path: |
|
||||
*.deb
|
||||
*.tar.gz
|
||||
*.zip
|
||||
- name: Create release
|
||||
if: ${{ github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore(release)') }}
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: true
|
||||
files: |
|
||||
*.deb
|
||||
*.tar.gz
|
||||
*.zip
|
||||
name: ${{ steps.get_version.outputs.value }}
|
||||
tag_name: ""
|
@ -1,5 +1,6 @@
|
||||
use std::io::Write;
|
||||
|
||||
use clap::value_parser;
|
||||
use eyre::Context;
|
||||
|
||||
pub struct FuzzyClone;
|
||||
@ -201,13 +202,18 @@ impl FuzzyClone {
|
||||
}),
|
||||
)?;
|
||||
} else {
|
||||
util::shell::run(&["git", "pull"], None)?;
|
||||
util::shell::run(
|
||||
&["git", "pull"],
|
||||
Some(util::shell::RunOptions {
|
||||
path: git_repo_path.clone(),
|
||||
}),
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(git_repo_path)
|
||||
}
|
||||
|
||||
fn run() -> eyre::Result<()> {
|
||||
fn run(print_dest: &bool) -> eyre::Result<()> {
|
||||
let settings = Self::get_settings()?;
|
||||
if settings.auto_update {
|
||||
println!("running auto update");
|
||||
@ -234,10 +240,17 @@ impl FuzzyClone {
|
||||
let chosen = util::shell::run_with_input_and_output(&["fzf"], entries_str)?;
|
||||
let chosen = std::str::from_utf8(&chosen.stdout)?;
|
||||
|
||||
Self::clone(GitHubEntry::from(chosen.to_string()).ok_or(eyre::anyhow!(
|
||||
let path = Self::clone(GitHubEntry::from(chosen.to_string()).ok_or(eyre::anyhow!(
|
||||
"could not parse choice as github entry <org>/<repo>"
|
||||
))?)?;
|
||||
|
||||
if *print_dest {
|
||||
print!(
|
||||
"{}",
|
||||
path.to_str().ok_or(eyre::anyhow!("path was not found"))?
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -255,13 +268,24 @@ impl util::Cmd for FuzzyClone {
|
||||
Ok(clap::Command::new("fuzzy-clone")
|
||||
.alias("fc")
|
||||
.alias("c")
|
||||
.arg(
|
||||
clap::Arg::new("print-dest")
|
||||
.long("print-dest")
|
||||
.value_name("print-dest")
|
||||
.value_parser(value_parser!(bool))
|
||||
.num_args(0..=1)
|
||||
.require_equals(true)
|
||||
.default_missing_value("true"),
|
||||
)
|
||||
.subcommand(clap::Command::new("update")))
|
||||
}
|
||||
|
||||
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
let print_dest = args.get_one::<bool>("print-dest").unwrap_or(&false);
|
||||
|
||||
match args.subcommand() {
|
||||
Some(("update", _)) => Self::update()?,
|
||||
_ => Self::run()?,
|
||||
_ => Self::run(print_dest)?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
0
man/.gitkeep
Normal file
0
man/.gitkeep
Normal file
13
src/init/fish.rs
Normal file
13
src/init/fish.rs
Normal file
@ -0,0 +1,13 @@
|
||||
pub struct Fish;
|
||||
|
||||
impl util::Cmd for Fish {
|
||||
fn cmd() -> eyre::Result<clap::Command> {
|
||||
let cmd = clap::Command::new("fish").subcommands(&[]);
|
||||
|
||||
Ok(cmd)
|
||||
}
|
||||
|
||||
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
20
src/init/mod.rs
Normal file
20
src/init/mod.rs
Normal file
@ -0,0 +1,20 @@
|
||||
mod fish;
|
||||
|
||||
pub struct Init;
|
||||
|
||||
impl util::Cmd for Init {
|
||||
fn cmd() -> eyre::Result<clap::Command> {
|
||||
let cmd = clap::Command::new("init")
|
||||
.subcommands(&[fish::Fish::cmd()?])
|
||||
.subcommand_required(true);
|
||||
|
||||
Ok(cmd)
|
||||
}
|
||||
|
||||
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
match args.subcommand() {
|
||||
Some(("fish", args)) => fish::Fish::exec(args),
|
||||
_ => Err(eyre::anyhow!("missing command!")),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
use util::Cmd;
|
||||
|
||||
mod init;
|
||||
mod prereqs;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
@ -10,7 +11,9 @@ fn main() -> eyre::Result<()> {
|
||||
sourcegraph::Sourcegraph::cmd()?,
|
||||
github::GitHub::cmd()?,
|
||||
stats::Stats::cmd()?,
|
||||
init::Init::cmd()?,
|
||||
])
|
||||
.subcommand_required(true)
|
||||
.get_matches();
|
||||
|
||||
match matches.subcommand() {
|
||||
@ -19,6 +22,7 @@ fn main() -> eyre::Result<()> {
|
||||
Some(("sourcegraph", subcmd)) => sourcegraph::Sourcegraph::exec(subcmd),
|
||||
Some(("github", subcmd)) => github::GitHub::exec(subcmd),
|
||||
Some(("stats", subcmd)) => stats::Stats::exec(subcmd),
|
||||
Some(("init", subcmd)) => init::Init::exec(subcmd),
|
||||
_ => Err(eyre::anyhow!("no command selected!")),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user