Merge pull request #907 from openziti/v1-nodejs-sdk-ci

V1 nodejs sdk ci
This commit is contained in:
Kenneth Bingham 2025-03-05 10:04:12 -05:00 committed by GitHub
commit 401eaac6bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,8 +12,6 @@ jobs:
name: Require Stable Release Semver name: Require Stable Release Semver
if: github.event.action == 'released' if: github.event.action == 'released'
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
outputs:
version: ${{ steps.parse.outputs.version }}
steps: steps:
- name: Parse Release Version - name: Parse Release Version
id: parse id: parse
@ -32,18 +30,17 @@ jobs:
if: always() if: always()
name: Build for Node-${{ matrix.node_ver }} ${{ matrix.config.target }}/${{ matrix.config.arch }} name: Build for Node-${{ matrix.node_ver }} ${{ matrix.config.target }}/${{ matrix.config.arch }}
runs-on: ${{ matrix.config.os }} runs-on: ${{ matrix.config.os }}
env: env:
BUILD_NUMBER: ${{ github.run_number }} BUILD_NUMBER: ${{ github.run_number }}
AWS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
strategy: strategy:
matrix: matrix:
config: config:
- { os: ubuntu-20.04, target: "linux", arch: "x64" } - { os: ubuntu-24.04, target: "linux", arch: "x64" }
node_ver: [ 20 ] node_ver: [ 20 ]
fail-fast: false fail-fast: false
steps: steps:
- name: Node Version - name: Node Version
@ -55,20 +52,22 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
submodules: 'recursive'
- name: Get current zrok repo tag - name: Get current zrok repo tag
if: github.event.action == 'released'
id: tag id: tag
run: echo "TAG=$(git describe --tags --abbrev=0)" | tee -a $GITHUB_OUTPUT shell: bash
run: echo "TAG=$(git describe --tags --always)" | tee -a $GITHUB_OUTPUT
- name: Update zrok NodeJS-SDK's package.json version based on current zrok repo git tag - name: Update zrok NodeJS-SDK's package.json version based on current zrok repo git tag
if: github.ref_type == 'tag' if: github.event.action == 'released'
shell: bash
run: | run: |
cd ${{ runner.workspace }}/${{ github.event.repository.name }}/sdk/nodejs/sdk cd sdk/nodejs/sdk
npm version ${{ steps.tag.outputs.TAG }} --no-git-tag-version --allow-same-version npm version ${{ steps.tag.outputs.TAG }} --no-git-tag-version --allow-same-version
- name: Setup .npmrc - name: Setup .npmrc
if: github.ref_type == 'tag' if: github.event.action == 'released'
# Setup .npmrc file to prepare for possible publish to npm # Setup .npmrc file to prepare for possible publish to npm
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
@ -76,17 +75,26 @@ jobs:
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- name: Build the zrok NodeJS-SDK - name: Build the zrok NodeJS-SDK
shell: bash
run: | run: |
cd ${{ runner.workspace }}/${{ github.event.repository.name }}/sdk/nodejs/sdk cd sdk/nodejs/sdk
npm install npm install
npm run build npm run build
env: env:
BUILD_DATE: ${{ steps.date.outputs.date }} BUILD_DATE: ${{ steps.date.outputs.date }}
- name: NPM Publish - name: NPM Publish
if: github.ref_type == 'tag' if: github.event.action == 'released'
shell: bash
run: | run: |
cd ${{ runner.workspace }}/${{ github.event.repository.name }}/sdk/nodejs/sdk cd sdk/nodejs/sdk
npm publish --access public # Check if this is the official repository
if [[ "${{ github.repository_owner }}" == "openziti" ]]; then
echo "Publishing from official repository with @latest tag"
npm publish --access public
else
echo "Publishing from fork/test repository with @canary tag"
npm publish --access public --tag canary
fi
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}