ci: 修改tag命名错误 #19
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
name: Create Release with Zip | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
persist-credentials: false | |
# otherwise, there would be errors pushing refs to the destination repository. | |
fetch-depth: 0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
# 选择要使用的 pnpm 版本 | |
version: 7 | |
# 使用 pnpm 安装依赖 | |
run_install: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
# 选择要使用的 node 版本 | |
node-version: 16.14.2 | |
# 缓存 pnpm 依赖 | |
cache: pnpm | |
# 运行构建脚本 | |
- name: Build tasks | |
run: npm run build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get package.json info | |
id: get_package_info | |
run: | | |
echo "name=$(jq -r .name package.json)" >> "$GITHUB_ENV" | |
echo "version=$(jq -r .version package.json)" >> "$GITHUB_ENV" | |
echo "time=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_ENV" | |
- name: Zip dist/index.js | |
run: zip -r dist/index.zip dist/index.js | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.version }}_${{env.time}} | |
release_name: ${{ env.name }} v${{ env.version }} | |
body: New release | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: dist/index.zip | |
asset_name: index.zip | |
asset_content_type: application/zip |