Skip to content

后端支持上传失败时自动切换其他渠道重试 #24

后端支持上传失败时自动切换其他渠道重试

后端支持上传失败时自动切换其他渠道重试 #24

Workflow file for this run

name: NodeJS with Webpack
on:
push:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Build
run: |
npm install
npm run build
- name: Package and upload Artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: "./dist"
# 获取提交信息和当前日期
- name: Get Commit Info
id: get_commit_info
run: |
echo "commit_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "commit_message=$(git log -1 --pretty=%B)" >> $GITHUB_ENV
echo "release_date=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
# 将 dist 文件夹打包成 zip
- name: Zip dist folder
run: |
zip -r dist-v1.0.${{ github.run_number }}.zip ./dist
# 创建 Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v1.0.${{ github.run_number }} # 使用工作流运行次数作为版本号
release_name: "Release v1.0.${{ github.run_number }} - ${{ env.release_date }}" # 包含版本号和日期的名称
body: |
### Release Notes
- **Commit SHA**: ${{ env.commit_sha }}
- **Commit Message**: ${{ env.commit_message }}
- **Release Date**: ${{ env.release_date }}
draft: false
prerelease: false
# 上传构建产物到 Release
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist-v1.0.${{ github.run_number }}.zip
asset_name: dist-v1.0.${{ github.run_number }}.zip # 动态生成上传文件名称
asset_content_type: application/zip