Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mono-mono-signing.yml « ci « scripts - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9d0d59f8ea9b2a673c55127c14c0ba76a507126 (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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
parameters:
- name: mono_branch
  displayName: Branch of build
  type: string
  default: main
  values:
  - main
  - 2020-02
- name: mono_commit
  displayName: Full commit hash
  type: string
- name: mac_build_number
  displayName: Mac Jenkins build number
  type: number
  default: 0
- name: windows_build_number
  displayName: Windows Jenkins build number
  type: number
  default: 0

trigger: none

jobs:

## macOS .pkg signing

- job: MonoPkgSigning
  displayName: Mono .PKG Signing
  condition: ne(${{ parameters.mac_build_number }}, 0)
  pool:
    vmImage: 'macOS-10.15'
  timeoutInMinutes: 180
  workspace:
    clean: all

  steps:

  - checkout: none

  - script: |
      set -e
      gh api repos/mono/mono/statuses/${{ parameters.mono_commit }} --raw-field "state=pending" --raw-field "context=PKG-mono" --raw-field "target_url=$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)"
    displayName: Set pending GitHub status
    env:
      GITHUB_TOKEN: $(GITHUB_TOKEN)

  - script: |
      set -e
      cd $(Build.SourcesDirectory)
      MONO_SIGNED_PKG_DIR="${{ parameters.mono_branch }}/${{ parameters.mac_build_number }}/${{ parameters.mono_commit }}"
      az storage blob download-batch -s build-package-osx-mono -d . --pattern "$MONO_SIGNED_PKG_DIR/unsigned/*"
      cp $MONO_SIGNED_PKG_DIR/unsigned/mac-entitlements.plist .
      MONO_PKG_NAME=$(cd "$MONO_SIGNED_PKG_DIR/unsigned/" && ls *.pkg)
      echo "##vso[task.setvariable variable=MONO_PKG_NAME;]$MONO_PKG_NAME"
      echo "##vso[task.setvariable variable=MONO_SIGNED_PKG_DIR;]$MONO_SIGNED_PKG_DIR"
      pkgutil --expand "$MONO_SIGNED_PKG_DIR/unsigned/$MONO_PKG_NAME" expanded
      mkdir payload
      cd payload
      tar -xvf ../expanded/mono.pkg/Payload
    displayName: Download files and extract
    env:
      AZURE_STORAGE_ACCOUNT: $(AZURE_STORAGE_ACCOUNT)
      AZURE_STORAGE_KEY: $(AZURE_STORAGE_KEY)

  - script: |
      set -e
      cd $(Build.SourcesDirectory)/payload
      mkdir -p $(Build.ArtifactStagingDirectory)/mac_entitled
      for i in $(find Library -type f); do
        if file $i | grep Mach-O > /dev/null; then
          if [ "$(basename $i)" == "Microsoft.CodeAnalysis.CSharp.dll.dylib" ]; then
            echo "Remove i386 slice from $i"
            lipo -remove i386 $i -o $i
          fi
          echo "Codesigning $i"
          codesign -s - -f --options runtime --entitlements $(Build.SourcesDirectory)/mac-entitlements.plist $i
          ditto -V $i $(Build.ArtifactStagingDirectory)/mac_entitled/$i
        fi
      done
    displayName: Codesign Mach-O files

  - script: |
      set -e
      cd $(Build.ArtifactStagingDirectory)
      hdiutil create mac_entitled_to_sign.dmg -ov -volname "MacEntitledToSign" -fs HFS+ -srcfolder "mac_entitled"
    displayName: Archive binaries into .dmg for signing

  - task: UseDotNet@2
    displayName: 'Use .NET Core SDK 2.1.808'
    inputs:
      packageType: sdk
      version: 2.1.808

  - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
    displayName: 'ESRP CodeSigning binaries'
    timeoutInMinutes: 180
    inputs:
      ConnectedServiceName: 'ESRP CodeSigning'
      FolderPath: '$(Build.ArtifactStagingDirectory)/'
      Pattern: 'mac_entitled_to_sign.dmg'
      UseMinimatch: true
      signConfigType: inlineSignParams
      inlineOperation: |
        [
          {
            "keyCode": "CP-401337-Apple",
            "operationCode": "MacAppDeveloperSign",
            "parameters": {
              "hardening": "Enable"
            },
            "toolName": "sign",
            "toolVersion": "1.0"
          }
        ]

  - script: |
      set -e
      cd $(Build.ArtifactStagingDirectory)
      mkdir -p mac_entitled_signed
      hdiutil attach mac_entitled_to_sign.dmg
      cp -R /Volumes/MacEntitledToSign/Library mac_entitled_signed
    displayName: 'Extract binaries after signing'

  - script: |
      set -e
      cd $(Build.ArtifactStagingDirectory)/mac_entitled_signed
      for i in $(find Library -type f); do
        chmod +x $i
        ditto -V $i $(Build.SourcesDirectory)/payload/$i
      done
    displayName: Replace files with signed ones

  - script: |
      set -e
      cd $(Build.SourcesDirectory)
      pkgbuild --analyze --root $PWD/expanded $PWD/expanded/Info.plist
      mono_version=$(grep packageIdentifier $PWD/expanded/Distribution | sed -E 's/.*version="([0-9\.]+)".*/\1/g')
      pkgbuild --root $PWD/payload --component-plist $PWD/expanded/Info.plist --scripts $PWD/expanded/mono.pkg/Scripts --identifier com.xamarin.mono-MDK.pkg --version $mono_version --install-location / $PWD/mono.pkg
      productbuild --distribution $PWD/expanded/Distribution --resources $PWD/expanded/Resources --package-path $PWD/mono.pkg $PWD/mono-dist.pkg
      mkdir -p $(Build.ArtifactStagingDirectory)/mono-to-sign
      mv $PWD/mono-dist.pkg $(Build.ArtifactStagingDirectory)/mono-to-sign/$MONO_PKG_NAME
    displayName: pkgbuild and productbuild

  - script: |
      set -e
      cd $(Build.ArtifactStagingDirectory)
      hdiutil create mono-to-sign.dmg -ov -volname "MonoToSign" -fs HFS+ -srcfolder "mono-to-sign"
    displayName: Archive .pkg into .dmg for signing

  - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
    displayName: 'ESRP CodeSigning .pkg'
    timeoutInMinutes: 180
    inputs:
      ConnectedServiceName: 'ESRP CodeSigning'
      FolderPath: '$(Build.ArtifactStagingDirectory)/'
      Pattern: 'mono-to-sign.dmg'
      UseMinimatch: true
      signConfigType: inlineSignParams
      inlineOperation: |
        [
          {
            "keyCode": "CP-401337-Apple",
            "operationCode": "MacAppDeveloperSign",
            "parameters": {},
            "toolName": "sign",
            "toolVersion": "1.0"
          }
        ]

  - script: |
      set -e
      cd $(Build.ArtifactStagingDirectory)
      mkdir -p mono-signed
      hdiutil attach mono-to-sign.dmg
      cp -R /Volumes/MonoToSign/$MONO_PKG_NAME mono-signed
    displayName: 'Extract .pkg after signing'

  - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
    displayName: 'ESRP Notarizing .pkg'
    timeoutInMinutes: 180
    inputs:
      ConnectedServiceName: 'ESRP CodeSigning'
      FolderPath: '$(Build.ArtifactStagingDirectory)/mono-signed/'
      Pattern: '*.pkg'
      UseMinimatch: true
      signConfigType: inlineSignParams
      inlineOperation: |
        [
          {
            "keyCode": "CP-401337-Apple",
            "operationCode": "MacAppNotarize",
            "parameters": {
                "bundleId": "com.xamarin.mono-MDK.pkg"
            },
            "toolName": "sign",
            "toolVersion": "1.0"
          }
        ]

  - script: |
      set -e
      cd $(Build.ArtifactStagingDirectory)
      MONO_SIGNED_PKG="$(Build.ArtifactStagingDirectory)/mono-signed/$MONO_PKG_NAME"
      echo "##vso[task.setvariable variable=MONO_SIGNED_PKG;]$MONO_SIGNED_PKG"

      /usr/sbin/spctl -vvv --assess --type install --ignore-cache --no-cache $MONO_SIGNED_PKG
      xcrun stapler validate -v $MONO_SIGNED_PKG
    displayName: Validate .pkg

  - script: |
      set -e
      mono_sha=$(shasum --binary --algorithm 256 $MONO_SIGNED_PKG | cut -d ' ' -f 1)
      mono_mdfive=$(md5 -q $MONO_SIGNED_PKG)
      mono_size=$(stat -f "%z" $MONO_SIGNED_PKG)

      pkgutil --expand $MONO_SIGNED_PKG temp-mdk-extract
      mono_updateinfo=$(tar -xf temp-mdk-extract/mono.pkg/Payload --include '*/updateinfo' -O)
      mono_version=$(tar -xf temp-mdk-extract/mono.pkg/Payload --include '*/VERSION' --exclude '*/share' -O)

      mono_productid=$(echo $mono_updateinfo | cut -d ' ' -f1)
      mono_releaseid=$(echo $mono_updateinfo | cut -d ' ' -f2)

      jq -n --arg url "https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/$MONO_SIGNED_PKG_DIR/$MONO_PKG_NAME" \
            --arg sha256    "$mono_sha" \
            --arg md5       "$mono_mdfive" \
            --arg size      "$mono_size" \
            --arg productId "$mono_productid" \
            --arg releaseId "$mono_releaseid" \
            --arg version   "$mono_version" \
            '[{"url": $url, "sha256": $sha256, "md5": $md5, "size": $size, "productId": $productId, "releaseId": $releaseId, "version": $version }]' > $(Build.ArtifactStagingDirectory)/mono-signed/artifacts.json
    displayName: Create artifacts.json

  - publish: $(Build.ArtifactStagingDirectory)/mono-signed
    artifact: NotarizedPKG

  - script: |
      set -e
      cd $(Build.ArtifactStagingDirectory)
      az storage blob upload-batch -s mono-signed --destination-path "$MONO_SIGNED_PKG_DIR" --pattern "*" -d build-package-osx-mono --account-name xamjenkinsartifact
    displayName: Upload artifacts to blob storage
    env:
      AZURE_STORAGE_ACCOUNT: $(AZURE_STORAGE_ACCOUNT)
      AZURE_STORAGE_KEY: $(AZURE_STORAGE_KEY)

  - script: |
      set -e
      gh api repos/mono/mono/statuses/${{ parameters.mono_commit }} --raw-field "state=success" --raw-field "context=PKG-mono" --raw-field "target_url=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/$MONO_SIGNED_PKG_DIR/$MONO_PKG_NAME"
      gh api repos/mono/mono/statuses/${{ parameters.mono_commit }} --raw-field "state=success" --raw-field "context=artifacts.json" --raw-field "target_url=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/$MONO_SIGNED_PKG_DIR/artifacts.json"
    displayName: Set success GitHub status
    env:
      GITHUB_TOKEN: $(GITHUB_TOKEN)

## Windows .msi signing

- job: MonoMsiSigning
  displayName: Mono .MSI Signing
  condition: ne(${{ parameters.windows_build_number }}, 0)
  pool:
    vmImage: 'ubuntu-20.04'
  timeoutInMinutes: 180
  workspace:
    clean: all

  steps:

  - checkout: none

  - script: |
      gh api repos/mono/mono/statuses/${{ parameters.mono_commit }} --raw-field "state=pending" --raw-field "context=MSI-mono_x86" --raw-field "target_url=$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)"
      gh api repos/mono/mono/statuses/${{ parameters.mono_commit }} --raw-field "state=pending" --raw-field "context=MSI-mono_x64" --raw-field "target_url=$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)"
    displayName: Set pending GitHub status
    env:
      GITHUB_TOKEN: $(GITHUB_TOKEN)

  - script: |
      cd $(Build.SourcesDirectory)
      MONO_SIGNED_MSI_DIR="${{ parameters.mono_branch }}/${{ parameters.windows_build_number }}/${{ parameters.mono_commit }}"
      az storage blob download-batch -s build-package-win-mono -d . --pattern "$MONO_SIGNED_MSI_DIR/unsigned/*.msi"
      cp $MONO_SIGNED_MSI_DIR/unsigned/*.msi $(Build.ArtifactStagingDirectory)
      MONO_MSI_NAME_X86=$(cd "$MONO_SIGNED_MSI_DIR/unsigned/" && ls *win32*.msi)
      MONO_MSI_NAME_X64=$(cd "$MONO_SIGNED_MSI_DIR/unsigned/" && ls *x64*.msi)
      echo "##vso[task.setvariable variable=MONO_MSI_NAME_X86;]$MONO_MSI_NAME_X86"
      echo "##vso[task.setvariable variable=MONO_MSI_NAME_X64;]$MONO_MSI_NAME_X64"
      echo "##vso[task.setvariable variable=MONO_SIGNED_MSI_DIR;]$MONO_SIGNED_MSI_DIR"
    displayName: Download files
    env:
      AZURE_STORAGE_ACCOUNT: $(AZURE_STORAGE_ACCOUNT)
      AZURE_STORAGE_KEY: $(AZURE_STORAGE_KEY)

  - task: UseDotNet@2
    displayName: 'Use .NET Core SDK 2.1.808'
    inputs:
      packageType: sdk
      version: 2.1.808

  - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
    displayName: 'ESRP CodeSigning .msi'
    timeoutInMinutes: 180
    inputs:
      ConnectedServiceName: 'ESRP CodeSigning'
      FolderPath: '$(Build.ArtifactStagingDirectory)/'
      Pattern: '*.msi'
      UseMinimatch: true
      signConfigType: inlineSignParams
      inlineOperation: |
        [
          {
            "keyCode": "CP-230012",
            "operationCode": "SigntoolSign",
            "parameters": {
              "OpusName": "Mono",
              "OpusInfo": "https://www.mono-project.com",
              "PageHash": "/NPH",
              "FileDigest": "/fd sha256",
              "TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
            },
            "toolName": "sign",
            "toolVersion": "1.0"
          },
          {
            "keyCode": "CP-230012",
            "operationCode": "SigntoolVerify",
            "parameters": {
              "VerifyAll": "/all"
            },
            "toolName": "sign",
            "toolVersion": "1.0"
          }
        ]

  - publish: $(Build.ArtifactStagingDirectory)
    artifact: SignedMSI

  - script: |
      cd $(Build.ArtifactStagingDirectory)
      az storage blob upload-batch -s . --destination-path "$MONO_SIGNED_MSI_DIR" --pattern "*.msi" -d build-package-win-mono --account-name xamjenkinsartifact
    displayName: Upload artifacts to blob storage
    env:
      AZURE_STORAGE_ACCOUNT: $(AZURE_STORAGE_ACCOUNT)
      AZURE_STORAGE_KEY: $(AZURE_STORAGE_KEY)

  - script: |
      gh api repos/mono/mono/statuses/${{ parameters.mono_commit }} --raw-field "state=success" --raw-field "context=MSI-mono_x86" --raw-field "target_url=https://xamjenkinsartifact.azureedge.net/build-package-win-mono/$MONO_SIGNED_MSI_DIR/$MONO_MSI_NAME_X86"
      gh api repos/mono/mono/statuses/${{ parameters.mono_commit }} --raw-field "state=success" --raw-field "context=MSI-mono_x64" --raw-field "target_url=https://xamjenkinsartifact.azureedge.net/build-package-win-mono/$MONO_SIGNED_MSI_DIR/$MONO_MSI_NAME_X64"
    displayName: Set success GitHub status
    env:
      GITHUB_TOKEN: $(GITHUB_TOKEN)