chore: 调整更新脚本

This commit is contained in:
neo 2022-03-09 19:04:17 +08:00
parent 8115411d95
commit 815732c78d
2 changed files with 38 additions and 8 deletions

View File

@ -30,6 +30,7 @@ jobs:
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Set up Git repository
uses: actions/checkout@main
@ -39,6 +40,7 @@ jobs:
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
@ -48,6 +50,12 @@ jobs:
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: |
@ -57,6 +65,7 @@ jobs:
else
echo "/home/linuxbrew/.linuxbrew/bin:/usr/bin:/bin" >> "${GITHUB_PATH}"
fi
- name: Uninstall GitHub Actions Homebrew
run: |
if which brew &>/dev/null
@ -64,6 +73,7 @@ jobs:
/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}"
@ -72,6 +82,7 @@ jobs:
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
@ -88,11 +99,13 @@ jobs:
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
@ -101,11 +114,13 @@ jobs:
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

View File

@ -1,5 +1,5 @@
#!/usr/bin/env node
'use strict'
'use strict';
const path = require('path');
const chalk = require('chalk');
@ -10,7 +10,7 @@ const download = require('download-git-repo');
const cwd = process.cwd();
const origin = 'Homebrew/install';
const branch = "#master";
const branch = '#master';
const targetPath = path.join(cwd, 'lib');
@ -19,16 +19,27 @@ fsExtra.emptyDirSync(path.join(targetPath));
const spinner = ora(`downloading ${origin}...`);
spinner.start();
download(`${origin}${branch}`, targetPath, {clone: false}, function (err) {
download(`${origin}${branch}`, targetPath, { clone: false }, function(err) {
spinner.stop();
if (err) {
console.log(chalk.red(`Failed to download repo https://github.com/${origin}${branch}`, err));
console.log(
chalk.red(
`Failed to download repo https://github.com/${origin}${branch}`,
err,
),
);
} else {
console.log(chalk.green(`Success to download repo https://github.com/${origin}${branch}`));
console.log(
chalk.green(
`Success to download repo https://github.com/${origin}${branch}`,
),
);
try {
fsExtra.removeSync(path.join(targetPath, '.github/ISSUE_TEMPLATE'));
fsExtra.removeSync(path.join(targetPath, '.github/workflows/triage-issues.yml'));
fsExtra.removeSync(
path.join(targetPath, '.github/workflows/triage-issues.yml'),
);
fsExtra.removeSync(path.join(targetPath, '.github/ISSUE_TEMPLATE.md'));
fsExtra.removeSync(path.join(targetPath, 'install'));
@ -36,11 +47,15 @@ download(`${origin}${branch}`, targetPath, {clone: false}, function (err) {
fsExtra.removeSync(path.join(targetPath, 'LICENSE.txt'));
fsExtra.removeSync(path.join(targetPath, 'README.md'));
fsExtra.moveSync(path.join(targetPath, '.github'), path.join(cwd, '.github'), {overwrite: true});
fsExtra.moveSync(
path.join(targetPath, '.github/workflows/tests.yml'),
path.join(cwd, '.github/workflows/tests.yml'),
{ overwrite: true },
);
console.log(chalk.green('Done!'));
} catch (e) {
console.log(e.message);
}
}
})
});