2024-03-25 21:51:15 +01:00
|
|
|
name: Build/Release Node SDK
|
2023-11-21 17:31:28 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [ published ]
|
2024-03-25 21:51:15 +01:00
|
|
|
push:
|
|
|
|
branches: [ main ]
|
|
|
|
paths-ignore:
|
|
|
|
- 'package.json'
|
|
|
|
- 'CHANGELOG.md'
|
|
|
|
pull_request:
|
|
|
|
branches: [ main ]
|
2023-11-21 17:31:28 +01:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
build:
|
|
|
|
name: Build for Node-${{ matrix.node_ver }} ${{ matrix.config.target }}/${{ matrix.config.arch }}
|
|
|
|
runs-on: ${{ matrix.config.os }}
|
|
|
|
|
|
|
|
env:
|
|
|
|
BUILD_NUMBER: ${{ github.run_number }}
|
|
|
|
AWS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
config:
|
|
|
|
- { os: ubuntu-20.04, target: "linux", arch: "x64" }
|
2024-03-26 16:32:10 +01:00
|
|
|
node_ver: [ 20 ]
|
2023-11-21 17:31:28 +01:00
|
|
|
fail-fast: false
|
2024-05-01 14:03:02 +02:00
|
|
|
|
2023-11-21 17:31:28 +01:00
|
|
|
steps:
|
|
|
|
|
2024-03-26 19:42:44 +01:00
|
|
|
- name: Node Version
|
|
|
|
uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node_ver }}
|
|
|
|
|
2023-11-21 17:31:28 +01:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: 'recursive'
|
|
|
|
|
2024-05-01 14:03:02 +02:00
|
|
|
- name: Get current zrok repo tag
|
|
|
|
id: tag
|
|
|
|
run: echo ::set-output name=TAG::$(git describe --tags --abbrev=0)
|
|
|
|
|
|
|
|
- name: Update zrok NodeJS-SDK's package.json version based on current zrok repo git tag
|
2024-05-01 14:16:18 +02:00
|
|
|
if: github.ref == 'refs/heads/main'
|
2024-05-01 14:03:02 +02:00
|
|
|
run: |
|
|
|
|
cd ${{ runner.workspace }}/${{ github.event.repository.name }}/sdk/nodejs/sdk
|
|
|
|
npm version ${{ steps.tag.outputs.TAG }} --no-git-tag-version --allow-same-version
|
|
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
git config --global user.name "github-actions[bot]"
|
|
|
|
git commit -am "Update package.json version to ${{ steps.tag.outputs.TAG }}" || echo "No changes to commit"
|
|
|
|
|
|
|
|
- name: Push changes to zrok NodeJS-SDK's package.json
|
2024-05-01 14:16:18 +02:00
|
|
|
if: github.ref == 'refs/heads/main'
|
2024-05-01 14:03:02 +02:00
|
|
|
uses: ad-m/github-push-action@master
|
2023-11-21 17:31:28 +01:00
|
|
|
with:
|
2024-05-01 14:03:02 +02:00
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
branch: ${{ github.ref }}
|
2024-03-26 19:42:44 +01:00
|
|
|
|
2024-05-01 14:03:02 +02:00
|
|
|
- name: Pull newly bumped zrok NodeJS-SDK semver
|
2024-03-26 19:42:44 +01:00
|
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
run: git pull
|
2023-11-21 17:31:28 +01:00
|
|
|
|
2024-03-26 19:42:44 +01:00
|
|
|
- name: Setup .npmrc
|
|
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
# Setup .npmrc file to prepare for possible publish to npm
|
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
registry-url: 'https://registry.npmjs.org'
|
2023-11-21 17:31:28 +01:00
|
|
|
|
2024-05-01 14:03:02 +02:00
|
|
|
- name: Build the zrok NodeJS-SDK
|
2023-11-21 17:31:28 +01:00
|
|
|
run: |
|
2024-03-25 21:51:15 +01:00
|
|
|
cd ${{ runner.workspace }}/${{ github.event.repository.name }}/sdk/nodejs/sdk
|
2023-11-21 17:31:28 +01:00
|
|
|
npm install
|
2024-03-25 21:51:15 +01:00
|
|
|
npm run build
|
2023-11-21 17:31:28 +01:00
|
|
|
env:
|
|
|
|
BUILD_DATE: ${{ steps.date.outputs.date }}
|
|
|
|
|
2024-03-26 19:42:44 +01:00
|
|
|
- name: Publish production release
|
|
|
|
if: github.ref == 'refs/heads/main'
|
2024-05-01 14:03:02 +02:00
|
|
|
run: |
|
|
|
|
cd ${{ runner.workspace }}/${{ github.event.repository.name }}/sdk/nodejs/sdk
|
|
|
|
npm publish --access public
|
2024-03-26 19:42:44 +01:00
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
|
2023-11-21 17:31:28 +01:00
|
|
|
- name: NPM Publish
|
2024-05-01 14:16:18 +02:00
|
|
|
if: github.ref == 'refs/heads/main'
|
2023-11-21 17:31:28 +01:00
|
|
|
uses: JS-DevTools/npm-publish@v1
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.NPM_TOKEN }}
|
|
|
|
access: public
|