Use dirty ts. (#483) #862
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: 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 install npm@6.14.18 -g | |
name: Install legacy npm for correct dependency resolution | |
- 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}} |