diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index d8175854..e3014385 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -5,8 +5,7 @@ name: Test and Release on: push: branches: - # This avoids having duplicate builds in non-forked PRs - - "master" + - master tags: # normal versions - "v[0-9]+.[0-9]+.[0-9]+" @@ -21,37 +20,18 @@ jobs: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x] - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - uses: ioBroker/testing-action-check@v1 with: - node-version: ${{ matrix.node-version }} + node-version: '14.x' + type-checking: true + lint: true - - name: Install Dependencies - run: npm ci - - - name: Perform a type check - run: npm run check:ts - env: - CI: true - # - name: Lint TypeScript code - # run: npm run lint - - name: Test package files - run: npm run test:package # Runs adapter tests on all supported node versions and OSes adapter-tests: if: contains(github.event.head_commit.message, '[skip ci]') == false - needs: [check-and-lint] - runs-on: ${{ matrix.os }} strategy: matrix: @@ -59,31 +39,17 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - uses: ioBroker/testing-action-adapter@v1 with: node-version: ${{ matrix.node-version }} + os: ${{ matrix.os }} + build: true + extra-tests: 'npm run test:ts' - - name: Install Dependencies - run: npm ci - - - name: Run local tests - run: npm test - - name: Run unit tests - run: npm run test:unit - - name: Run integration tests (unix only) - if: startsWith(runner.OS, 'windows') == false - run: DEBUG=testing:* npm run test:integration - - name: Run integration tests (windows only) - if: startsWith(runner.OS, 'windows') - run: set DEBUG=testing:* & npm run test:integration # Deploys the final package to NPM deploy: - needs: [adapter-tests] + needs: [check-and-lint, adapter-tests] # Trigger this step only when a commit on any branch is tagged with a version number if: | @@ -92,52 +58,11 @@ jobs: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x] steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Extract the version and commit body from the tag - id: extract_release - # The body may be multiline, therefore we need to escape some characters - run: | - VERSION="${{ github.ref }}" - VERSION=${VERSION##*/v} - echo "::set-output name=VERSION::$VERSION" - BODY=$(git show -s --format=%b) - BODY="${BODY//'%'/'%25'}" - BODY="${BODY//$'\n'/'%0A'}" - BODY="${BODY//$'\r'/'%0D'}" - echo "::set-output name=BODY::$BODY" - - - name: Install Dependencies - run: npm ci - - - name: Create a clean build - run: npm run build - - - name: Publish package to npm - run: | - npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - npm whoami - npm publish - - - name: Create Github Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: ioBroker/testing-action-deploy@v1 with: - tag_name: ${{ github.ref }} - release_name: Release v${{ steps.extract_release.outputs.VERSION }} - draft: false - # Prerelease versions create prereleases on Github - prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }} - body: ${{ steps.extract_release.outputs.BODY }} + node-version: "14.x" # This should be LTS + build: 'true' + npm-token: ${{ secrets.NPM_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index fe4bc6ef..143908cc 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "prebuild": "rimraf ./build", "build:react": "node .build.js -react", "build:ts": "node .build.js -typescript", - "check:ts": "tsc -p tsconfig.build.json --noEmit", + "check": "tsc -p tsconfig.build.json --noEmit", "build": "node .build.js -typescript -react", "watch:react": "npm run build:react -- --watch", "watch:ts": "npm run build:ts -- --watch",