Skip to content

Commit 7cdb058

Browse files
authored
npm ci (#97)
* added npm ci * release workflow * rm debug print * style * fixes
1 parent 709decf commit 7cdb058

File tree

5 files changed

+116
-16
lines changed

5 files changed

+116
-16
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "checks"
1+
name: "coverage"
22

33
on:
44
push:
@@ -10,16 +10,6 @@ on:
1010
- dev
1111

1212
jobs:
13-
test:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout the repository
17-
uses: actions/checkout@v3
18-
- name: Setup
19-
uses: ./.github/actions/setup
20-
- name: Run tests
21-
run: npm run test
22-
2313
coverage:
2414
runs-on: ubuntu-latest
2515
steps:

.github/workflows/docs.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ name: "docs"
22

33
on:
44
workflow_dispatch:
5-
push:
6-
tags:
7-
- "[0-9]+.[0-9]+.[0-9]+"
5+
workflow_run:
6+
workflows:
7+
- tests
8+
types:
9+
- completed
10+
branches:
11+
- master
812

913
jobs:
1014
docs:
1115
runs-on: ubuntu-latest
16+
if: github.event.workflow_run.conclusion == 'success'
1217
steps:
1318
- name: Checkout the repository
1419
uses: actions/checkout@v3
@@ -33,10 +38,10 @@ jobs:
3338
git config --global user.name "Docs Syncer"
3439
git config --global user.email "contact@distributedlab.com"
3540
git fetch --unshallow
36-
latest_tag=$(git describe --tags --abbrev=0)
41+
latest_commit_hash=$(git rev-parse --short HEAD)
3742
cd docs
3843
git add -f .
3944
if ! git diff-index --quiet HEAD; then
40-
git commit -m "CI: \`$latest_tag\`"
45+
git commit -m "CI: \`$latest_commit_hash\`"
4146
git push
4247
fi

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: "release"
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows:
7+
- tests
8+
types:
9+
- completed
10+
branches:
11+
- master
12+
13+
jobs:
14+
state:
15+
runs-on: ubuntu-latest
16+
if: github.event.workflow_run.conclusion == 'success'
17+
steps:
18+
- name: Checkout the repository
19+
uses: actions/checkout@v3
20+
- name: Set up environment
21+
uses: ./.github/actions/setup
22+
- name: Fetch State
23+
id: state
24+
run: bash ./scripts/versions.sh
25+
outputs:
26+
local_version: ${{ steps.state.outputs.local_version }}
27+
version_changed: ${{ steps.state.outputs.version_changed }}
28+
29+
release:
30+
runs-on: ubuntu-latest
31+
needs: state
32+
if: needs.state.outputs.version_changed != 'not_changed'
33+
steps:
34+
- name: Checkout the repository
35+
uses: actions/checkout@v3
36+
- name: Create Release
37+
uses: actions/create-release@v1
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
with:
41+
tag_name: ${{ needs.state.outputs.local_version }}
42+
release_name: Release v${{ needs.state.outputs.local_version }}
43+
body: |
44+
# Release notes v${{ needs.state.outputs.local_version }} 🎉
45+
46+
## This is a ${{ needs.state.outputs.version_changed }} release
47+
48+
To be filled...
49+
draft: false
50+
prerelease: false
51+
52+
publish:
53+
runs-on: ubuntu-latest
54+
needs: state
55+
if: needs.state.outputs.version_changed != 'not_changed'
56+
steps:
57+
- name: Checkout the repository
58+
uses: actions/checkout@v3
59+
- name: Setup
60+
uses: ./.github/actions/setup
61+
- name: Publish to npm
62+
run: |
63+
npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_ACCESS_TOKEN }}
64+
npm run publish-to-npm

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "tests"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
- dev
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout the repository
17+
uses: actions/checkout@v3
18+
- name: Setup
19+
uses: ./.github/actions/setup
20+
- name: Run tests
21+
run: npm run test

scripts/versions.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
local_version=$(node -p "require('./package.json').version")
4+
registry_version=$(npm view $(node -p "require('./package.json').name") version)
5+
6+
IFS='.' read -a local_version_array <<< $local_version
7+
IFS='.' read -a registry_version_array <<< $registry_version
8+
9+
version_changed="not_changed"
10+
11+
if [[ ${local_version_array[0]} -gt ${registry_version_array[0]} ]]; then
12+
version_changed="major"
13+
elif [[ ${local_version_array[1]} -gt ${registry_version_array[1]} ]]; then
14+
version_changed="minor"
15+
elif [[ ${local_version_array[2]} -gt ${registry_version_array[2]} ]]; then
16+
version_changed="patch"
17+
fi
18+
19+
echo "::set-output name=local_version::$local_version"
20+
echo "::set-output name=version_changed::$version_changed"

0 commit comments

Comments
 (0)