Skip to content

支持课程问卷获取 #206

支持课程问卷获取

支持课程问卷获取 #206

name: Build and Publish
on: [push, pull_request]
env:
YARN_ENABLE_GLOBAL_CACHE: false
jobs:
build:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Get the Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
with:
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
restore-keys: |
${{runner.os}}-yarn-
- name: Install dependencies
run: corepack yarn install --immutable
- name: Lint
run: corepack yarn lint
- name: Build library
run: corepack yarn build
- name: Build demo extension
run: corepack yarn dev:build
- name: Show files to publish
run: npm publish --dry-run
- name: Upload built library
uses: actions/upload-artifact@v4
with:
name: thu-learn-lib
path: lib/
- name: Upload built demo extension
uses: actions/upload-artifact@v4
with:
name: thu-learn-lib-demo
path: dist/
publish-to-npm:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v4
- name: Download build result
uses: actions/download-artifact@v4
with:
name: thu-learn-lib
path: lib/
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}