mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-04-06 03:58:05 +08:00
127 lines
3.7 KiB
YAML
127 lines
3.7 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
jobs:
|
|
tests:
|
|
strategy:
|
|
matrix:
|
|
os:
|
|
- macOS-latest
|
|
- ubuntu-latest
|
|
- windows-latest
|
|
include:
|
|
- os: macOS-latest
|
|
shell: bash
|
|
- os: ubuntu-latest
|
|
shell: bash
|
|
- os: windows-latest
|
|
shell: "wsl-bash {0}"
|
|
runs-on: ${{matrix.os}}
|
|
defaults:
|
|
run:
|
|
shell: ${{ matrix.shell }}
|
|
steps:
|
|
- name: Set up WSL
|
|
if: runner.os == 'windows'
|
|
shell: powershell
|
|
run: |
|
|
git config --global core.autocrlf false
|
|
git config --global core.eol lf
|
|
|
|
- name: Set up Git repository
|
|
uses: actions/checkout@main
|
|
|
|
- name: Cleanup macOS
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
sudo rm -rf /Applications/Xcode.app \
|
|
/Library/Developer/CommandLineTools
|
|
sudo xcode-select --reset
|
|
|
|
- name: Install WSL
|
|
if: runner.os == 'windows'
|
|
# https://github.com/Vampire/setup-wsl/releases/tag/v1.1.0
|
|
uses: Vampire/setup-wsl@c8afb39d908a55f133accd98a27e160edc255810
|
|
with:
|
|
distribution: Ubuntu-16.04
|
|
wsl-shell-user: runner
|
|
additional-packages: build-essential
|
|
|
|
- name: Check Bash 3.x syntax
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
/bin/bash -u -n install.sh
|
|
/bin/bash -u -O extglob -n uninstall.sh
|
|
|
|
- name: Set up Homebrew PATH
|
|
if: runner.os != 'windows'
|
|
run: |
|
|
if [[ "${{ runner.os }}" = "macOS" ]]
|
|
then
|
|
echo "/usr/local/bin:/usr/bin:/bin" >> "${GITHUB_PATH}"
|
|
else
|
|
echo "/home/linuxbrew/.linuxbrew/bin:/usr/bin:/bin" >> "${GITHUB_PATH}"
|
|
fi
|
|
|
|
- name: Uninstall GitHub Actions Homebrew
|
|
run: |
|
|
if which brew &>/dev/null
|
|
then
|
|
/bin/bash uninstall.sh -n >/dev/null
|
|
/bin/bash uninstall.sh -f >/dev/null
|
|
fi
|
|
|
|
- name: Set up WSL environment
|
|
if: runner.os == 'windows'
|
|
shell: "wsl-bash -u root {0}"
|
|
run: |
|
|
echo "runner ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/runner
|
|
chmod 644 /etc/sudoers.d/runner
|
|
echo -e "#!/bin/bash\nexec /home/linuxbrew/.linuxbrew/bin/brew \"\$@\"" | tee /usr/local/bin/brew
|
|
chmod 755 /usr/local/bin/brew
|
|
|
|
- run: /bin/bash -c "$(cat install.sh)"
|
|
|
|
- run: brew config
|
|
|
|
- run: brew install ack
|
|
|
|
- run: /bin/bash uninstall.sh -f >/dev/null
|
|
|
|
- name: Install Homebrew with non-default remotes
|
|
# Use the default remotes but with Git Protocol
|
|
run: |
|
|
HOMEBREW_BREW_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/brew"
|
|
HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
|
|
export HOMEBREW_BREW_GIT_REMOTE="${HOMEBREW_BREW_DEFAULT_GIT_REMOTE/#https/git}"
|
|
export HOMEBREW_CORE_GIT_REMOTE="${HOMEBREW_CORE_DEFAULT_GIT_REMOTE/#https/git}"
|
|
/bin/bash -c "$(cat install.sh)"
|
|
|
|
- run: brew config
|
|
|
|
- run: |
|
|
/bin/bash uninstall.sh -f >/dev/null
|
|
unset HOMEBREW_{BREW,CORE}{,_DEFAULT}_GIT_REMOTE
|
|
|
|
- run: /bin/bash -c "$(cat install.sh)"
|
|
|
|
- name: Uninstall and reinstall with sudo NOPASSWD
|
|
if: runner.os == 'linux'
|
|
run: |
|
|
echo "${USER} ALL=(ALL) NOPASSWD:ALL" | sudo tee "/etc/sudoers.d/${USER}"
|
|
/bin/bash uninstall.sh -f >/dev/null
|
|
/bin/bash -c "$(cat install.sh)"
|
|
|
|
- name: Check code styles
|
|
if: runner.os != 'windows'
|
|
run: |
|
|
brew install shellcheck shfmt diffutils
|
|
brew style *.sh
|
|
|
|
- run: /bin/bash uninstall.sh -n >/dev/null
|
|
|
|
- run: /bin/bash uninstall.sh -f >/dev/null
|