-
Notifications
You must be signed in to change notification settings - Fork 200
122 lines (107 loc) · 4.21 KB
/
template-upgradesample.yml
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
name: Upgrade Sample
on:
workflow_call:
inputs:
skipUpgrade:
required: false
default: false
type: boolean
vmImage:
required: false
default: 'windows-latest'
type: string
sampleName:
required: true
type: string
reactNativeWindowsVersion:
required: true
type: string
configuration:
required: false
default: 'Debug'
type: string
platform:
required: false
default: 'x64'
type: string
useBuildCertificate:
required: false
default: false
type: boolean
runInitWindows:
required: false
default: false
type: boolean
runCodeGenCheck:
required: false
default: false
type: boolean
extraRunWindowsArgs:
required: false
default: ''
type: string
extraInitWindowsArgs:
required: false
default: ''
type: string
defaults:
run:
shell: pwsh
jobs:
check: # This job ensures the template reports success even when we don't want it to upgrade
name: "Check if upgrade is required: ${{ !inputs.skipUpgrade }}"
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
upgrade-sample:
name: Upgrade ${{ inputs.sampleName }} ${{ inputs.configuration }} ${{ inputs.platform }} to ${{ inputs.reactNativeWindowsVersion }}
needs: check
if: ${{ !inputs.skipUpgrade }}
runs-on: ${{ inputs.vmImage }}
steps:
- uses: actions/checkout@v3
- name: Gather environment info
run: npx envinfo
- name: Relocate to reduce long paths
run: Copy-item -Force -Recurse -Verbose "samples\${{ inputs.sampleName }}" -Destination "..\..\src"
- name: Get starting folder size
run: ${{github.workspace}}\.github\scripts\GetFolderSize.ps1
working-directory: ..\..\src
- name: Yarn install
run: yarn install --frozen-lockfile
working-directory: ..\..\src
- name: Upgrade react-native-windows
id: upgrade
continue-on-error: true
run: ${{github.workspace}}\.github\scripts\UpgradeSmokeTest.ps1 ${{ inputs.reactNativeWindowsVersion }} -Force ${{ format('${0}', contains(inputs.reactNativeWindowsVersion, 'canary')) }}
working-directory: ..\..\src
- name: Run react-native-windows-init
if: ${{ steps.upgrade.outcome == 'success' && inputs.runInitWindows }}
run: npx react-native-windows-init --overwrite ${{ inputs.extraInitWindowsArgs }} --version ${{ inputs.reactNativeWindowsVersion }}
working-directory: ..\..\src
- name: Codegen check
if: ${{ steps.upgrade.outcome == 'success' && inputs.runCodeGenCheck }}
run: npx react-native codegen-windows --check --no-telemetry
working-directory: ..\..\src
- name: Decode the pfx
if: ${{ steps.upgrade.outcome == 'success' && inputs.useBuildCertificate }}
run: |
$PfxBytes = [System.Convert]::FromBase64String("${{ secrets.SAMPLES_BASE64_ENCODED_PFX }}")
$PfxPath = [System.IO.Path]::GetFullPath("${{github.workspace}}\GitHubActionsWorkflow.pfx")
Write-Host $PfxPath
[System.IO.File]::WriteAllBytes("$PfxPath", $PfxBytes)
working-directory: ..\..\src
- name: Run react-native run-windows
if: ${{ steps.upgrade.outcome == 'success' }}
run: npx react-native run-windows --logging --no-packager --no-launch ${{ inputs.extraRunWindowsArgs }} --arch ${{ inputs.platform }} ${{ startsWith(inputs.platform, 'ARM') && '--no-deploy' || '' }} ${{ inputs.configuration == 'Release' && '--release' || '' }} ${{ inputs.useBuildCertificate && '--msbuildprops PackageCertificateKeyFile=${{github.workspace}}\GitHubActionsWorkflow.pfx' || '' }}
working-directory: ..\..\src
- name: Remove the pfx
if: ${{ steps.upgrade.outcome == 'success' && inputs.useBuildCertificate }}
run: |
$certificatePath = [System.IO.Path]::GetFullPath("${{github.workspace}}\GitHubActionsWorkflow.pfx")
Write-Host $certificatePath
Remove-Item -path $certificatePath
working-directory: ..\..\src
- name: Get final folder size
run: ${{github.workspace}}\.github\scripts\GetFolderSize.ps1
working-directory: ..\..\src