Skip to content

Commit 96d122c

Browse files
committed
Working cross-platform setup for CI, snapshot releases as well as tagged releases
1 parent 760c0bd commit 96d122c

File tree

4 files changed

+209
-11
lines changed

4 files changed

+209
-11
lines changed

.build/pre-release.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env bash
22
set -ex
33

4-
echo "snapshot release"
4+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
5+
npm whoami
56

6-
#npm ci
7-
#patchVersion=$(npm --no-git-tag version patch)
8-
#nextVersion=${patchVersion}-next."$(date +%Y%m%d%H%M%S)"
9-
#echo "${nextVersion:1}"
10-
#
11-
#npm version --no-git-tag -f "${nextVersion:1}"
12-
#npm run publish-next
7+
npm ci
8+
patchVersion=$(npm --no-git-tag version patch)
9+
nextVersion=${patchVersion}-next."$(date +%Y%m%d%H%M%S)"
10+
echo "${nextVersion:1}"
11+
12+
npm version --no-git-tag -f "${nextVersion:1}"
13+
npm run publish-next

.github/workflows/ci.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Run CI
2+
on:
3+
push:
4+
branches-ignore:
5+
- develop
6+
- release/**
7+
pull_request:
8+
9+
jobs:
10+
sonar:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Set up Git repository
14+
uses: actions/checkout@v2
15+
- name: Set up node
16+
uses: actions/setup-node@v2
17+
with:
18+
node-version: 14
19+
- name: Setup sonarqube
20+
uses: warchant/setup-sonar-scanner@v3
21+
- name: Setup Docker
22+
run: |
23+
docker pull s1hofmann/nut-ci:latest
24+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
25+
- name: Install
26+
run: npm ci
27+
- name: Compile
28+
run: npm run compile
29+
- name: Init e2e test subpackage
30+
run: npm --prefix e2e/tests ci
31+
- name: Clean coverage report
32+
run: npm run coverage:clean
33+
- name: Generate coverage report
34+
uses: GabrielBB/xvfb-action@v1
35+
with:
36+
run: npm run coverage -- --coverageDirectory=coverage/unit
37+
- name: Run Docker E2E tests
38+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} 14"
39+
- name: Merge coverage reports
40+
run: |
41+
npm run coverage:merge
42+
npm run coverage:merge-report
43+
- name: Run sonarqube
44+
env:
45+
# to get access to secrets.SONAR_TOKEN, provide GITHUB_TOKEN
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: sonar-scanner
48+
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
49+
-Dsonar.organization=nut-tree
50+
-Dsonar.host.url=https://sonarcloud.io/
51+
-Dsonar.projectKey=nut-tree:nut.js
52+
53+
test:
54+
needs:
55+
- sonar
56+
strategy:
57+
matrix:
58+
os: [ ubuntu-latest, windows-latest, macos-latest ]
59+
node: [ 10, 11, 12, 13, 14 ]
60+
exclude:
61+
- os: ubuntu-latest
62+
node: 14
63+
runs-on: ${{matrix.os}}
64+
steps:
65+
- name: Set up Git repository
66+
uses: actions/checkout@v2
67+
- name: Set up node
68+
uses: actions/setup-node@v2
69+
with:
70+
node-version: 14
71+
- name: Setup Docker
72+
if: ${{matrix.os == 'ubuntu-latest'}}
73+
run: |
74+
docker pull s1hofmann/nut-ci:latest
75+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
76+
- name: Install
77+
run: npm ci
78+
- name: Compile
79+
run: npm run compile
80+
- name: Init e2e test subpackage
81+
run: npm --prefix e2e/tests ci
82+
- name: Generate coverage report
83+
uses: GabrielBB/xvfb-action@v1
84+
with:
85+
run: npm run coverage -- --coverageDirectory=coverage/unit
86+
- name: Run Docker E2E tests
87+
if: ${{matrix.os == 'ubuntu-latest'}}
88+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} 14"

.github/workflows/snapshot.yaml renamed to .github/workflows/snapshot_release.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Create snapshot release
2-
on: [push]
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
37
jobs:
48
sonar:
59
runs-on: ubuntu-latest
@@ -49,7 +53,7 @@ jobs:
4953
- sonar
5054
strategy:
5155
matrix:
52-
os: [ macos-latest ]
56+
os: [ ubuntu-latest, windows-latest, macos-latest ]
5357
node: [ 10, 11, 12, 13, 14 ]
5458
exclude:
5559
- os: ubuntu-latest
@@ -93,5 +97,7 @@ jobs:
9397
uses: actions/setup-node@v2
9498
with:
9599
node-version: 14
96-
- name: Release Snapshot
100+
- name: Publish snapshot release
97101
run: bash ./.build/pre-release.sh
102+
env:
103+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/tagged_release.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Create tagged release
2+
on:
3+
push:
4+
tags:
5+
- v*.*.*
6+
7+
jobs:
8+
sonar:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Set up Git repository
12+
uses: actions/checkout@v2
13+
- name: Set up node
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: 14
17+
- name: Setup sonarqube
18+
uses: warchant/setup-sonar-scanner@v3
19+
- name: Setup Docker
20+
run: |
21+
docker pull s1hofmann/nut-ci:latest
22+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
23+
- name: Install
24+
run: npm ci
25+
- name: Compile
26+
run: npm run compile
27+
- name: Init e2e test subpackage
28+
run: npm --prefix e2e/tests ci
29+
- name: Clean coverage report
30+
run: npm run coverage:clean
31+
- name: Generate coverage report
32+
uses: GabrielBB/xvfb-action@v1
33+
with:
34+
run: npm run coverage -- --coverageDirectory=coverage/unit
35+
- name: Run Docker E2E tests
36+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} 14"
37+
- name: Merge coverage reports
38+
run: |
39+
npm run coverage:merge
40+
npm run coverage:merge-report
41+
- name: Run sonarqube
42+
env:
43+
# to get access to secrets.SONAR_TOKEN, provide GITHUB_TOKEN
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: sonar-scanner
46+
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
47+
-Dsonar.organization=nut-tree
48+
-Dsonar.host.url=https://sonarcloud.io/
49+
-Dsonar.projectKey=nut-tree:nut.js
50+
51+
test:
52+
needs:
53+
- sonar
54+
strategy:
55+
matrix:
56+
os: [ ubuntu-latest, windows-latest, macos-latest ]
57+
node: [ 10, 11, 12, 13, 14 ]
58+
exclude:
59+
- os: ubuntu-latest
60+
node: 14
61+
runs-on: ${{matrix.os}}
62+
steps:
63+
- name: Set up Git repository
64+
uses: actions/checkout@v2
65+
- name: Set up node
66+
uses: actions/setup-node@v2
67+
with:
68+
node-version: 14
69+
- name: Setup Docker
70+
if: ${{matrix.os == 'ubuntu-latest'}}
71+
run: |
72+
docker pull s1hofmann/nut-ci:latest
73+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
74+
- name: Install
75+
run: npm ci
76+
- name: Compile
77+
run: npm run compile
78+
- name: Init e2e test subpackage
79+
run: npm --prefix e2e/tests ci
80+
- name: Generate coverage report
81+
uses: GabrielBB/xvfb-action@v1
82+
with:
83+
run: npm run coverage -- --coverageDirectory=coverage/unit
84+
- name: Run Docker E2E tests
85+
if: ${{matrix.os == 'ubuntu-latest'}}
86+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} 14"
87+
88+
deploy:
89+
needs:
90+
- sonar
91+
- test
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: Set up Git repository
95+
uses: actions/checkout@v2
96+
- name: Set up node
97+
uses: actions/setup-node@v2
98+
with:
99+
node-version: 14
100+
- name: Publish tagged release
101+
uses: JS-DevTools/npm-publish@v1
102+
with:
103+
token: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)