-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
351 additions
and
113 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Release | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Create Release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
publish: | ||
name: publish ${{ matrix.name }} | ||
needs: | ||
- release | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
- target: x86_64-pc-windows-gnu | ||
suffix: windows-x86_64 | ||
archive: zip | ||
name: x86_64-pc-windows-gnu | ||
- target: x86_64-unknown-linux-gnu | ||
suffix: linux-x86_64 | ||
archive: tar.xz | ||
name: x86_64-unknown-linux-gnu | ||
- target: x86_64-apple-darwin | ||
suffix: darwin-x86_64 | ||
archive: tar.gz | ||
name: x86_64-apple-darwin | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone test repository | ||
uses: actions/checkout@v2 | ||
- uses: xhaiker/[email protected] | ||
name: build ${{ matrix.name }} | ||
with: | ||
release: ${{ github.ref_name }} | ||
rust_target: ${{ matrix.target }} | ||
archive_suffix: ${{ matrix.suffix }} | ||
archive_types: ${{ matrix.archive }} | ||
extra_files: "README.md" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,51 @@ | ||
use serde::{Serialize}; | ||
use structopt::StructOpt; | ||
|
||
use std::sync::OnceLock; | ||
|
||
|
||
#[derive(Debug, StructOpt)] | ||
#[structopt(name = "args")] | ||
pub struct Args { | ||
#[structopt(subcommand)] | ||
pub command: Command, | ||
|
||
#[structopt(short, long)] | ||
pub verbose: bool, | ||
// #[structopt(short, long)] | ||
// pub verbose: bool, | ||
} | ||
|
||
#[derive(StructOpt, Debug)] | ||
pub enum Command { | ||
Web { | ||
#[structopt(long)] | ||
#[structopt(long, env="FAKECDN_LISTEN", default_value="127.0.0.1:9527")] | ||
listen: String, | ||
|
||
#[structopt(long, env="FAKECDN_DIR", default_value=".uploads")] | ||
dir: String, | ||
|
||
#[structopt(long, env="FAKECDN_TOKEN", default_value="")] | ||
token: String, | ||
}, | ||
} | ||
|
||
pub fn get_args() -> &'static Args { | ||
static ARGS: OnceLock<Args> = OnceLock::new(); | ||
return ARGS.get_or_init(|| parse_args()); | ||
} | ||
|
||
|
||
pub fn get_args_token() -> &'static String { | ||
let args = get_args(); | ||
match &args.command { | ||
Command::Web { token, .. } => return token, | ||
} | ||
} | ||
|
||
pub fn parse_args() -> Args { | ||
return Args::from_args() | ||
} | ||
return Args::from_args(); | ||
} | ||
|
||
// pub fn parse_args() -> &'static Mutex<Args> { | ||
// // return Args::from_args() | ||
// static ARGS: OnceLock<Mutex<Args>> = OnceLock::new(); | ||
// return ARGS.get_or_init(|| Mutex::new(Args::from_args())) | ||
// } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use std::fs::File; | ||
use std::path::Path; | ||
use std::path::PathBuf; | ||
use flate2::read::GzDecoder; | ||
use tar::Archive; | ||
|
||
pub(crate) fn uncompress_tgz(path: &PathBuf, dest: &Path) -> Result<(), std::io::Error> { | ||
// let path = "archive.tar.gz"; | ||
let tar_gz = File::open(path)?; | ||
let tar = GzDecoder::new(tar_gz); | ||
let mut archive = Archive::new(tar); | ||
archive.unpack(dest)?; | ||
|
||
Ok(()) | ||
} |
Empty file.
Oops, something went wrong.