83 lines
2.2 KiB
YAML
83 lines
2.2 KiB
YAML
name: 构建并发布应用
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
name: 构建和发布
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 设置Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: 安装pnpm
|
|
uses: pnpm/action-setup@v3
|
|
with:
|
|
version: 8
|
|
|
|
- name: 安装前端依赖
|
|
run: pnpm install
|
|
|
|
- name: 显示依赖包信息
|
|
run: |
|
|
ls -la node_modules/aplayer
|
|
ls -la node_modules/APlayer || echo "大写的APlayer不存在"
|
|
|
|
- name: 构建前端
|
|
run: pnpm run build
|
|
|
|
- name: 设置Go环境
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.21'
|
|
|
|
- name: 安装UPX
|
|
run: sudo apt-get update && sudo apt-get install -y upx
|
|
|
|
- name: 构建应用
|
|
run: bash build.auto.release.sh -full
|
|
|
|
- name: 显示构建产物
|
|
run: |
|
|
ls -la
|
|
find . -name "miao-directory*" -type f
|
|
|
|
- name: 上传构建产物
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: miao-directory-all
|
|
path: |
|
|
**/miao-directory*
|
|
|
|
- name: 生成版本号
|
|
id: version
|
|
run: |
|
|
echo "date=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
|
|
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: 创建自动发布
|
|
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: Auto-Build-${{ steps.version.outputs.date }}-${{ steps.version.outputs.sha_short }}
|
|
tag_name: auto-${{ steps.version.outputs.date }}-${{ steps.version.outputs.sha_short }}
|
|
draft: false
|
|
prerelease: false
|
|
files: |
|
|
**/miao-directory*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |