-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (143 loc) · 7.37 KB
/
Copy pathBuild.yml
File metadata and controls
169 lines (143 loc) · 7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Display Name of the workflow
name: Build - GH Packages and Artifacts
# Event listeners for when the job should start execution
on:
# Triggers the workflow on push or pull request events to the main branch
push:
branches: [main]
# Allow this workflow to be called from another workflow
workflow_call:
inputs:
correlationId:
description: 'Correlates the origin job with the child instance since process start does not return an ID.'
type: string
required: false
jobs:
# Generate the TypeScript SDK client code
TypeScript-Build:
# Generate each SDK client in a separate build process to speed up execution and publishing
strategy:
matrix:
# Spec and SDK root locations
specifications:
- name: SHIELD
sdkPath: 'src/shield/TypeScript'
specPath: 'spec/SHIELD.json'
- name: DataGateway
sdkPath: 'src/dataGateway/TypeScript'
specPath: 'spec/Data-Gateway.json'
- name: UrlShortener
sdkPath: 'src/urlShortener/TypeScript'
specPath: 'spec/Url-Shortener.json'
# Display name of the job
name: Generate NPM Packages
# Operating system filter for the runners
runs-on: ubuntu-latest
# Allow single failures for SDK publish, e.g. SDG fail due to not getting an update but SHIELD goes through
continue-on-error: true
# Sets the scopes available to the github_token injected to the GH Actions runner
permissions:
attestations: write
contents: read
id-token: write
packages: write
# Set of steps required to generate the API client for TypeScript
steps:
# Download all of the source code
- name: Clone Repo Locally
uses: actions/checkout@v7
background: true
# Set up NodeJS on the build host
- name: Setup Node.JS Runtime
uses: actions/setup-node@v6
background: true
with:
node-version: 24
registry-url: https://npm.pkg.github.com
scope: software-hardware-integration-lab
# Set up the socket firewall binary
- name: Install - Socket Firewall
uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f
background: true
with:
mode: firewall-free
# Set up all of the supporting components for SDK generation
- name: Initialize Kiota Binaries
uses: microsoft/setup-kiota@v0.6.0
background: true
# Bring job back to sync execution by awaiting for all async jobs to finish before continuing
- name: Steps - Convert Back To Synchronous Execution - Build
wait-all: true
# Extract the project version from the package.json
- name: Extract Project Version
id: computedVersion
background: true
working-directory: ${{ matrix.specifications.sdkPath }}
run: echo "version=$(npm pkg get version --workspaces=false | tr -d \")" >> "$GITHUB_OUTPUT"
# Set the experimental tag to indicate if it is an Alpha or Beta build
- name: Compute Channel
id: computedChannel
background: true
run: |
if [ "${{ github.event_name }}" = "release" ] && [ "${{ github.event.release.prerelease }}" = "true" ]; then
echo "channel=beta" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "release" ]; then
echo "channel=stable" >> "$GITHUB_OUTPUT"
else
echo "channel=alpha" >> "$GITHUB_OUTPUT"
fi
# Get the first 7 chars of the SHA hash that represents the current commit that the build is operating off of.
- name: Compute Short SHA - Experimental Channel
id: shortSha
background: true
run: echo "shortSha=$(echo ${{ github.sha }} | head -c 7)" >> "$GITHUB_OUTPUT"
# Bring job back to sync execution by awaiting for all async jobs to finish before continuing
- name: Steps - Convert Back To Synchronous Execution - Metadata
wait-all: true
# Update the NPM CLI to the latest available version
- name: Update NPM CLI
run: sfw npm install -g npm
# Install the dependencies needed to build the project
- name: Install Build Dependencies
run: sfw npm ci
working-directory: ${{ matrix.specifications.sdkPath }}
# Cryptographically attest that packages haven't been tampered where supported
- name: Attest Dependency Provenance
run: npm audit signatures
working-directory: ${{ matrix.specifications.sdkPath }}
# Generate the TypeScript SDK
- name: Generate SDK Client Code via Kiota
run: npm run generate:Sdk
working-directory: ${{ matrix.specifications.sdkPath }}
# Generate the TypeScript SDK
- name: Build Project
run: npm run build:Prod
working-directory: ${{ matrix.specifications.sdkPath }}
# Update the version of SHIELD being uploaded to have a different version number to avoid SDG version conflict
- name: Tattoo Version - Experimental Channel
if: ${{ steps.computedChannel.outputs.channel != 'stable' }}
working-directory: ${{ matrix.specifications.sdkPath }}
run: npm version --no-commit-hooks --no-git-tag-version "${{ steps.computedVersion.outputs.version }}-${{ steps.computedChannel.outputs.channel }}.${{ steps.shortSha.outputs.shortSha }}"
# Publish the artifact to NPM with attestation
- name: Upload Package to NPM Registry
working-directory: ${{ matrix.specifications.sdkPath }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm publish --tag ${{ steps.computedChannel.outputs.channel }}
# Generate the NPM package for beta and stable publishing, if required
- name: Generate NPM Package
id: generate-package
working-directory: ${{ matrix.specifications.sdkPath }}
run: echo "package-file=$(npm pack --ignore-scripts)" >> "$GITHUB_OUTPUT"
# Create an attestation for the generated NPM package to ensure integrity and authenticity
- name: Attest NPM Package
uses: actions/attest@v4
with:
subject-path: ${{ format('{0}/{1}', matrix.specifications.sdkPath, steps.generate-package.outputs.package-file) }}
# Upload the compiled HTML as an artifact for future consumption
- name: Upload a Build Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.specifications.name }}
if-no-files-found: error
path: ${{ matrix.specifications.sdkPath }}/${{ steps.generate-package.outputs.package-file }}