diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7f01b02 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +on: + push: + tags: + - 'v*' + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Build project + run: | + rustup target add x86_64-unknown-linux-musl + cargo build --release + cargo build --release --target x86_64-unknown-linux-musl + zip --junk-paths release.zip garbage-* + - name: Create Release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: target/release/garbage + asset_name: garbage + asset_content_type: application/octet-stream + - name: Upload Musl Release Asset + id: upload-musl-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: target/x86_64-unknown-linux-musl/release/garbage + asset_name: garbage-musl + asset_content_type: application/octet-stream diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fec17ad..21851f7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -4,7 +4,6 @@ on: [push] jobs: build: - runs-on: ubuntu-latest steps: diff --git a/Cargo.toml b/Cargo.toml index d233d44..a367be4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garbage" -version = "0.1.2" +version = "0.1.3" authors = ["Michael Zhang "] description = "cli tool for interacting with the freedesktop trashcan" license = "MIT" diff --git a/src/ops/put.rs b/src/ops/put.rs index a754ecb..a3bed5a 100644 --- a/src/ops/put.rs +++ b/src/ops/put.rs @@ -28,53 +28,6 @@ pub fn put(paths: Vec, recursive: bool) -> Result<()> { Ok(()) } -// fn put_single(path: impl AsRef, recursive: bool) -> Result<()> { -// let current_dir = env::current_dir()?; -// let path = path.as_ref().canonicalize()?; - -// ensure!( -// path == current_dir -// || (current_dir.parent().is_some() && path == current_dir.parent().unwrap()), -// Error::CannotTrashDotDirs -// ); - -// // if path.is_dir() && !recursive { -// // error!("cannot trash directories without --recursive"); -// // return Ok(()); -// // } - -// let now = Local::now(); -// let elapsed = now.timestamp_millis(); - -// let home_trash = TrashDir::get_home_trash(); -// let file_name = format!( -// "{}.{}", -// elapsed, -// path.file_name().unwrap().to_str().unwrap() -// ); - -// let trash_file_path = home_trash.files_dir()?.join(&file_name); -// let trash_info_path = home_trash.info_dir()?.join(file_name + ".trashinfo"); - -// let trash_info = TrashInfo { -// path: path.clone(), -// deletion_date: now, -// deleted_path: trash_file_path.clone(), -// info_path: trash_info_path.clone(), -// }; -// { -// let trash_info_file = File::create(trash_info_path)?; -// trash_info.write(&trash_info_file)?; -// } - -// let result = fs::rename(&path, &trash_file_path); -// if result.is_err() { -// fs::copy(&path, &trash_file_path)?; -// } - -// Ok(()) -// } - pub enum DeletionStrategy { Copy, Topdir,