Bump typescript from 5.6.3 to 5.7.2 #1079
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Node.js CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
node-version: [ 18.x ] | |
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ] | |
arch: [ x64, arm64 ] | |
exclude: | |
# https://github.com/xuxiaowei-com-cn/electron-tools/actions/runs/5128498312/jobs/9225241332 | |
# https://github.com/xuxiaowei-com-cn/electron-tools/actions/runs/5128523146/jobs/9225286730 | |
- arch: arm64 | |
os: ubuntu-latest | |
# https://github.com/xuxiaowei-com-cn/electron-tools/actions/runs/5128523146/jobs/9225286883 | |
# https://github.com/xuxiaowei-com-cn/electron-tools/actions/runs/5128534557/jobs/9225307705 | |
- arch: arm64 | |
os: windows-latest | |
env: | |
# npm 缓存路径 | |
NPM_CONFIG_CACHE: ~/.cache | |
# electron 缓存路径 | |
ELECTRON_CACHE: ~/.electron/cache | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Print Environment Variables | |
run: | | |
echo $NPM_CONFIG_CACHE | |
echo $ELECTRON_CACHE | |
- name: Use Node.js ${{ matrix.node-version }} !(macos-latest arm64) | |
uses: actions/setup-node@v3 | |
if: ${{ !(matrix.os == 'macos-latest' && matrix.arch == 'arm64') }} | |
with: | |
node-version: ${{ matrix.node-version }} | |
architecture: ${{ matrix.arch }} | |
# macos、arm64 默认为 node v18.16.0(不能设置 node-version 否则无法执行) | |
- name: Use Node.js ${{ matrix.node-version }} macos-latest arm64 | |
uses: actions/setup-node@v3 | |
if: ${{ matrix.os == 'macos-latest' && matrix.arch == 'arm64' }} | |
with: | |
architecture: ${{ matrix.arch }} | |
- name: Cache modules | |
uses: actions/cache@v3 | |
id: cache-modules | |
with: | |
path: | | |
~/.npm | |
~/.cache | |
~/.electron/cache | |
key: ${{ matrix.os }}-${{ hashFiles('package.json') }} | |
restore-keys: | | |
${{ matrix.os }}- | |
- run: node -v | |
- run: echo '' > .npmrc | |
- run: npm i | |
- run: npm run build | |
- name: electron:build (macos-latest x64) | |
if: ${{ matrix.os == 'macos-latest' && matrix.arch == 'x64' }} | |
run: | | |
npm run electron:build | |
- name: electron:build (macos-latest arm64) | |
if: ${{ matrix.os == 'macos-latest' && matrix.arch == 'arm64' }} | |
run: | | |
# 刪除特殊字符 | |
sed -i '' 's/\r$//' electron-builder.json5 | |
# 准备打包的文件命名方式 | |
echo 's/${productName}_${version}-${arch}.${ext}/${productName}_${version}-arm64.${ext}/' | |
# 修改为准备打包的文件命名方式 | |
sed -i '' 's/${productName}_${version}-${arch}.${ext}/${productName}_${version}-arm64.${ext}/' electron-builder.json5 | |
# 查看修改结果 | |
cat electron-builder.json5 | |
npm run electron:build | |
- name: electron:build (windows-latest) | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: | | |
npm run electron:build | |
- name: electron:build (ubuntu-latest) | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
cat electron-builder.json5 | |
# 增加 .rpm 产物 | |
sed -i '/"AppImage",/i \ \ \ \ \ \ "rpm",' electron-builder.json5 | |
# 增加 .deb 产物 | |
sed -i '/"AppImage",/i \ \ \ \ \ \ "deb",' electron-builder.json5 | |
cat electron-builder.json5 | |
npm run electron:build | |
- run: ls release | |
- name: Ubuntu ls release | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: ls release/*.*.* | |
- name: macOS ls release | |
if: ${{ matrix.os == 'macos-latest' }} | |
run: ls release/*.*.* | |
- name: Windows ls release | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: pwsh | |
run: Get-ChildItem -Path ./release/*/ -Directory | ForEach-Object { Get-ChildItem -Path $_.FullName } | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: electron-tools-${{ matrix.os }}-${{ matrix.arch }} | |
path: | | |
release/*/*.exe | |
release/*/*.exe.blockmap | |
release/*/*.dmg | |
release/*/*.dmg.blockmap | |
release/*/*.rpm | |
release/*/*.rpm.blockmap | |
release/*/*.deb | |
release/*/*.deb.blockmap | |
release/*/*.AppImage | |
release/*/*.AppImage.blockmap | |
release/*/*.tar.gz | |
release/*/*.tar.gz.blockmap | |
release/*/*.tar.xz | |
release/*/*.tar.xz.blockmap | |
release/*/alpha.yml | |
release/*/beta.yml | |
release/*/dev.yml | |
release/*/rc.yml | |
release/*/stable.yml | |
release/*/latest.yml | |
release/*/alpha-*.yml | |
release/*/beta-*.yml | |
release/*/dev-*.yml | |
release/*/rc-*.yml | |
release/*/stable-*.yml | |
release/*/latest-*.yml | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
# if: startsWith(github.ref, 'refs/heads/main') | |
steps: | |
- name: Get current date | |
id: date | |
# bash, sh, cmd, powershell, pwsh | |
# shell 类型必须为 sh,否则: | |
# $GITHUB_ENV:仅支持 ubuntu、macos | |
# $env:GITHUB_ENV:仅支持 windows | |
shell: sh | |
run: | | |
echo "YEAR_MONTH_DAY=$(date +'%Y-%m-%dZ')" >> $GITHUB_ENV | |
echo "YEAR_MONTH_DAY_HOUR=$(date +'%Y-%m-%dT%HZ')" >> $GITHUB_ENV | |
echo "YEAR_MONTH_DAY_HOUR_MINUTE=$(date +'%Y-%m-%dT%H-%MZ')" >> $GITHUB_ENV | |
- name: Download Artifacts electron-tools-ubuntu-latest-x64 | |
uses: actions/download-artifact@v4.1.7 | |
with: | |
name: electron-tools-ubuntu-latest-x64 | |
path: . | |
- run: ls *.*.* | |
- name: Download Artifacts electron-tools-windows-latest-x64 | |
uses: actions/download-artifact@v4.1.7 | |
with: | |
name: electron-tools-windows-latest-x64 | |
path: . | |
- run: ls *.*.* | |
- name: Download Artifacts electron-tools-macos-latest-arm64 | |
uses: actions/download-artifact@v4.1.7 | |
with: | |
name: electron-tools-macos-latest-arm64 | |
path: ./arm64 | |
- run: ls ./arm64/*.*.* | |
- run: cat ./arm64/*.*.*/latest-mac.yml | |
- run: ls *.*.* | |
- name: Download Artifacts electron-tools-macos-latest-x64 | |
uses: actions/download-artifact@v4.1.7 | |
with: | |
name: electron-tools-macos-latest-x64 | |
path: ./x64 | |
- run: ls ./x64/*.*.* | |
- run: cat ./x64/*.*.*/latest-mac.yml | |
- run: ls *.*.* | |
- run: (cat x64/*.*.*/latest-mac.yml | sed '/files:/q') > latest-mac.yml && cat arm64/*.*.*/latest-mac.yml | grep ' - url\| sha512\| size' >> latest-mac.yml && cat x64/*.*.*/latest-mac.yml | sed -n '/files:/,$p' | tail -n +2 >> latest-mac.yml | |
- run: cat latest-mac.yml | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: | | |
*/*.exe | |
*/*.exe.blockmap | |
*/*.dmg | |
*/*.dmg.blockmap | |
arm64/*/*.dmg | |
arm64/*/*.dmg.blockmap | |
x64/*/*.dmg | |
x64/*/*.dmg.blockmap | |
*/*.rpm | |
*/*.rpm.blockmap | |
*/*.deb | |
*/*.deb.blockmap | |
*/*.AppImage | |
*/*.AppImage.blockmap | |
*/*.tar.gz | |
*/*.tar.gz.blockmap | |
*/*.tar.xz | |
*/*.tar.xz.blockmap | |
*/alpha.yml | |
*/beta.yml | |
*/dev.yml | |
*/rc.yml | |
*/stable.yml | |
*/latest.yml | |
*/alpha-*.yml | |
*/beta-*.yml | |
*/dev-*.yml | |
*/rc-*.yml | |
*/stable-*.yml | |
*/latest-*.yml | |
latest-mac.yml | |
body: | |
自动推送时的发布 | |
# draft: 草稿状态,为 true 时,不创建标签,默认为 false | |
# draft: true | |
# prerelease:是否发布预发布版,默认为 false | |
prerelease: true | |
name: 1.0.0-${{ env.YEAR_MONTH_DAY_HOUR_MINUTE }} | |
tag: v1.0.0-${{ env.YEAR_MONTH_DAY_HOUR_MINUTE }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# https://docs.github.com/zh/enterprise-cloud@latest/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions | |
dependabot: | |
name: Dependabot | |
# 需要所有 build 完成后,才运行 | |
needs: build | |
runs-on: ${{ matrix.os }} | |
permissions: | |
# 可以修改仓库中的文件内容 | |
contents: write | |
# # 可以新建或修改 Pull Request | |
pull-requests: write | |
# 依赖机器人 && 仅PR | |
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }} | |
strategy: | |
matrix: | |
os: [ "ubuntu-latest" ] | |
steps: | |
# 检出代码 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
# 获取所有的代码历史记录,包括分支和标签 | |
fetch-depth: 0 | |
- name: Dependabot metadata | |
id: metadata | |
uses: dependabot/fetch-metadata@v1 | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
- name: echo | |
run: | | |
echo ${{ github.event.pull_request.html_url }} | |
echo ${{ steps.metadata.outputs.dependency-names }} | |
echo ${{ steps.metadata.outputs.update-type }} | |
echo ${{ 'version-update:semver-patch' }} | |
- name: Enable auto-merge for Dependabot PRs | |
# if: ${{contains(steps.metadata.outputs.dependency-names, 'my-dependency') && steps.metadata.outputs.update-type == 'version-update:semver-patch'}} | |
run: gh pr merge --auto --merge "$PR_URL" | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 将 main 分支代码同步到 极狐GitLab | |
- name: Sync JihuLab | |
run: | | |
git config --global user.email "xuxiaowei@xuxiaowei.com.cn" | |
git config --global user.name "徐晓伟" | |
# 设置 SSH 秘钥 | |
mkdir -p ~/.ssh | |
echo "${{ secrets.JIHULAB_ID_RSA }}" >> ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa | |
# 信任域名 | |
ssh-keyscan -H jihulab.com >> ~/.ssh/known_hosts | |
# 切换 main 分支 | |
git checkout main | |
# 拉取 main 分支 | |
git pull origin main | |
# 查看远端 极狐GitLab | |
echo git@jihulab.com:$GITHUB_REPOSITORY.git | |
# 添加远端 极狐GitLab | |
git remote add jihulab git@jihulab.com:$GITHUB_REPOSITORY.git | |
# 拉取 main 分支 | |
git pull --progress -v --no-rebase jihulab main | |
# 推送 main 分支 | |
git push --progress jihulab main:main | |
sync: | |
name: Sync | |
# 需要所有 build 完成后,才运行 | |
needs: build | |
# 仅在推送代码时执行 | |
if: github.event_name == 'push' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ "ubuntu-latest" ] | |
steps: | |
# 检出代码 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
# 获取所有的代码历史记录,包括分支和标签 | |
fetch-depth: 0 | |
# 将代码同步到 极狐GitLab | |
- name: Sync JihuLab | |
run: | | |
git config --global user.email "xuxiaowei@xuxiaowei.com.cn" | |
git config --global user.name "徐晓伟" | |
# 设置 SSH 秘钥 | |
mkdir -p ~/.ssh | |
echo "${{ secrets.JIHULAB_ID_RSA }}" >> ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa | |
# 信任域名 | |
ssh-keyscan -H jihulab.com >> ~/.ssh/known_hosts | |
# 查看当前分支 | |
echo 当前分支:$GITHUB_REF_NAME | |
# 查看远端 极狐GitLab | |
echo git@jihulab.com:$GITHUB_REPOSITORY.git | |
# 添加远端 极狐GitLab | |
git remote add jihulab git@jihulab.com:$GITHUB_REPOSITORY.git | |
# 拉取 | |
git pull --progress -v --no-rebase jihulab $GITHUB_REF_NAME | |
# 推送当前分支 | |
git push --progress jihulab $GITHUB_REF_NAME:$GITHUB_REF_NAME |