Skip to content

Commit 27c4135

Browse files
authored
Refactor GitHub Actions workflow for testing and deployment
Updated GitHub Actions workflow to use ioBroker testing actions and streamlined node version handling.
1 parent daa1ce2 commit 27c4135

File tree

1 file changed

+30
-69
lines changed

1 file changed

+30
-69
lines changed

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

Lines changed: 30 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,121 +5,82 @@ name: Test and Release
55
on:
66
push:
77
branches:
8-
- "*"
8+
- "main"
99
tags:
1010
# normal versions
1111
- "v[0-9]+.[0-9]+.[0-9]+"
1212
# pre-releases
1313
- "v[0-9]+.[0-9]+.[0-9]+-**"
1414
pull_request: {}
1515

16+
# Cancel previous PR/branch runs when a new commit is pushed
17+
concurrency:
18+
group: ${{ github.ref }}
19+
cancel-in-progress: true
20+
1621
jobs:
1722
# Performs quick checks before the expensive test runs
1823
check-and-lint:
1924
if: contains(github.event.head_commit.message, '[skip ci]') == false
2025

2126
runs-on: ubuntu-latest
2227

23-
strategy:
24-
matrix:
25-
node-version: [20.x]
26-
2728
steps:
28-
- name: Checkout code
29-
uses: actions/checkout@v5
30-
31-
- name: Use Node.js ${{ matrix.node-version }}
32-
uses: actions/setup-node@v5
29+
- uses: ioBroker/testing-action-check@v1
3330
with:
34-
node-version: ${{ matrix.node-version }}
35-
36-
- name: Install Dependencies
37-
run: npm ci
38-
- name: Lint source code
39-
run: npm run lint
40-
- name: Test package files
41-
run: npm run test:package
31+
node-version: "20.x"
32+
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
33+
# install-command: 'npm install'
34+
lint: true
4235

4336
# Runs adapter tests on all supported node versions and OSes
4437
adapter-tests:
4538
if: contains(github.event.head_commit.message, '[skip ci]') == false
4639

47-
needs: [check-and-lint]
48-
4940
runs-on: ${{ matrix.os }}
5041
strategy:
5142
matrix:
5243
node-version: [20.x, 22.x, 24.x]
5344
os: [ubuntu-latest, windows-latest, macos-latest]
5445

5546
steps:
56-
- name: Checkout code
57-
uses: actions/checkout@v5
58-
59-
- name: Use Node.js ${{ matrix.node-version }}
60-
uses: actions/setup-node@v5
47+
- uses: ioBroker/testing-action-adapter@v1
6148
with:
6249
node-version: ${{ matrix.node-version }}
50+
os: ${{ matrix.os }}
51+
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
52+
# install-command: 'npm install'
6353

64-
- name: Install Dependencies
65-
run: npm i
54+
# TODO: To enable automatic npm releases, create a token on npmjs.org
55+
# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
56+
# Then uncomment the following block:
6657

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-
# Deploys the final package to NPM
58+
# Deploys the final package to NPM
59+
# Deploys the final package to NPM and Github Actions
7960
deploy:
61+
# Define which jobst must succeed before the release
8062
needs: [adapter-tests]
81-
82-
# Trigger this step only when a commit on any branch is tagged with a version number
63+
64+
# Trigger this step only when a commit on master is tagged with a version number
8365
if: |
8466
contains(github.event.head_commit.message, '[skip ci]') == false &&
8567
github.event_name == 'push' &&
8668
startsWith(github.ref, 'refs/tags/v')
8769
8870
runs-on: ubuntu-latest
71+
8972
strategy:
9073
matrix:
9174
node-version: [20.x]
9275

76+
# Write permissions are required to create Github releases
9377
permissions:
9478
contents: write
9579
id-token: write
96-
80+
9781
steps:
98-
- name: Checkout code
99-
uses: actions/checkout@v5
100-
101-
- name: Use Node.js ${{ matrix.node-version }}
102-
uses: actions/setup-node@v5
82+
- uses: ioBroker/testing-action-deploy@v1
10383
with:
104-
node-version: ${{ matrix.node-version }}
105-
106-
- name: Extract the version and commit body from the tag
107-
id: extract_release
108-
# The body may be multiline, therefore newlines and % need to be escaped
109-
run: |
110-
VERSION="${{ github.ref }}"
111-
VERSION=${VERSION##*/v}
112-
echo "::set-output name=VERSION::$VERSION"
113-
BODY=$(git show -s --format=%b)
114-
BODY="${BODY//'%'/'%25'}"
115-
BODY="${BODY//$'\n'/'%0A'}"
116-
BODY="${BODY//$'\r'/'%0D'}"
117-
echo "::set-output name=BODY::$BODY"
118-
119-
# If you like, activate automated version publish to NPM
120-
# Only if commit contains a version, see : https://github.com/AlCalzone/release-script
121-
122-
- name: Publish package to npm
123-
run: |
124-
# npm whoami
125-
npm publish
84+
node-version: '20.x'
85+
github-token: ${{ secrets.AUTO_MERGE_TOKEN }}
86+
#

0 commit comments

Comments
 (0)