|
16 | 16 | required: false |
17 | 17 |
|
18 | 18 | jobs: |
| 19 | + # Calculates the tag and channel metadata based on the event that triggered the workflow, and making that data available to downstream jobs through outputs. |
| 20 | + Deploy-Metadata: |
| 21 | + # Human friendly display name for the job |
| 22 | + name: Calculate Deployment Metadata |
| 23 | + |
| 24 | + # Operating system that the job will run on |
| 25 | + runs-on: ubuntu-slim |
| 26 | + |
| 27 | + # Sets the scopes available to the github_token injected to the GH Actions runner |
| 28 | + permissions: |
| 29 | + # Read the files in the repository to be able to compute the version from the package.json. |
| 30 | + contents: read |
| 31 | + |
| 32 | + # Set of data that will be made available to downstream jobs. |
| 33 | + outputs: |
| 34 | + channel: ${{ steps.computedChannel.outputs.channel }} |
| 35 | + environment: ${{ steps.computedGitHubEnvironment.outputs.environment }} |
| 36 | + shortSha: ${{ steps.shortSha.outputs.shortSha }} |
| 37 | + version: ${{ steps.computedVersion.outputs.version }} |
| 38 | + |
| 39 | + # Set of actions to perform for this execution sandbox |
| 40 | + steps: |
| 41 | + # Download the source code |
| 42 | + - name: Checkout Files from Repo |
| 43 | + uses: actions/checkout@v7 |
| 44 | + |
| 45 | + # Extract the project version from the package.json |
| 46 | + - name: Extract Project Version |
| 47 | + id: computedVersion |
| 48 | + background: true |
| 49 | + run: echo "version=$(npm pkg get version --workspaces=false | tr -d \")" >> "$GITHUB_OUTPUT" |
| 50 | + |
| 51 | + # Set the experimental tag to indicate if it is an Alpha or Beta build |
| 52 | + - name: Compute Channel |
| 53 | + id: computedChannel |
| 54 | + background: true |
| 55 | + run: | |
| 56 | + if [ "${{ github.event_name }}" = "release" ] && [ "${{ github.event.release.prerelease }}" = "true" ]; then |
| 57 | + echo "channel=beta" >> "$GITHUB_OUTPUT" |
| 58 | + elif [ "${{ github.event_name }}" = "release" ]; then |
| 59 | + echo "channel=stable" >> "$GITHUB_OUTPUT" |
| 60 | + else |
| 61 | + echo "channel=alpha" >> "$GITHUB_OUTPUT" |
| 62 | + fi |
| 63 | +
|
| 64 | + # Compute the GitHub Environment to be used by the deployment |
| 65 | + - name: Compute GitHub Environment |
| 66 | + id: computedGitHubEnvironment |
| 67 | + background: true |
| 68 | + run: | |
| 69 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 70 | + echo "environment=Azure-Privileged" >> "$GITHUB_OUTPUT" |
| 71 | + else |
| 72 | + echo "environment=Azure-Alpha" >> "$GITHUB_OUTPUT" |
| 73 | + fi |
| 74 | +
|
| 75 | + # Get the first 7 chars of the SHA hash that represents the current commit that the build is operating off of. |
| 76 | + - name: Compute Short SHA - Experimental Channel |
| 77 | + id: shortSha |
| 78 | + background: true |
| 79 | + run: echo "shortSha=$(echo ${{ github.sha }} | head -c 7)" >> "$GITHUB_OUTPUT" |
| 80 | + |
| 81 | + # Bring job back to sync execution by awaiting for all async jobs to finish before continuing |
| 82 | + - name: Steps - Convert Back To Synchronous Execution |
| 83 | + wait-all: true |
| 84 | + |
19 | 85 | # Generate the TypeScript SDK client code |
20 | 86 | TypeScript-Build: |
21 | 87 | # Generate each SDK client in a separate build process to speed up execution and publishing |
|
42 | 108 | # Allow single failures for SDK publish, e.g. SDG fail due to not getting an update but SHIELD goes through |
43 | 109 | continue-on-error: true |
44 | 110 |
|
| 111 | + # Ensure that the metadata is calculated before starting the build process |
| 112 | + needs: [Deploy-Metadata] |
| 113 | + |
45 | 114 | # Sets the scopes available to the github_token injected to the GH Actions runner |
46 | 115 | permissions: |
47 | 116 | attestations: write |
@@ -105,12 +174,18 @@ jobs: |
105 | 174 | run: npm run build:Prod |
106 | 175 | working-directory: ${{ matrix.specifications.sdkPath }} |
107 | 176 |
|
| 177 | + # Update the version of SHIELD being uploaded to have a different version number to avoid SDG version conflict |
| 178 | + - name: Tattoo Version - Experimental Channel |
| 179 | + if: ${{ needs.Deploy-Metadata.outputs.channel != 'stable' }} |
| 180 | + working-directory: ${{ matrix.specifications.sdkPath }} |
| 181 | + run: npm version --no-commit-hooks --no-git-tag-version "${{ needs.Deploy-Metadata.outputs.version }}-${{ needs.Deploy-Metadata.outputs.channel }}.${{ needs.Deploy-Metadata.outputs.shortSha }}" |
| 182 | + |
108 | 183 | # Publish the artifact to NPM with attestation |
109 | 184 | - name: Upload Package to NPM Registry |
110 | 185 | working-directory: ${{ matrix.specifications.sdkPath }} |
111 | 186 | env: |
112 | 187 | NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
113 | | - run: npm publish --tag alpha |
| 188 | + run: npm publish --tag ${{ needs.Deploy-Metadata.outputs.channel }} |
114 | 189 |
|
115 | 190 | # Generate the NPM package for beta and stable publishing, if required |
116 | 191 | - name: Generate NPM Package |
|
0 commit comments