-
Notifications
You must be signed in to change notification settings - Fork 95
139 lines (135 loc) · 4.23 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
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:ueberdb@127.0.0.1/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@v3
with:
node-version: 20
- run: npm ci
# 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:ueberdb@127.0.0.1/ueberdb -c '\dt'
- name: Create javascript files from typescript
run: npm run build
- run: npm test
env:
SURREALDB_CI: false
- run: npm 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@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: 'npm'
# 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: npm ci
-
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'
npm 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: npm run build
-
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
-
name: Add package to etherpad organization
run: npm access grant read-write etherpad:developers ueberdb2
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}