2222 TAG : ${{ steps.tag.outputs.TAG }}
2323 steps :
2424 - name : Calculate VERSION
25- # We should only use the hard coded test value for a dry run
26- run : echo "VERSION=${{ github.event_name == 'release' && github.event.release.tag_name || 'v0.0.0-pre.0' }}" >> "$GITHUB_ENV"
25+ # Safely store dynamic values in environment variables
26+ # to prevent shell injection (template-injection)
27+ run : |
28+ # The logic is executed within the shell using the env variables
29+ if [ "$EVENT_NAME" = "release" ]; then
30+ echo "VERSION=$RELEASE_TAG" >> "$GITHUB_ENV"
31+ else
32+ echo "VERSION=v0.0.0-pre.0" >> "$GITHUB_ENV"
33+ fi
34+ env :
35+ RELEASE_TAG : ${{ github.event.release.tag_name }}
36+ EVENT_NAME : ${{ github.event_name }}
2737 - id : dry_run
2838 name : Set DRY_RUN
2939 # We perform a dry run for all events except releases.
7181 contents : write # required to upload release asset
7282 steps :
7383 - name : Determine filename
74- run : echo "FILENAME_PREFIX=sable-call-embedded-${{ needs.versioning.outputs.UNPREFIXED_VERSION }}" >> "$GITHUB_ENV"
84+ run : echo "FILENAME_PREFIX=sable-call-embedded-${NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION}" >> "$GITHUB_ENV"
85+ env :
86+ NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION : ${{ needs.versioning.outputs.UNPREFIXED_VERSION }}
7587 - name : Download built artifact
7688 uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
7789 with :
8092 name : build-output-embedded
8193 path : ${{ env.FILENAME_PREFIX}}
8294 - name : Create Tarball
83- run : tar --numeric-owner -cvzf ${{ env. FILENAME_PREFIX }} .tar.gz ${{ env. FILENAME_PREFIX } }
95+ run : tar --numeric-owner -cvzf ${FILENAME_PREFIX} .tar.gz ${FILENAME_PREFIX}
8496 - name : Create Checksum
85- run : find ${{ env. FILENAME_PREFIX }} -type f -print0 | sort -z | xargs -0 sha256sum | tee ${{ env. FILENAME_PREFIX } }.sha256
97+ run : find ${FILENAME_PREFIX} -type f -print0 | sort -z | xargs -0 sha256sum | tee ${FILENAME_PREFIX}.sha256
8698 - name : Upload
8799 if : ${{ needs.versioning.outputs.DRY_RUN == 'false' }}
88100 uses : softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
@@ -104,6 +116,8 @@ jobs:
104116 steps :
105117 - name : Checkout
106118 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
119+ with :
120+ persist-credentials : false
107121
108122 - name : Download built artifact
109123 uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
@@ -124,14 +138,16 @@ jobs:
124138 working-directory : embedded/web
125139 env :
126140 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
141+ NEEDS_VERSIONING_OUTPUTS_PREFIXED_VERSION : ${{ needs.versioning.outputs.PREFIXED_VERSION }}
142+ NEEDS_VERSIONING_OUTPUTS_TAG : ${{ needs.versioning.outputs.TAG }}
127143 run : |
128- npm version ${{ needs.versioning.outputs.PREFIXED_VERSION } } --no-git-tag-version
144+ npm version ${NEEDS_VERSIONING_OUTPUTS_PREFIXED_VERSION } --no-git-tag-version
129145 echo "ARTIFACT_VERSION=$(jq '.version' --raw-output package.json)" >> "$GITHUB_ENV"
130- npm publish --provenance --access public --tag ${{ needs.versioning.outputs.TAG } } ${{ needs.versioning.outputs.DRY_RUN == 'true' && '--dry-run' || '' }}
146+ npm publish --provenance --access public --tag ${NEEDS_VERSIONING_OUTPUTS_TAG } ${{ needs.versioning.outputs.DRY_RUN == 'true' && '--dry-run' || '' }}
131147
132148 - id : artifact_version
133149 name : Output artifact version
134- run : echo "ARTIFACT_VERSION=${{env. ARTIFACT_VERSION} }" >> "$GITHUB_OUTPUT"
150+ run : echo "ARTIFACT_VERSION=${ARTIFACT_VERSION}" >> "$GITHUB_OUTPUT"
135151
136152 release_notes :
137153 needs : [versioning, publish_npm]
@@ -143,7 +159,9 @@ jobs:
143159 steps :
144160 - name : Log versions
145161 run : |
146- echo "NPM: ${{ needs.publish_npm.outputs.ARTIFACT_VERSION }}"
162+ echo "NPM: ${NEEDS_PUBLISH_NPM_OUTPUTS_ARTIFACT_VERSION}"
163+ env :
164+ NEEDS_PUBLISH_NPM_OUTPUTS_ARTIFACT_VERSION : ${{ needs.publish_npm.outputs.ARTIFACT_VERSION }}
147165 - name : Add release notes
148166 if : ${{ needs.versioning.outputs.DRY_RUN == 'false' }}
149167 uses : softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
0 commit comments