microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
pipelines/azure-build-package-shell.yml
133lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # Licensed under the MIT License. |
| 3 | |
| 4 | trigger: |
| 5 | branches: |
| 6 | include: |
| 7 | - main |
| 8 | |
| 9 | pr: |
| 10 | branches: |
| 11 | exclude: |
| 12 | - "*" |
| 13 | |
| 14 | parameters: |
| 15 | - name: channel |
| 16 | type: string |
| 17 | default: test |
| 18 | values: |
| 19 | - test |
| 20 | - lkg |
| 21 | |
| 22 | variables: |
| 23 | - name: buildDirectory |
| 24 | value: $(Build.SourcesDirectory)/ts |
| 25 | - name: shell_folder |
| 26 | value: $(buildDirectory)/packages/shell |
| 27 | - name: nodeVersion |
| 28 | value: 22 |
| 29 | - name: platforms |
| 30 | value: win,linux,mac |
| 31 | - name: ELECTRON_CACHE_DIR |
| 32 | value: $(Pipeline.Workspace)/cache/ |
| 33 | - name: ELECTRON_CACHE |
| 34 | value: $(ELECTRON_CACHE_DIR)electron |
| 35 | - name: ELECTRON_BUILDER_CACHE |
| 36 | value: $(ELECTRON_CACHE_DIR)electron-builder-cache |
| 37 | - name: channel |
| 38 | ${{ if eq(variables['Build.Reason'], 'Manual') }}: |
| 39 | value: ${{ parameters.channel }} |
| 40 | ${{ if ne(variables['Build.Reason'], 'Manual') }}: |
| 41 | value: ci |
| 42 | |
| 43 | jobs: |
| 44 | - job: build_package_shell |
| 45 | displayName: Build TypeAgent Shell |
| 46 | strategy: |
| 47 | matrix: |
| 48 | windows: |
| 49 | image: windows-latest |
| 50 | platform: win |
| 51 | linux: |
| 52 | image: ubuntu-latest |
| 53 | platform: linux |
| 54 | mac: |
| 55 | image: macos-latest |
| 56 | platform: mac |
| 57 | pool: |
| 58 | vmImage: $(image) |
| 59 | steps: |
| 60 | - template: include-prepare-repo.yml |
| 61 | parameters: |
| 62 | buildDirectory: $(buildDirectory) |
| 63 | nodeVersion: $(nodeVersion) |
| 64 | registry: $(REGISTRY) |
| 65 | |
| 66 | - template: include-update-package-version.yml |
| 67 | parameters: |
| 68 | buildDirectory: $(buildDirectory) |
| 69 | prerelease: $(channel).$(Build.BuildNumber) |
| 70 | |
| 71 | - script: | |
| 72 | pnpm run build:shell |
| 73 | displayName: Build Shell |
| 74 | workingDirectory: $(buildDirectory) |
| 75 | |
| 76 | - task: Cache@2 |
| 77 | displayName: Cache Electron Builder |
| 78 | inputs: |
| 79 | key: electron | $(Agent.OS) | $(Agent.OSArchitecture) | $(buildDirectory)/pnpm-lock.yaml |
| 80 | path: $(ELECTRON_CACHE_DIR) |
| 81 | restoreKeys: | |
| 82 | electron | $(Agent.OS) | $(Agent.OSArchitecture) |
| 83 | |
| 84 | - script: | |
| 85 | pnpm run shell:package |
| 86 | displayName: Package - shell |
| 87 | workingDirectory: $(buildDirectory) |
| 88 | env: |
| 89 | ELECTRON_BUILDER_CHANNEL: $(channel) |
| 90 | |
| 91 | # For backward compat, can be remove in the future |
| 92 | - script: | |
| 93 | copy %ELECTRON_BUILDER_CHANNEL%-x64.yml %ELECTRON_BUILDER_CHANNEL%.yml |
| 94 | displayName: Copy windows x64 to default channel file |
| 95 | condition: eq(variables['Agent.OS'], 'Windows_NT') |
| 96 | workingDirectory: $(shell_folder)/dist |
| 97 | env: |
| 98 | ELECTRON_BUILDER_CHANNEL: $(channel) |
| 99 | |
| 100 | - publish: $(shell_folder)/dist |
| 101 | displayName: Upload Artifact |
| 102 | artifact: shell-$(platform) |
| 103 | |
| 104 | - deployment: publish |
| 105 | displayName: Publish TypeAgent Shell |
| 106 | environment: typeagent-shell-$(channel) |
| 107 | dependsOn: build_package_shell |
| 108 | pool: |
| 109 | # AzureFileCopy requires windows |
| 110 | vmImage: windows-latest |
| 111 | strategy: |
| 112 | runOnce: |
| 113 | deploy: |
| 114 | steps: |
| 115 | - ${{ each platform in split(variables.platforms, ',') }}: |
| 116 | - download: current |
| 117 | artifact: shell-${{ platform }} |
| 118 | displayName: Download shell package - ${{ platform }} |
| 119 | patterns: | |
| 120 | TypeAgent Shell[-_]* |
| 121 | typeagentshell-* |
| 122 | $(channel)*.yml |
| 123 | condition: succeeded() |
| 124 | |
| 125 | - task: AzureFileCopy@6 |
| 126 | displayName: Upload Azure Storage - ${{ platform }} |
| 127 | inputs: |
| 128 | SourcePath: $(Pipeline.Workspace)\shell-${{ platform }}\** |
| 129 | Destination: AzureBlob |
| 130 | azureSubscription: $(azureSubscription) |
| 131 | storage: $(azureStorageAccountName) |
| 132 | ContainerName: $(azureStorageContainerName) |
| 133 | condition: succeeded() |
| 134 | |