-
Notifications
You must be signed in to change notification settings - Fork 17
94 lines (82 loc) · 3.07 KB
/
release-next.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Release NEXT Version
on:
workflow_dispatch:
inputs:
ref:
description: 'A valid ref, eg: v1.xx, main'
required: true
default: 'main'
jobs:
next-version:
name: Next Version
environment: next
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
# 判断用户是否有写权限
- name: 'Check if user has write access'
uses: 'opensumi/actions/permission-check@main'
with:
permission: 'write'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Checkout to specific branch
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- name: Get yarn cache directory path
id: yarn_cache_dir_path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn_cache
with:
path: ${{ steps.yarn_cache_dir_path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# 安装依赖并构建
- name: Install dependencies & Build
run: |
yarn install --immutable
yarn run init
- name: Setup .yarnrc.yml
run: |
yarn config set -H npmRegistryServer "https://registry.npmjs.org"
yarn config set -H npmAlwaysAuth true
yarn config set -H npmAuthToken $NPM_AUTH_TOKEN
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish prepatch version
run: |
lerna publish --exact --preid next-$(date +%s) --dist-tag next --force-publish='*' --no-push --no-git-tag-version prepatch --ignore-prepublish --ignore-scripts --no-private -y
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Adding markdown
if: success()
run: |
CURRENT_VERSION=$(node -p 'require("./lerna.json").version')
CURRENT_COMMIT=$(git rev-parse --short HEAD)
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
echo "CURRENT_COMMIT=${CURRENT_COMMIT}" >> $GITHUB_ENV
echo '### Released :rocket:' $CURRENT_VERSION >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo $CURRENT_VERSION >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'user input ref:' $INPUT_REF >> $GITHUB_STEP_SUMMARY
echo '```log' >> $GITHUB_STEP_SUMMARY
git log --oneline -1 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'SUMMARY<<EOF' >> $GITHUB_ENV
cat $GITHUB_STEP_SUMMARY >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
env:
INPUT_REF: ${{ github.event.inputs.ref }}