diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01e9ee2..a599f6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,22 +12,22 @@ name: CI jobs: build: name: Build - runs-on: '${{ matrix.os }}' + runs-on: "${{ matrix.os }}" strategy: matrix: include: - os: macos-latest target: aarch64-apple-darwin - suffix: '' + suffix: "" - os: macos-latest target: x86_64-apple-darwin - suffix: '' + suffix: "" - os: ubuntu-latest target: x86_64-unknown-linux-musl - suffix: '' + suffix: "" - os: ubuntu-latest target: x86_64-unknown-linux-gnu - suffix: '' + suffix: "" - os: windows-latest target: x86_64-pc-windows-msvc suffix: .exe @@ -51,7 +51,7 @@ jobs: - name: Make binary executable run: chmod u+x ./target/${{ matrix.target }}/release/tool-new-release${{ matrix.suffix }} - name: Archive production artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: tool-new-release-${{ matrix.target }} path: ./target/${{ matrix.target }}/release/tool-new-release${{ matrix.suffix }} diff --git a/src/args.rs b/src/args.rs index fe0dd10..b5abda7 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,48 +1,38 @@ -use clap:: { - Parser, - Subcommand -}; +use clap::{Parser, Subcommand}; #[derive(Debug, Parser)] #[clap(author, version, about)] -pub struct ReleaseArgs{ - #[clap(subcommand)] - pub project: Project, - - /// Run the deploy pipeline without actually deploying. - /// Useful for understanding all the necessary steps, or when working on the pipeline itself. - #[arg(long, global = true)] - pub dry_run: bool, +pub struct ReleaseArgs { + #[clap(subcommand)] + pub project: Project, + + /// Run the deploy pipeline without actually deploying. + /// Useful for understanding all the necessary steps, or when working on the pipeline itself. + #[arg(long, global = true)] + pub dry_run: bool, } #[derive(Debug, Subcommand)] pub enum Project { - /// Release the Guides guides.emberjs.com - Guides, - - /// Run algolia on the guides - GuidesSearch, + /// Release the Guides guides.emberjs.com + Guides, - /// Release the API Docs api.emberjs.com - ApiDocs, + /// Run algolia on the guides + GuidesSearch, - /// Prepare the release blog post on blog.emberjs.com - BlogPost, + /// Release the API Docs api.emberjs.com + ApiDocs, - /// Update the Glitch project - Glitch { - /// Set this to be the version you're trying to release - #[arg(long)] - version: String, - }, + /// Prepare the release blog post on blog.emberjs.com + BlogPost, - /// Update details on wikipedia - Wikipedia, + /// Update details on wikipedia + Wikipedia, - /// Update the reminder bot - Bot { - /// Set this to true if you're doing a major version release - #[arg(long, global = true)] - major_version: bool, - }, -} \ No newline at end of file + /// Update the reminder bot + Bot { + /// Set this to true if you're doing a major version release + #[arg(long, global = true)] + major_version: bool, + }, +} diff --git a/src/git/add.rs b/src/git/add.rs deleted file mode 100644 index b5a26f8..0000000 --- a/src/git/add.rs +++ /dev/null @@ -1,9 +0,0 @@ -/// Stages all changed files in the repository. -pub fn add(glitch_repo: &git2::Repository) -> git2::Index { - let mut index = glitch_repo.index().unwrap(); - index - .add_all(["*"].iter(), git2::IndexAddOption::DEFAULT, None) - .unwrap(); - index.write().unwrap(); - index -} diff --git a/src/git/commit.rs b/src/git/commit.rs deleted file mode 100644 index 2357f04..0000000 --- a/src/git/commit.rs +++ /dev/null @@ -1,18 +0,0 @@ -/// Creates a commit in the repository. -pub fn commit(mut index: git2::Index, glitch_repo: &git2::Repository, version: &str) { - let tree_id = index.write_tree().unwrap(); - let tree = glitch_repo.find_tree(tree_id).unwrap(); - let sig = glitch_repo.signature().unwrap(); - let head_id = glitch_repo.refname_to_id("HEAD").unwrap(); - let parent = glitch_repo.find_commit(head_id).unwrap(); - let _commit_id = glitch_repo - .commit( - Some("HEAD"), - &sig, - &sig, - &format!("{} (glitch)", version), - &tree, - &[&parent], - ) - .unwrap(); -} diff --git a/src/glitch/push.rs b/src/glitch/push.rs deleted file mode 100644 index 969413d..0000000 --- a/src/glitch/push.rs +++ /dev/null @@ -1,11 +0,0 @@ -use std::path::PathBuf; - -pub fn push(dir: PathBuf) { - std::process::Command::new("git") - .current_dir(&dir) - .args(&["push"]) - .spawn() - .unwrap() - .wait() - .expect("git status"); -} diff --git a/src/main.rs b/src/main.rs index dc4f839..a2ced6c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,30 +1,24 @@ -use std::path::{PathBuf}; use crate::utils::prompt::{automated, yes_no}; -use std::fs; use dirs; +use std::fs; +use std::path::PathBuf; mod projects { pub mod api; pub mod blog_post; pub mod bot; - pub mod glitch; pub mod guides; pub mod wikipedia; } -mod cli; mod args; +mod cli; use args::ReleaseArgs; use clap::Parser; pub mod utils; mod git { - pub mod add; pub mod clone; - pub mod commit; - pub mod push; -} -mod glitch { pub mod push; } @@ -34,7 +28,6 @@ fn get_project_name(project: &args::Project) -> &'static str { args::Project::GuidesSearch => "Guides", args::Project::ApiDocs => "ApiDocs", args::Project::BlogPost => "BlogPost", - args::Project::Glitch { version: _ } => "Glitch", args::Project::Wikipedia => "Wikipedia", args::Project::Bot { major_version: _ } => "Bot", } @@ -50,13 +43,22 @@ fn main() { dir.push(get_project_name(&args.project)); let dir = dir.as_path(); - - let local_dir = format!("~/tool-new-release-working-dir/{}", get_project_name(&args.project)); + + let local_dir = format!( + "~/tool-new-release-working-dir/{}", + get_project_name(&args.project) + ); automated(format!("starting the process in the local dir {} now", local_dir).as_str()); if dir.exists() { - if yes_no(format!("Working directory {} already exists, do you want to delete it? y/n", local_dir).as_str()) { + if yes_no( + format!( + "Working directory {} already exists, do you want to delete it? y/n", + local_dir + ) + .as_str(), + ) { println!("Deleting now!"); fs::remove_dir_all(dir).expect("could not delete working directory"); fs::create_dir_all(dir).expect("Could not create working directory"); @@ -70,11 +72,10 @@ fn main() { args::Project::GuidesSearch => projects::guides::publish_algolia(dir, args.dry_run), args::Project::ApiDocs => projects::api::run(dir, args.dry_run), args::Project::BlogPost => projects::blog_post::run(), - args::Project::Glitch { version } => projects::glitch::run(dir, args.dry_run, version), args::Project::Wikipedia => projects::wikipedia::run(), args::Project::Bot { major_version } => { let versions = crate::cli::ask_version(major_version); projects::bot::run(&versions.target) - }, + } }; } diff --git a/src/projects/guides.rs b/src/projects/guides.rs index 0a24984..eaf9364 100644 --- a/src/projects/guides.rs +++ b/src/projects/guides.rs @@ -1,21 +1,22 @@ use crate::utils::prompt::{automated, manual}; -use std::{path::Path, process}; use semver::{Version, VersionReq}; +use std::{path::Path, process}; pub fn run(dir: &Path, dry_run: bool) { let npm_version_command = process::Command::new("node") - .arg("--version") - .output() - .expect("Could not check node version"); + .arg("--version") + .output() + .expect("Could not check node version"); let stdout_result = String::from_utf8(npm_version_command.stdout).unwrap(); - let req = VersionReq::parse(">=14.0.0").unwrap(); - let version = Version::parse(&stdout_result[1..stdout_result.len()].trim()).unwrap(); - if !req.matches(&version) { - panic!("Guides can only be installed with node version 14 and above right now. you have {:?}", stdout_result) + if !req.matches(&version) { + panic!( + "Guides can only be installed with node version 14 and above right now. you have {:?}", + stdout_result + ) } manual("Check for pending PRs: https://github.com/ember-learn/guides-source/pulls"); @@ -35,7 +36,6 @@ pub fn run(dir: &Path, dry_run: bool) { if !status.success() { panic!("npm install failed"); } - } automated("Creating new version of guides"); diff --git a/src/utils/op.rs b/src/utils/op.rs index 699ea77..9264397 100644 --- a/src/utils/op.rs +++ b/src/utils/op.rs @@ -68,11 +68,6 @@ pub fn read(path: &str) -> String { let output = op().args(&["read", path]).output().unwrap(); String::from_utf8_lossy(&output.stdout).trim().to_string() } -pub mod glitch { - pub fn read() -> String { - super::read("op://Ember Learning Team/Glitch/password") - } -} pub mod api_docs { use std::collections::HashMap;