chore(main): release 4.4.19 (#116) #377
This file contains hidden or 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
# 触发条件:当代码被推送到仓库时 | |
on: | |
push: | |
# 触发的分支:仅当推送到 main 分支时触发 | |
branches: | |
- main | |
# 工作流名称 | |
name: release-please | |
# 定义工作流中的各个任务 | |
jobs: | |
# 任务名称:release-please | |
release-please: | |
# 运行环境:Ubuntu 最新版本 | |
runs-on: ubuntu-latest | |
# 定义任务中的各个步骤 | |
steps: | |
# 步骤:检出代码 | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# 步骤:设置 Node.js 环境 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
# 指定 Node.js 版本为最新版本 | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org' | |
# 步骤:安装依赖,编译 | |
- name: Install, Build | |
run: | | |
npm install | |
npm run build | |
# 步骤:使用 Google 的 release-please-action 动作 | |
- name: Create Release | |
uses: google-github-actions/release-please-action@v3 | |
# 为这个步骤指定一个标识符,方便后续引用 | |
id: release-please | |
with: | |
# 指定发布类型为 Node.js 项目 | |
release-type: node | |
# 指定要发布的包名 | |
package-name: '@ikenxuan/amagi' | |
# 指定默认分支名称 | |
default-branch: main | |
# 步骤:获取版本号 | |
- name: Get version | |
if: steps.release-please.outputs.release_created == 'true' | |
id: get_version | |
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
# 步骤:压缩文件 | |
- name: Compress files | |
if: steps.release-please.outputs.release_created == 'true' | |
run: | | |
npm pack | |
zip -r amagi-build-${{ env.VERSION }}.zip dist README.md package.json LICENSE | |
# 步骤:上传 ZIP 发布资产 | |
- name: Upload ZIP release asset | |
if: steps.release-please.outputs.release_created == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.release-please.outputs.upload_url }} | |
asset_path: ./amagi-build-${{ env.VERSION }}.zip | |
asset_name: amagi-build-${{ env.VERSION }}.zip | |
asset_content_type: application/zip | |
# 步骤:上传 TGZ 发布资产 | |
- name: Upload TGZ release asset | |
if: steps.release-please.outputs.release_created == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.release-please.outputs.upload_url }} | |
asset_path: ./ikenxuan-amagi-${{ env.VERSION }}.tgz | |
asset_name: amagi-source-${{ env.VERSION }}.tgz | |
asset_content_type: application/octet-stream | |
- run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 发布到 npm | |
if: ${{ steps.release-please.outputs.release_created }} |