summaryrefslogtreecommitdiffstats
path: root/.azure-pipelines/windows-release/stage-pack-msix.yml
blob: 26a5712e845ca9ebd1b1fdc5035510b93d9075e8 (plain)
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
jobs:
- job: Pack_MSIX
  displayName: Pack MSIX bundles

  pool:
    vmImage: windows-2019

  workspace:
    clean: all

  strategy:
    matrix:
      amd64:
        Name: amd64
        Artifact: appx
        Suffix:
        ShouldSign: true
      amd64_store:
        Name: amd64
        Artifact: appxstore
        Suffix: -store
        Upload: true
      arm64:
        Name: arm64
        Artifact: appx
        Suffix:
        ShouldSign: true
      arm64_store:
        Name: arm64
        Artifact: appxstore
        Suffix: -store
        Upload: true

  steps:
  - template: ./checkout.yml

  - task: DownloadPipelineArtifact@1
    displayName: 'Download artifact: layout_$(Artifact)_$(Name)'
    inputs:
      artifactName: layout_$(Artifact)_$(Name)
      targetPath: $(Build.BinariesDirectory)\layout

  - task: DownloadBuildArtifacts@0
    displayName: 'Download artifact: symbols'
    inputs:
      artifactName: symbols
      downloadPath: $(Build.BinariesDirectory)

  - powershell: |
      $d = (.\PCbuild\build.bat -V) | %{ if($_ -match '\s+(\w+):\s*(.+)\s*$') { @{$Matches[1] = $Matches[2];} }};
      Write-Host "##vso[task.setvariable variable=VersionText]$($d.PythonVersion)"
      Write-Host "##vso[task.setvariable variable=VersionNumber]$($d.PythonVersionNumber)"
      Write-Host "##vso[task.setvariable variable=VersionHex]$($d.PythonVersionHex)"
      Write-Host "##vso[task.setvariable variable=VersionUnique]$($d.PythonVersionUnique)"
      Write-Host "##vso[task.setvariable variable=Filename]python-$($d.PythonVersion)-$(Name)$(Suffix)"
    displayName: 'Extract version numbers'

  - powershell: |
      ./Tools/msi/make_appx.ps1 -layout "$(Build.BinariesDirectory)\layout" -msix "$(Build.ArtifactStagingDirectory)\msix\$(Filename).msix"
    displayName: 'Build msix'

  - powershell: |
      7z a -tzip "$(Build.ArtifactStagingDirectory)\msix\$(Filename).appxsym" *.pdb
    displayName: 'Build appxsym'
    workingDirectory: $(Build.BinariesDirectory)\symbols\$(Name)

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: MSIX'
    condition: and(succeeded(), or(ne(variables['ShouldSign'], 'true'), not(variables['SigningCertificate'])))
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)\msix'
      ArtifactName: msix

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: MSIX'
    condition: and(succeeded(), and(eq(variables['ShouldSign'], 'true'), variables['SigningCertificate']))
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)\msix'
      ArtifactName: unsigned_msix

  - powershell: |
      7z a -tzip "$(Build.ArtifactStagingDirectory)\msixupload\$(Filename).msixupload" *
    displayName: 'Build msixupload'
    condition: and(succeeded(), eq(variables['Upload'], 'true'))
    workingDirectory: $(Build.ArtifactStagingDirectory)\msix

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: MSIXUpload'
    condition: and(succeeded(), eq(variables['Upload'], 'true'))
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)\msixupload'
      ArtifactName: msixupload


- job: Sign_MSIX
  displayName: Sign side-loadable MSIX bundles
  dependsOn:
  - Pack_MSIX
  condition: and(succeeded(), variables['SigningCertificate'])

  pool:
    name: 'Windows Release'

  workspace:
    clean: all

  steps:
  - template: ./checkout.yml
  - template: ./find-sdk.yml

  - powershell: |
      $d = (.\PCbuild\build.bat -V) | %{ if($_ -match '\s+(\w+):\s*(.+)\s*$') { @{$Matches[1] = $Matches[2];} }};
      Write-Host "##vso[task.setvariable variable=SigningDescription]Python $($d.PythonVersion)"
    displayName: 'Update signing description'
    condition: and(succeeded(), not(variables['SigningDescription']))

  - task: DownloadBuildArtifacts@0
    displayName: 'Download Artifact: unsigned_msix'
    inputs:
      artifactName: unsigned_msix
      downloadPath: $(Build.BinariesDirectory)

  - powershell: |
      $failed = $true
      foreach ($retry in 1..3) {
          signtool sign /a /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "$(SigningDescription)" (gi *.msix)
          if ($?) {
              $failed = $false
              break
          }
          sleep 1
      }
      if ($failed) {
          throw "Failed to sign MSIX"
      }
    displayName: 'Sign MSIX'
    workingDirectory: $(Build.BinariesDirectory)\unsigned_msix

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: MSIX'
    inputs:
      PathtoPublish: '$(Build.BinariesDirectory)\unsigned_msix'
      ArtifactName: msix