-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (140 loc) · 4.47 KB
/
publish-package.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Publish unplugin-lit sass
run-name: Release ${{ inputs.releaseLevel }} version
on:
workflow_dispatch:
inputs:
releaseLevel:
description: "Release level"
required: true
default: patch
type: choice
options:
- major
- minor
- patch
- preup
isPre:
description: "Is New pre-release (exp: X.X.X-beta.0)"
required: false
type: boolean
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
pull-requests: write
id-token: write
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=8192
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set git config
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
registry-url: "https://registry.npmjs.org/"
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 9.1.0
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node Dependencies
run: pnpm install --frozen-lockfile
- name: Set .npmrc
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > packages/unplugin/.npmrc
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > packages/core/.npmrc
- name: Set pre value
id: pre
run: |
if [[ "${{ inputs.isPre }}" == "true" ]]; then
echo "pre=--pre" >> $GITHUB_OUTPUT
else
echo "pre=" >> $GITHUB_OUTPUT
fi
- name: Release
id: release
run: |
pnpm p:release build && pnpm release:package -l ${{ inputs.releaseLevel }} ${{ steps.pre.outputs.pre }}
shell: bash
- name: Create PR
id: create-pr
run: |
gh pr create \
-B main \
-t ":bookmark: Update package.json" \
-a "${{ github.actor }}" \
-F ./.github/pull_request_template.md
create-github-release:
needs: release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set git config
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
registry-url: "https://registry.npmjs.org/"
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 9.1.0
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node Dependencies
run: pnpm install --frozen-lockfile
- name: Get Current package info
id: get-package-info
run: |
echo "PACKAGE_VERSION=$(pnpm view unplugin-lit-sass version)" >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: create-release
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ steps.get-package-info.outputs.PACKAGE_VERSION }}
prerelease: ${{ contains(steps.get-package-info.outputs.PACKAGE_VERSION, '-beta') }}