-
Notifications
You must be signed in to change notification settings - Fork 94
169 lines (165 loc) · 5.32 KB
/
npmpublish.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
165
166
167
168
169
name: Node.js Package
on:
pull_request:
push:
branches:
- main
- master
- v[0-9]+
jobs:
test:
runs-on: ubuntu-latest
services:
couchdb:
image: couchdb
ports:
- 5984:5984
env:
COUCHDB_USER: ueberdb
COUCHDB_PASSWORD: ueberdb
elasticsearch:
image: elasticsearch:7.17.3
ports:
- 9200:9200
env:
discovery.type: single-node
mongo:
image: mongo
ports:
- 27017:27017
mysql:
# The default authentication used in MySQL 8.0 isn't supported by the
# mysql npm package: https://github.com/mysqljs/mysql/issues/2002
image: mariadb
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: ueberdb
MYSQL_PASSWORD: ueberdb
MYSQL_DATABASE: ueberdb
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: ueberdb
POSTGRES_PASSWORD: ueberdb
POSTGRES_DB: ueberdb
options: >-
--health-cmd="pg_isready -d postgresql://ueberdb:[email protected]/ueberdb"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis
ports:
- 6379:6379
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
-
uses: actions/setup-node@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm i
# Verify databases are reachable.
- name: MySQL client and server check
run: |
mysql --version &&
mysql -h 127.0.0.1 -u ueberdb -pueberdb -e "SHOW TABLES;" ueberdb
- name: PostgreSQL client and server check
run: |
psql --version &&
psql -d postgresql://ueberdb:[email protected]/ueberdb -c '\dt'
- name: Create javascript files from typescript
run: pnpm run build
- run: pnpm run test
env:
SURREALDB_CI: false
- run: pnpm run lint
publish-npm:
if: github.event_name == 'push'
needs:
- test
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v4
with:
fetch-depth: 0
-
uses: actions/setup-node@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# This is required if the package has a prepare script that uses something
# in dependencies or devDependencies. This is also needed for bumping the
# version.
-
run: pnpm i
# Workaround based on https://github.com/pnpm/pnpm/issues/3141
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
-
name: Bump version (patch)
run: |
LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1
NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1
[ "${NEW_COMMITS}" -gt 0 ] || exit 0
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
pnpm version patch
# Update the branch before pushing the tag in case the branch can't be
# fast-forwarded.
git push
git push --follow-tags
# `npm publish` must come after `git push` otherwise there is a race
# condition: If two PRs are merged back-to-back then master/main will be
# updated with the commits from the second PR before the first PR's
# workflow has a chance to push the commit generated by `npm version
# patch`. This causes the first PR's `git push` step to fail after the
# package has already been published, which in turn will cause all future
# workflow runs to fail because they will all attempt to use the same
# already-used version number. By running `npm publish` after `git push`,
# back-to-back merges will cause the first merge's workflow to fail but
# the second's will succeed.
-
name: Convert typescript and create dist folder
run: pnpm run build
-
run: pnpm publish
-
name: Add package to etherpad organization
run: npm access grant read-write etherpad:developers ueberdb2
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}