Skip to content

Commit d9498f3

Browse files
committed
fixed adapter checker issues
1 parent 54c910b commit d9498f3

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

.github/workflows/test-and-deploy.yml

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Test and Release
2+
3+
# Run this job on all pushes and pull requests
4+
# as well as tags with a semantic version
5+
on:
6+
push:
7+
branches:
8+
- "*"
9+
tags:
10+
# normal versions
11+
- "v[0-9]+.[0-9]+.[0-9]+"
12+
# pre-releases
13+
- "v[0-9]+.[0-9]+.[0-9]+-**"
14+
pull_request: {}
15+
16+
jobs:
17+
# Performs quick checks before the expensive test runs
18+
check-and-lint:
19+
if: contains(github.event.head_commit.message, '[skip ci]') == false
20+
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
matrix:
25+
node-version: [18.x, 20.x, 22.x]
26+
27+
steps:
28+
- uses: actions/checkout@v1
29+
- name: Use Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- name: Install Dependencies
35+
run: npm ci
36+
37+
- name: Lint source code
38+
run: npm run lint
39+
- name: Test package files
40+
run: npm run test:package
41+
42+
# Runs adapter tests on all supported node versions and OSes
43+
adapter-tests:
44+
if: contains(github.event.head_commit.message, '[skip ci]') == false
45+
46+
needs: [check-and-lint]
47+
48+
runs-on: ${{ matrix.os }}
49+
strategy:
50+
matrix:
51+
node-version: [18.x, 20.x, 22.x]
52+
os: [ubuntu-latest, windows-latest, macos-latest]
53+
exclude:
54+
# Don't test Node.js 8 on Windows. npm is weird here
55+
- os: windows-latest
56+
node-version: 8.x
57+
steps:
58+
- uses: actions/checkout@v1
59+
- name: Use Node.js ${{ matrix.node-version }}
60+
uses: actions/setup-node@v1
61+
with:
62+
node-version: ${{ matrix.node-version }}
63+
64+
- name: Install Dependencies
65+
run: npm ci
66+
67+
- name: Run unit tests
68+
run: npm run test:unit
69+
70+
- name: Run integration tests (unix only)
71+
if: startsWith(runner.OS, 'windows') == false
72+
run: DEBUG=testing:* npm run test:integration
73+
74+
- name: Run integration tests (windows only)
75+
if: startsWith(runner.OS, 'windows')
76+
run: set DEBUG=testing:* & npm run test:integration
77+
78+
# TODO: To enable automatic npm releases, create a token on npmjs.org
79+
# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
80+
# Then uncomment the following block:
81+
82+
# Deploys the final package to NPM
83+
deploy:
84+
needs: [adapter-tests]
85+
86+
# Trigger this step only when a commit on master is tagged with a version number
87+
if: |
88+
contains(github.event.head_commit.message, '[skip ci]') == false &&
89+
github.event_name == 'push' &&
90+
startsWith(github.ref, 'refs/tags/v')
91+
runs-on: ubuntu-latest
92+
93+
steps:
94+
- name: Checkout code
95+
uses: actions/checkout@v4
96+
97+
- name: Use Node.js 18.x
98+
uses: actions/setup-node@v4
99+
with:
100+
node-version: 18.x
101+
102+
- name: Extract the version and commit body from the tag
103+
id: extract_release
104+
# The body may be multiline, therefore, we need to escape some characters
105+
run: |
106+
VERSION="${{ github.ref }}"
107+
VERSION=${VERSION##*/}
108+
VERSION=${VERSION##*v}
109+
echo "::set-output name=VERSION::$VERSION"
110+
BODY=$(git show -s --format=%b)
111+
BODY="${BODY//'%'/'%25'}"
112+
BODY="${BODY//$'\n'/'%0A'}"
113+
BODY="${BODY//$'\r'/'%0D'}"
114+
echo "::set-output name=BODY::$BODY"
115+
116+
- name: Publish package to npm
117+
run: |
118+
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
119+
npm whoami
120+
npx lerna publish from-package --yes
121+
122+
- name: Create Github Release
123+
uses: actions/create-release@v1
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
with:
127+
tag_name: ${{ github.ref }}
128+
release_name: Release v${{ steps.extract_release.outputs.VERSION }}
129+
draft: false
130+
# Prerelease versions create pre-releases on GitHub
131+
prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }}
132+
body: ${{ steps.extract_release.outputs.BODY }}
133+
134+
- name: Notify Sentry.io about the release
135+
run: |
136+
cd packages/admin
137+
npm i -g @sentry/cli
138+
export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
139+
export SENTRY_URL=https://sentry.iobroker.net
140+
export SENTRY_ORG=iobroker
141+
export SENTRY_PROJECT=iobroker-admin
142+
export SENTRY_VERSION=iobroker.admin@${{ steps.extract_release.outputs.VERSION }}
143+
export SENTRY_RELEASE=${{ steps.extract_release.outputs.VERSION }}
144+
sentry-cli releases new $SENTRY_VERSION
145+
sentry-cli releases finalize $SENTRY_VERSION
146+
sentry-cli sourcemaps inject ./adminWww
147+
sentry-cli sourcemaps upload ./adminWww
148+
149+
# Dummy job for skipped builds - without this, github reports the build as failed
150+
skip-ci:
151+
if: contains(github.event.head_commit.message, '[skip ci]')
152+
runs-on: ubuntu-latest
153+
steps:
154+
- name: Skip build
155+
run: echo "Build skipped!"

0 commit comments

Comments
 (0)