Skip to content

Commit

Permalink
Merge branch 'main' into feature-build
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuN6211 committed Sep 28, 2024
2 parents eb0af49 + 84d1559 commit d94bf11
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint

on: [push]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install ShellCheck
run: sudo apt install -y shellcheck

- name: Run ShellCheck
run: shellcheck ./install.sh ./scripts/*.bash
12 changes: 12 additions & 0 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: macOS

on: [push]

jobs:
macOS:
name: macOS
runs-on: macOS-latest

steps:
- name: Setup
run: curl -sL https://raw.githubusercontent.com/ShuN6211/dotfiles/refs/heads/main/install.sh | sh
12 changes: 12 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
INSTALL_DIR="${INSTALL_DIR:-$HOME/workspace/dotfiles}"

if [ -d "$INSTALL_DIR" ]; then
echo "Updating dotfiles..."
git -C "$INSTALL_DIR" pull
else
echo "Installing dotfiles..."
git clone https://github.com/ShuN6211/dotfiles.git "$INSTALL_DIR"
fi

/bin/bash "$INSTALL_DIR/scripts/setup.bash"
20 changes: 20 additions & 0 deletions scripts/common.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -x

export CUR_DIR REPO_DIR
CUR_DIR="$(
cd "$(dirname "$0")" || exit 1
pwd
)"
REPO_DIR="$(
cd "$(dirname "$0")/.." || exit 1
pwd
)"

export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"

export DENO_INSTALL="${DENO_INSTALL:-$XDG_DATA_HOME/deno}"
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
export CARGO_HOME="$XDG_DATA_HOME/cargo"
22 changes: 22 additions & 0 deletions scripts/setup-homebrew.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -x
# shellcheck source=./scripts/common.bash
source "$(dirname "$0")/common.bash"

[ "$(uname)" != "Darwin" ] && exit
[ -n "$SKIP_HOMEBREW" ] && exit

if type brew >/dev/null; then
echo "Homebrew is already installed."
else
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi

echo "Updating Homebrew..."
brew update

echo "Installing Homebrew apps..."
brew bundle install --file "${REPO_DIR}/config/homebrew/Brewfile" --no-lock --verbose

true
24 changes: 24 additions & 0 deletions scripts/setup-links.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -x
# shellcheck source=./scripts/common.bash
source "$(dirname "$0")/common.bash"

if [[ ! -d "$HOME/.ssh" ]]; then
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
fi

if [[ ! -d "$HOME/.gnupg" ]]; then
mkdir -p "$HOME/.gnupg"
chmod 700 "$HOME/.gnupg"
fi

mkdir -p \
"$XDG_CONFIG_HOME" \
"$XDG_STATE_HOME" \
"$XDG_DATA_HOME/vim"

ln -sfv "$REPO_DIR/config/"* "$XDG_CONFIG_HOME"
ln -sfv "$XDG_CONFIG_HOME/zsh/.zshenv" "$HOME/.zshenv"
ln -sfv "$XDG_CONFIG_HOME/editorconfig/.editorconfig" "$HOME/.editorconfig"
ln -sfnv "$XDG_CONFIG_HOME/vim" "$HOME/.vim"
13 changes: 7 additions & 6 deletions scripts/setup-sheldon.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ set -x
# shellcheck source=./scripts/common.bash
source "$(dirname "$0")/common.bash"

if [ -d "$XDG_DATA_HOME/sheldon/bin" ]; then
echo "sheldon is already installed."
if [ ! -e "$CARGO_HOME/env" ]; then
echo "Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | /bin/sh -s -- -y --no-modify-path
else
echo "Installing sheldon..."
curl --proto '=https' -fLsS https://rossmacarthur.github.io/install/crate.sh \
| bash -s -- --repo rossmacarthur/sheldon --to "$XDG_DATA_HOME/bin"
ln -s "$XDG_DATA_HOME/sheldon/bin/sheldon" "$HOME/.local/bin/sheldon"
echo "Rust is already installed, skipping the procedure"
fi

. "$CARGO_HOME/env"
cargo install sheldon
13 changes: 13 additions & 0 deletions scripts/setup-zeno.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -x
# shellcheck source=./scripts/common.bash
source "$(dirname "$0")/common.bash"

[ -n "$SKIP_DENO" ] && exit

echo "Installing Deno..."
curl -fsSL https://deno.land/x/install/install.sh | /bin/sh

echo "Install Deno completions..."
mkdir -p "$XDG_DATA_HOME/zsh/completions"
"$DENO_INSTALL/bin/deno" completions zsh >"$XDG_DATA_HOME/zsh/completions/_deno"
9 changes: 9 additions & 0 deletions scripts/setup.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -eux
# shellcheck source=./scripts/common.bash
source "$(dirname "$0")/common.bash"

/bin/bash "$CUR_DIR/setup-homebrew.bash"
/bin/bash "$CUR_DIR/setup-links.bash"
/bin/bash "$CUR_DIR/setup-deno.bash"
/bin/bash "$CUR_DIR/setup-sheldon.bash"

0 comments on commit d94bf11

Please sign in to comment.