2024-05-11 07:03:56 +08:00
# 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
2024-05-11 11:44:49 +08:00
name : halo-theme-dream2.0-plus CI
2024-05-11 07:03:56 +08:00
on :
push :
2024-05-11 10:59:55 +08:00
branches : [ "master" , "dev" ]
2024-05-11 09:53:14 +08:00
paths : [ "version" ]
2024-05-11 07:03:56 +08:00
jobs :
build :
2024-07-11 10:01:47 +08:00
runs-on : ubuntu-latest
2024-05-11 07:03:56 +08:00
strategy :
matrix :
2024-07-11 10:01:47 +08:00
node-version : [ 18. x]
2024-05-11 07:03:56 +08:00
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps :
2024-05-11 11:08:04 +08:00
# 迁出代码
2024-05-11 07:03:56 +08:00
- uses : actions/checkout@v4
2024-05-11 11:08:04 +08:00
# 确定构建分支类型
2024-05-11 10:59:55 +08:00
- name : Determine Branch Type
id : determine_branch_type
run : |
branch_type=unknown
if [[ $GITHUB_REF == refs/heads/master ]]; then
branch_type=master
elif [[ $GITHUB_REF == refs/heads/dev ]]; then
branch_type=dev
fi
2024-05-11 11:19:51 +08:00
echo "branch_type=$branch_type" >> $GITHUB_ENV
2024-05-11 10:59:55 +08:00
shell : bash
2024-05-11 11:08:04 +08:00
# 确定构建版本
2024-05-11 09:53:14 +08:00
- name : version
id : version
run : |
2024-05-11 09:59:04 +08:00
version=$(cat version)
2024-05-11 09:53:14 +08:00
echo "version=$version" >> $GITHUB_ENV
2024-05-11 07:03:56 +08:00
- name : Use Node.js ${{ matrix.node-version }}
2024-05-11 08:07:20 +08:00
uses : actions/setup-node@v4
2024-05-11 07:03:56 +08:00
with :
node-version : ${{ matrix.node-version }}
cache : 'npm'
2024-05-11 07:07:41 +08:00
- name : Install dependencies
2024-05-11 07:08:21 +08:00
run : npm install
2024-05-11 09:27:49 +08:00
# Actions构建
2024-05-11 07:18:27 +08:00
- name : Build
2024-05-11 09:53:14 +08:00
run : npm run actions --tag=${{ env.version }}
2024-05-11 10:15:05 +08:00
2024-05-11 10:42:40 +08:00
# 上传构建产物zip
- name : Upload artifacts
uses : actions/upload-artifact@v4
with :
name : halo-theme-dream2.0-plus
2024-05-17 08:16:26 +08:00
path : dist-actions
2024-05-11 10:42:40 +08:00
2024-05-11 11:08:04 +08:00
# 如果是master分支, 创建Release
2024-05-11 10:15:05 +08:00
- name : Create Release
2024-05-11 11:18:06 +08:00
if : ${{ env.branch_type == 'master' }}
2024-05-11 10:15:05 +08:00
id : create_release
uses : actions/create-release@latest
env :
2024-05-11 10:26:14 +08:00
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2024-05-11 10:15:05 +08:00
with :
2024-05-11 10:45:49 +08:00
tag_name : ${{ env.version }}
release_name : ${{ env.version }}
2024-05-11 10:15:05 +08:00
body : ${{ github.event.commits[0].message }}
draft : false
prerelease : false
2024-05-11 11:08:04 +08:00
# 如果是master分支, 创建Release Asset
2024-05-11 10:15:05 +08:00
- name : Upload Release Asset
2024-05-11 11:18:06 +08:00
if : ${{ env.branch_type == 'master' }}
2024-05-11 10:15:05 +08:00
uses : dwenegar/upload-release-assets@v1
env :
2024-05-11 10:26:14 +08:00
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2024-05-11 07:34:18 +08:00
with :
2024-05-11 11:37:49 +08:00
release_id : ${{ steps.create_release.outputs.id }}
2024-05-11 10:15:05 +08:00
assets_path : |
2024-05-17 08:10:23 +08:00
dist