-
Notifications
You must be signed in to change notification settings - Fork 280
131 lines (110 loc) · 4.26 KB
/
build-js-steps.yml
File metadata and controls
131 lines (110 loc) · 4.26 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
name: Build JS SDK
on:
workflow_call:
inputs:
version:
required: true
type: string
useWinML:
required: false
type: boolean
default: false
platform:
required: false
type: string
default: 'windows' # or 'macos' or 'ubuntu'
permissions:
contents: read
jobs:
build:
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
runs-on: ${{ inputs.platform }}-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
clean: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
# needed to download Foundry Local Core from Azure Artifacts
- name: Setup .NET SDK for NuGet authentication
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
env:
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }}
- name: Format version for JS
shell: pwsh
run: |
# Release: 0.9.0.41 -> 0.9.0-41
$version = "${{ inputs.version }}"
$versionParts = $version -split '\.'
$baseVersion = ($versionParts[0..2]) -join '.'
$buildNumber = $versionParts[3]
$version = "$baseVersion-$buildNumber"
Write-Host "Modified version for JS: $version"
Write-Host "ProjectVersion=$version" >> $env:GITHUB_ENV
# need to use direct git commands to clone from Azure DevOps instead of actions/checkout
- name: Checkout test-data-shared from Azure DevOps
shell: pwsh
working-directory: ${{ github.workspace }}/..
run: |
$pat = "${{ secrets.AZURE_DEVOPS_PAT }}"
$encodedPat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))
# Configure git to use the PAT
git config --global http.https://dev.azure.com.extraheader "AUTHORIZATION: Basic $encodedPat"
# Clone with LFS to parent directory
git lfs install
git clone --depth 1 https://dev.azure.com/microsoft/windows.ai.toolkit/_git/test-data-shared test-data-shared
Write-Host "Clone completed successfully to ${{ github.workspace }}/../test-data-shared"
- name: Checkout specific commit in test-data-shared
shell: pwsh
working-directory: ${{ github.workspace }}/../test-data-shared
run: |
Write-Host "Current directory: $(Get-Location)"
git checkout 231f820fe285145b7ea4a449b112c1228ce66a41
if ($LASTEXITCODE -ne 0) {
Write-Error "Git checkout failed."
exit 1
}
Write-Host "`nDirectory contents:"
Get-ChildItem -Recurse -Depth 2 | ForEach-Object { Write-Host " $($_.FullName)" }
# The .npmrc points to an Azure Artifacts feed for CFS compliance.
# Remove it in CI so npm uses the public registry directly.
- name: Remove .npmrc (use public registry)
shell: pwsh
working-directory: sdk/js
run: |
if (Test-Path .npmrc) { Remove-Item .npmrc -Force; Write-Host "Removed .npmrc" }
- name: npm install
working-directory: sdk/js
run: npm install
- name: Set package version
working-directory: sdk/js
run: npm version ${{ env.ProjectVersion }} --no-git-tag-version --allow-same-version
- name: Run tests
working-directory: sdk/js
run: npm test
- name: Build package
working-directory: sdk/js
run: npm run build
- name: Pack npm package (WinML)
if: ${{ inputs.useWinML == true }}
working-directory: sdk/js
run: npm run pack:winml
- name: Pack npm package (Standard)
if: ${{ inputs.useWinML == false }}
working-directory: sdk/js
run: npm run pack
- name: Upload npm packages
uses: actions/upload-artifact@v4
with:
name: js-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}
path: sdk/js/*.tgz
- name: Upload flcore logs
uses: actions/upload-artifact@v4
with:
name: js-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}-logs
path: sdk/js/logs/**