Skip to content

ci: 更新CI文件

ci: 更新CI文件 #9

Workflow file for this run

name: 🚀 Build and release
on:
push:
branches:
- master
jobs:
build_and_push:
runs-on: ubuntu-latest
outputs:
branch: v${{ steps.version.outputs.major }}
tag: v${{ steps.pack.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
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: 📦 Zip dist files
id: pack
uses: ./
with:
files: dist, action.yml
- name: ⚙️ Unzip dist files
run: |
mkdir TODEPLOY
unzip ${{ steps.pack.outputs.archive }} -d TODEPLOY
- name: ⚙️ Parse version string
id: version
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ steps.pack.outputs.version }}
- name: 📢 Publish dist files to dist branch
uses: s0/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: self
BRANCH: v${{ steps.version.outputs.major }}
FOLDER: TODEPLOY
SKIP_EMPTY_COMMITS: true
tag_version:
needs: build_and_push
runs-on: ubuntu-latest
outputs:
tagged: ${{ steps.check_tagged.outputs.tagged }}
tag: ${{ steps.tag.outputs.new_tag }}
steps:
- name: 🔃 Checkout dist branch
uses: actions/checkout@v2
with:
ref: ${{ needs.build_and_push.outputs.branch }}
fetch-depth: 0
- name: ⚙️ Check tag exists
id: check_tag
uses: mukunku/[email protected]
with:
tag: ${{ needs.build_and_push.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔖 Tag version
id: tag
if: ${{ steps.check_tag.outputs.exists == 'false' }}
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: ${{ needs.build_and_push.outputs.tag }}
- name: ⚙️ Check created tag
id: check_tagged
run: |
echo "::set-output name=tagged::${{ (steps.check_tag.outputs.exists == 'false') && (steps.tag.outputs.new_tag == steps.tag.outputs.tag) }}"
create_release:
needs: tag_version
if: ${{ needs.tag_version.outputs.tagged == 'true' }}
runs-on: ubuntu-latest
steps:
- name: 🛎️ Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.tag_version.outputs.tag }}
draft: true