Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaaskarian committed Mar 24, 2024
2 parents b669fb2 + 16eab32 commit 373681b
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 159 deletions.
13 changes: 13 additions & 0 deletions .shell-methods.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
RED='\033[0;31m'
NC='\033[0m' # No Color

if [ "$#" -ne 1 ]; then
echo Usage: $0 tag_name
exit 1
fi

echo_exit() {
echo -e $RED"Error$NC: $*"
exit 1
}

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "c3"
version = "0.5.1"
version = "0.5.2"
edition = "2021"

[dependencies]
Expand Down
19 changes: 19 additions & 0 deletions bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env sh
. ./.shell-methods.sh
TAG="$1"

bump_version() {
sed -i "s/^version = .*/version = \"$TAG\"/" Cargo.toml
git add Cargo.toml
}

build_package() {
cargo build --release || echo_exit Linux build failed.
cargo build --release --target x86_64-pc-windows-gnu || echo_exit Windows build failed.
}

cargo test || echo_exit Unittests failed.
bump_version
build_package
git add Cargo.lock
git commit -m "Bumped version $TAG"
26 changes: 2 additions & 24 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
#!/bin/bash
echo_exit() {
echo Error: $*
exit 1
}

if [ "$#" -ne 1 ]; then
echo Usage: ./release.sh tag_name
exit 1
fi
#!/usr/bin/env sh
. ./.shell-methods.sh

LAST_TAG=$(git tag | tail -n 1)

PACKAGE_NAME=c3
USERNAME=nimaaskarian
TAG="$1"
update_cargo_toml() {
sed -i "s/^version = .*/version = \"$TAG\"/" Cargo.toml
git add Cargo.toml
}

push_tag() {
git push
git tag "$TAG" || {
echo List of existing tags:
git tag
Expand All @@ -29,11 +16,6 @@ push_tag() {
git push --tags
}

build_package() {
cargo build --release || echo_exit linux build failed
cargo build --release --target x86_64-pc-windows-gnu || echo_exit windows build failed
}

release_package() {
cp target/release/c3 c3.x86.linux || echo_exit copy linux binary failed
cp target/x86_64-pc-windows-gnu/release/c3.exe c3.x86_64.windows.exe || echo_exit copy windows binary failed
Expand Down Expand Up @@ -72,10 +54,6 @@ release_c3_bin() {
cd ../..
}

update_cargo_toml
build_package
git add Cargo.lock
git commit -m "Bumped version $TAG"
push_tag
release_package
release_c3
Expand Down
8 changes: 4 additions & 4 deletions src/fileio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use home::home_dir;

#[inline(always)]
pub fn append_home_dir(vec:[&str; 4]) -> PathBuf {
let mut path = PathBuf::from(format!("{}", home_dir().unwrap().to_str().unwrap()));
let mut path = home_dir().unwrap().to_path_buf();
for item in vec {
path = path.join(item);
}
Expand All @@ -18,10 +18,10 @@ pub fn append_home_dir(vec:[&str; 4]) -> PathBuf {
pub fn get_todo_path() -> io::Result<PathBuf> {
let file = append_home_dir([".local","share","calcurse","todo"]);
if file.is_dir() {
remove_dir(file.clone())?;
remove_dir(&file)?;
}
let parentdir = file.parent().unwrap();
let _ = std::fs::create_dir_all(parentdir)?;
std::fs::create_dir_all(parentdir)?;
Ok(file)
}

Expand All @@ -39,7 +39,7 @@ pub fn temp_note_path() -> PathBuf{
#[inline(always)]
pub fn file_content(path:&PathBuf) -> io::Result<String> {
let mut content = String::new();
let mut file = File::open(path.as_os_str())?;
let mut file = File::open(path)?;
file.read_to_string(&mut content)?;
Ok(content)
}
Expand Down
Loading

0 comments on commit 373681b

Please sign in to comment.