Skip to content

dataprotector: v2.0.0-beta.21 #4

dataprotector: v2.0.0-beta.21

dataprotector: v2.0.0-beta.21 #4

Workflow file for this run

# ⚠️ THIS WORKFLOW IS THE TRUSTED PUBLISHER CONFIGURED ON NPMJS.COM, DO NOT RENAME OR DELETE THIS FILE ⚠️name: SDK - Publish NPM
name: SDK - Publish NPM Package
on:
# For staging releases
workflow_dispatch:
# For latest releases
release:
types: [published]
permissions:
id-token: write # Required for OIDC
packages: write
contents: read
jobs:
set-staging-version:
# Only run for manual dispatch
# when run from main branch, sets dist-tag to "nightly"
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Set publish version
id: set-staging-version
working-directory: packages/sdk
run: |
BRANCH=$(echo "${{ github.ref_name }}" | sed 's|/|-|g')
COMMIT_SHA="${{ github.sha }}"
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
STAGING_VERSION="${CURRENT_VERSION}-${BRANCH}-${COMMIT_SHA::7}"
echo "VERSION=${STAGING_VERSION}" | tee -a $GITHUB_OUTPUT
if [ "${BRANCH}" = "main" ]; then
echo "DIST_TAG=nightly" | tee -a $GITHUB_OUTPUT
else
echo "DIST_TAG=${BRANCH}" | tee -a $GITHUB_OUTPUT
fi
outputs:
VERSION: ${{ steps.set-staging-version.outputs.VERSION }}
DIST_TAG: ${{ steps.set-staging-version.outputs.DIST_TAG }}
publish-npm-staging:
# Only run for manual dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
needs: set-staging-version
with:
scope: '@iexec/dataprotector'
registry: 'https://registry.npmjs.org'
node-version: '20'
environment: 'staging'
working-directory: packages/sdk
tag: ${{ needs.set-staging-version.outputs.DIST_TAG }}
version: ${{ needs.set-staging-version.outputs.VERSION }}
install-command: |
npm ci
npm run codegen
publish-npm-latest:
# # Only run for release published with tag "dataprotector-v*"
if: ${{ github.event_name == 'release' && startsWith(github.ref_name,'dataprotector-v') }}
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
with:
scope: '@iexec/dataprotector'
registry: 'https://registry.npmjs.org'
node-version: '20'
working-directory: packages/sdk
tag: 'latest'
install-command: |
npm ci
npm run codegen