Skip to content

Commit

Permalink
Feature/tweak run once install package (#107)
Browse files Browse the repository at this point in the history
* macOS 環境上で CI を実行する
Fixes #104

* extract homebrew bundle install commands to a separate function

* change function name to plural

* use if statement

* remove macOS job
  • Loading branch information
kuwata0037 committed Aug 19, 2023
1 parent 9f5e8c9 commit 96ac2a8
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions run_once_install_packages.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

install_system_package() {
install_system_packages() {
if type apt-get >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y \
Expand Down Expand Up @@ -33,12 +33,23 @@ install_homebrew() {

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "You have already installed Homebrew."
fi
}

# Install bundle
type brew >/dev/null 2>&1 && brew bundle --global
test -d /opt/homebrew && /opt/homebrew/bin/brew bundle --global
test -d ~/.linuxbrew && ~/.linuxbrew/bin/brew bundle --global
test -d /home/linuxbrew/.linuxbrew && /home/linuxbrew/.linuxbrew/bin/brew bundle --global
install_homebrew_bundles() {
# Install bundle
if type brew >/dev/null 2>&1; then
brew bundle --global
elif test -d /opt/homebrew; then
/opt/homebrew/bin/brew bundle --global
elif test -d ~/.linuxbrew; then
~/.linuxbrew/bin/brew bundle --global
elif test -d /home/linuxbrew/.linuxbrew; then
/home/linuxbrew/.linuxbrew/bin/brew bundle --global
else
echo "Homebrew is not installed. Please install manually."
fi
}

Expand All @@ -50,7 +61,7 @@ install_rust() {
fi
}

install_cargo_subcommand() {
install_cargo_subcommands() {
if type ~/.cargo/bin/cargo >/dev/null 2>&1; then
curl -L --proto '=https' --tlsv1.2 -sSf \
https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
Expand Down Expand Up @@ -79,10 +90,11 @@ install_google_cloud_sdk() {
}

main() {
install_system_package
install_system_packages
install_homebrew
install_homebrew_bundles
install_rust
install_cargo_subcommand
install_cargo_subcommands
install_google_cloud_sdk
}

Expand Down

0 comments on commit 96ac2a8

Please sign in to comment.