mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-06-24 21:39:15 +08:00
103 lines
2.9 KiB
YAML
103 lines
2.9 KiB
YAML
name: GitHub Actions 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: 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
|
|
|
|
- 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)"
|
|
|
|
- run: brew install shellcheck
|
|
|
|
- run: shellcheck *.sh
|
|
if: runner.os != 'windows'
|
|
|
|
- run: /bin/bash uninstall.sh -n >/dev/null
|
|
|
|
- run: /bin/bash uninstall.sh -f >/dev/null
|