Publish NPM Package #2
Workflow file for this run
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: Publish NPM Package | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
push: | |
tags: | |
- v* | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
on-success: | |
needs: publish | |
runs-on: ubuntu-latest | |
if: ${{ always() && needs.publish.result == 'success' }} | |
steps: | |
- name: Notification Feishu | |
uses: whatwewant/action-robot-feishu@v0.0.13 | |
with: | |
url: ${{ secrets.NPM_VERSION_FEISHU_BOT_WEBHOOK_URL }} | |
title: '✅ NPM 发布:${{ github.repository }}' | |
text: | | |
分支: ${{ github.ref }} | |
提交信息: ${{ github.event.head_commit.message }} | |
提交人: ${{ github.actor }} | |
状态: 构建成功(https://github.com/${{ github.repository }}/actions/runs/${{ github.run.id }}) | |
on-failure: | |
needs: publish | |
runs-on: ubuntu-latest | |
if: ${{ always() && needs.publish.result == 'failure' }} | |
steps: | |
- name: Notification Feishu | |
uses: whatwewant/action-robot-feishu@v0.0.13 | |
with: | |
url: ${{ secrets.NPM_VERSION_FEISHU_BOT_WEBHOOK_URL }} | |
title: '❌ NPM 发布:${{ github.repository }}' | |
text: | | |
分支: ${{ github.ref }} | |
提交信息: ${{ github.event.head_commit.message }} | |
提交人: ${{ github.actor }} | |
状态: 构建失败(https://github.com/${{ github.repository }}/actions/runs/${{ github.run.id }}) | |
publish: | |
# bootstrap: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- name: Get Current Date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
- uses: oleksiyrudenko/gha-git-credentials@v2-latest | |
with: | |
token: '${{ secrets.GITHUB_TOKEN }}' | |
# Runs a single command using the runners shell | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14.x | |
registry-url: https://registry.npmjs.org | |
- name: Cache node_modules | |
uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Dependencies | |
run: yarn | |
- name: Make Build | |
run: yarn build | |
# - name: Make Testing | |
# run: yarn test | |
# - name: Make Coverage | |
# run: yarn coverage | |
- name: Before Publish | |
run: cp .npmrc.template .npmrc | |
- name: Make Publish | |
run: yarn publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |