diff --git a/.github/workflows/reusable-sdk-npm.yml b/.github/workflows/reusable-sdk-npm.yml new file mode 100644 index 0000000..5471d23 --- /dev/null +++ b/.github/workflows/reusable-sdk-npm.yml @@ -0,0 +1,35 @@ +name: npm publish SDK +description: reusable npm workflow for this project + +on: + workflow_call: + inputs: + dry-run: + description: 'Run in dry-run mode (the package will not be published)' + default: false + type: boolean + version: + description: 'Version to publish (leave empty to use package.json version)' + default: '' + type: string + tag: + description: 'npm publish tag (e.g., latest, nightly)' + default: '' + type: string + secrets: + npm-token: + description: 'NPM auth token (required unless `dry-run: true`)' + required: false + +jobs: + publish-npm: + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/publish-npm.yml@publish-npm-v1.5.0 + with: + scope: '@iexec/web3telegram' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + environment: ${{ (inputs.dry-run && '') || inputs.tag }} + provenance: ${{ !inputs.dry-run }} + dry-run: ${{ inputs.dry-run }} + secrets: + npm-token: ${{ secrets.npm-token }} diff --git a/.github/workflows/sdk-ci.yml b/.github/workflows/sdk-ci.yml index 1376f1f..6098689 100644 --- a/.github/workflows/sdk-ci.yml +++ b/.github/workflows/sdk-ci.yml @@ -82,5 +82,7 @@ jobs: - name: Build run: npm run build - - name: publish dry-run - run: npm publish --dry-run + npm-publish-dry-run: + uses: ./.github/workflows/reusable-sdk-npm.yml + with: + dry-run: true diff --git a/.github/workflows/publish-npm-sdk.yml b/.github/workflows/sdk-npm-publish.yml similarity index 81% rename from .github/workflows/publish-npm-sdk.yml rename to .github/workflows/sdk-npm-publish.yml index a84aaf0..265371e 100644 --- a/.github/workflows/publish-npm-sdk.yml +++ b/.github/workflows/sdk-npm-publish.yml @@ -39,16 +39,10 @@ jobs: publish-npm: # Run only on main branch if: github.ref == 'refs/heads/main' - uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/publish-npm.yml@publish-npm-v1.5.0 + uses: ./.github/workflows/reusable-sdk-npm.yml needs: set-publish-version with: - scope: '@iexec/web3telegram' - registry: 'https://registry.npmjs.org' - node-version: '18' - environment: ${{ github.event.inputs.target }} tag: ${{ github.event.inputs.tag }} version: ${{ needs.set-publish-version.outputs.VERSION }} - install-command: | - npm ci secrets: npm-token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/sdk-release.yml b/.github/workflows/sdk-release.yml index 1f8fd34..452f6d1 100644 --- a/.github/workflows/sdk-release.yml +++ b/.github/workflows/sdk-release.yml @@ -7,7 +7,7 @@ on: jobs: publish-npm: - uses: ./.github/workflows/publish-npm-sdk.yml + uses: ./.github/workflows/reusable-sdk-npm.yml with: tag: 'latest' secrets: