unitsnet-js #222
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }' |