@@ -14,8 +14,9 @@ permissions:
1414
1515jobs :
1616 set-staging-version :
17- # Only run for manual dispatch on main branch
18- if : ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
17+ # Only run for manual dispatch
18+ # when run from main branch, sets dist-tag to "nightly"
19+ if : ${{ github.event_name == 'workflow_dispatch' }}
1920 runs-on : ubuntu-latest
2021 steps :
2122 - name : Checkout code
@@ -26,15 +27,23 @@ jobs:
2627 id : set-staging-version
2728 working-directory : packages/sdk
2829 run : |
30+ BRANCH=$(echo "${{ github.ref_name }}" | sed 's|/|-|g')
31+ COMMIT_SHA="${{ github.sha }}"
2932 CURRENT_VERSION=$(npm pkg get version | tr -d '"')
30- NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
31- echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
33+ STAGING_VERSION="${CURRENT_VERSION}-${BRANCH}-${COMMIT_SHA::7}"
34+ echo "VERSION=${STAGING_VERSION}" | tee -a $GITHUB_OUTPUT
35+ if [ "${BRANCH}" = "main" ]; then
36+ echo "DIST_TAG=nightly" | tee -a $GITHUB_OUTPUT
37+ else
38+ echo "DIST_TAG=${BRANCH}" | tee -a $GITHUB_OUTPUT
39+ fi
3240 outputs :
3341 VERSION : ${{ steps.set-staging-version.outputs.VERSION }}
42+ DIST_TAG : ${{ steps.set-staging-version.outputs.DIST_TAG }}
3443
3544 publish-npm-staging :
36- # Only run for manual dispatch on main branch
37- if : ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
45+ # Only run for manual dispatch
46+ if : ${{ github.event_name == 'workflow_dispatch' }}
3847 uses :
iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected] 3948 needs : set-staging-version
4049 with :
4352 node-version : ' 20'
4453 environment : ' staging'
4554 working-directory : packages/sdk
46- tag : ' nightly '
55+ tag : ${{ needs.set-staging-version.outputs.DIST_TAG }}
4756 version : ${{ needs.set-staging-version.outputs.VERSION }}
4857 install-command : |
4958 npm ci
0 commit comments