Merge pull request #2 from ikenxuan/release-please--branches--main--c… #5
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
# 触发条件:当代码被推送到仓库时 | |
on: | |
push: | |
# 触发的分支:仅当推送到 main 分支时触发 | |
branches: | |
- main | |
# 工作流名称 | |
name: release-please | |
# 定义工作流中的各个任务 | |
jobs: | |
# 任务名称:release-please | |
release-please: | |
# 运行环境:Ubuntu 最新版本 | |
runs-on: ubuntu-latest | |
# 定义任务中的各个步骤 | |
steps: | |
# 步骤:使用 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: 'barcode-generator' | |
# 指定默认分支名称 | |
default-branch: main | |
# 步骤:检出代码 | |
- name: Checkout code | |
# 条件判断:仅当 release-please 步骤创建了发布时才执行此步骤 | |
if: steps.release-please.outputs.release_created == 'true' | |
# 使用 actions/checkout 动作 | |
uses: actions/checkout@v4 | |
# 步骤:设置 Node.js 环境 | |
- name: Setup Node.js | |
if: steps.release-please.outputs.release_created == 'true' | |
# 使用 actions/setup-node 动作 | |
uses: actions/setup-node@v4 | |
with: | |
# 指定 Node.js 版本为最新版本 | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
# 步骤:安装依赖,编译 | |
- name: Install, Build | |
if: steps.release-please.outputs.release_created == 'true' | |
run: | | |
npm install -g yarn | |
yarn install | |
yarn build | |
# 步骤:上传 | |
- 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: ./dist/barcode-generator.exe | |
asset_name: barcode-generator.exe | |
asset_content_type: application/octet-stream |