Skip to content

feat: Publish sdk to GH Actions Packages #4

feat: Publish sdk to GH Actions Packages

feat: Publish sdk to GH Actions Packages #4

name: Build and Publish Cohort SDK NPSs
on:
#workflow_call:
push:
env:
SDK_JS_PACKAGE_NAME: "@talos/cohort_sdk_js"
SDK_CLIENT_PACKAGE_NAME: "@talos/cohort_sdk_client"
jobs:
npm:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
dirSdkJs: packages/cohort_sdk_js
dirSdkJsClient: packages/cohort_sdk_client
customiseHostCommand: echo "No customizations needed"
name: stable - ${{ matrix.settings.target }} - node@16
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
registry-url: "https://npm.pkg.github.com"
- name: Customise host image
shell: bash
run: ${{ matrix.settings.customiseHostCommand }}
- name: Setup version for ${{ matrix.settings.dirSdkJs }}
id: sdk-js-version
shell: bash
run: |-
echo "Building SDK JS Library"
cd ${{ matrix.settings.dirSdkJs }}
pwd
ls -l
npm ci --foreground-scripts
selectNodeName=${{ env.SDK_JS_PACKAGE_NAME }}
currentVersion=$(npm version | yq .$selectNodeName)
currentSha=$(git rev-parse --short HEAD)
newVersion="$currentVersion-$currentSha"
echo "DEBUG: selectNodeName=$selectNodeName"
echo "DEBUG: currentVersion=$currentVersion"
echo "DEBUG: currentSha=$currentSha"
echo "DEBUG: newVersion=$newVersion"
npm version $newVersion
echo "SDK_JS_PACKAGE_VERSION=$newVersion" >> "$GITHUB_OUTPUT"
echo ""
- name: Publishing ${{ matrix.settings.dirSdkJs }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |-
cd ${{ matrix.settings.dirSdkJs }}
pwd
ls -l
echo "Current version is"
npm version
npm publish --access private --foreground-scripts
echo ""
- name: Setup version for ${{ matrix.settings.dirSdkJsClient }}
env:
SDK_JS_PACKAGE_VERSION: ${{ steps.sdk-js-version.outputs.SDK_JS_PACKAGE_VERSION }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |-
echo "Building SDK Client"
cd ${{ matrix.settings.dirSdkJsClient }}
pwd
ls -l
npm install "$SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" --foreground-scripts
selectNodeName=${{ env.SDK_CLIENT_PACKAGE_NAME }}
currentVersion=$(npm version | yq .$selectNodeName)
currentSha=$(git rev-parse --short HEAD)
newVersion="$currentVersion-$currentSha"
echo "DEBUG: selectNodeName=$selectNodeName"
echo "DEBUG: currentVersion=$currentVersion"
echo "DEBUG: currentSha=$currentSha"
echo "DEBUG: newVersion=$newVersion"
npm version $newVersion
echo ""