Merge pull request #215 from rowthan/dev #265
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: release packages | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
- 'feat*' | |
# pull_request: | |
# branches: | |
# - main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: Production | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: dependencies cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
~/.cache | |
~/node_modules | |
key: ${{ runner.os }}-dependencies-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: ${{ runner.os }}-dependencies- | |
- name: Yarn install | |
run: yarn install | |
- name: Run Packages Tests | |
run: | | |
ls -la | |
yarn run test | |
# - name: Build Packages | |
# run: | | |
# yarn build | |
- name: Set Git Identity | |
run: | | |
git restore yarn.lock | |
git status | |
git config --global user.name "${{ github.actor }}" | |
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | |
#https://github.com/lerna/lerna/tree/main/libs/commands/version#semver-bump | |
# 开发阶段的版本号 预发布 | |
- name: Lerna feature Version | |
if: startsWith(github.ref, 'refs/heads/feat') && contains(github.event.head_commit.message, 'bookmark') | |
run: | | |
npx lerna version prerelease --preid next --conventional-commits --no-private --conventional-prerelease --yes | |
# 修订版本号 | |
- name: Lerna dev Version | |
if: github.ref =='refs/heads/dev' && contains(github.event.head_commit.message, 'bookmark') | |
run: | | |
npx lerna version --conventional-commits --loglevel debug --no-private patch --yes | |
# 正式发布 | |
- name: Lerna main Version | |
if: github.ref == 'refs/heads/main' | |
run: | | |
npx lerna version --conventional-commits --no-private minor --yes | |
- name: Create .npmrc | |
run: echo 'registry=https://registry.npmjs.org' > ~/.npmrc && echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> ~/.npmrc | |
# https://github.com/lerna/lerna/tree/main/libs/commands/publish#readme | |
- name: Publish to NPM | |
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/feat') | |
run: | | |
npm config set registry https://registry.npmjs.org | |
npm whoami | |
npx lerna publish from-git --yes | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |