-
Notifications
You must be signed in to change notification settings - Fork 9
137 lines (118 loc) · 4.67 KB
/
nodejs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: unitsnet-js
on: [push,workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Prepare dependencies
run: |
npm i -g yarn
cd generator-scripts
yarn install --frozen-lockfile
cd ..
yarn install --frozen-lockfile
- name: Build & Test 🔧
run: |
yarn generate
yarn test
cover:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [">=14.6"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Run Coverage
run: |
yarn install
yarn run cover
- name: Publish to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Prepare dependencies
run: |
npm i -g yarn
cd generator-scripts
yarn install --frozen-lockfile
cd ..
yarn install --frozen-lockfile
- name: Increase Version
id: update_version
run: |
VERSION=$(node -p "require('./package.json').version")
DEFINITION_VERSION=$(node -p "require('./package.json').definitionVersion")
CURRENT_DEFINITION=$(node ./scripts/definition-version.js)
NEXT_VERSION=$(node ./scripts/next-package-version.js $VERSION $DEFINITION_VERSION $CURRENT_DEFINITION)
jq --arg next_version "$NEXT_VERSION" --arg current_definition "$CURRENT_DEFINITION" '.version = $next_version | .definitionVersion = $current_definition' package.json > tmp.json && mv tmp.json package.json
echo "VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: Get version info
id: version_info
run: |
body=$(git log -1 --pretty=%B | sed -n '1p')
echo "BODY=$body" >> $GITHUB_OUTPUT
- name: Commit and push version
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Update to version ${{ steps.update_version.outputs.VERSION }} [skip-ci]
- name: Publish package on NPM 📦
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.update_version.outputs.VERSION }}
name: Package Version ${{ steps.update_version.outputs.VERSION }}
body: ${{ steps.version_info.outputs.BODY }}
draft: false
prerelease: false
- name: Commit and push generated docs update
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Update gen docs for version ${{ steps.update_version.outputs.VERSION }} [skip-ci]
- name: Call re-run generate & publish Python package # Trigger Python package re-generate and publish to PyPi (https://github.com/haimkastner/unitsnet-py)
env:
UNITSNET_PYTHON_WORKFLOW_TOKEN: ${{ secrets.UNITSNET_PYTHON_WORKFLOW_TOKEN }}
run: |
# Trigger re-generate Python units once a new release created
curl --fail --location --request POST 'https://api.github.com/repos/haimkastner/unitsnet-py/actions/workflows/build.yml/dispatches' \
--header 'Accept: application/vnd.github.everest-preview+json' \
--header 'Content-Type: application/json' \
--header "Authorization: token $UNITSNET_PYTHON_WORKFLOW_TOKEN" \
--data-raw '{"ref": "main" }'
# Trigger re-generate Golang units once a new release created
curl --fail --location --request POST 'https://api.github.com/repos/haimkastner/unitsnet-go/actions/workflows/build.yml/dispatches' \
--header 'Accept: application/vnd.github.everest-preview+json' \
--header 'Content-Type: application/json' \
--header "Authorization: token $UNITSNET_PYTHON_WORKFLOW_TOKEN" \
--data-raw '{"ref": "main" }'