microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
pipelines/azure-build-ts.yml
102lines · 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 | pool: |
| 15 | vmImage: "ubuntu-latest" |
| 16 | |
| 17 | variables: |
| 18 | - name: buildDirectory |
| 19 | value: $(Build.SourcesDirectory)/ts |
| 20 | - name: packageDirectory |
| 21 | value: $(Build.ArtifactStagingDirectory)/packages |
| 22 | - name: publishedPackageDirectory |
| 23 | value: $(Build.ArtifactStagingDirectory)/packages/published |
| 24 | - name: NpmRcDirectory |
| 25 | value: $(Build.SourcesDirectory) |
| 26 | jobs: |
| 27 | - job: build_ts |
| 28 | displayName: "Build TypeScript Project" |
| 29 | strategy: |
| 30 | matrix: |
| 31 | node_22: |
| 32 | nodeVersion: "22" |
| 33 | steps: |
| 34 | - template: include-prepare-repo.yml |
| 35 | parameters: |
| 36 | buildDirectory: $(buildDirectory) |
| 37 | nodeVersion: $(nodeVersion) |
| 38 | registry: $(REGISTRY) |
| 39 | |
| 40 | - template: include-update-package-version.yml |
| 41 | parameters: |
| 42 | buildDirectory: $(buildDirectory) |
| 43 | prerelease: $(Build.BuildId) |
| 44 | |
| 45 | - script: | |
| 46 | npm run build |
| 47 | displayName: "Build" |
| 48 | workingDirectory: $(buildDirectory) |
| 49 | |
| 50 | - script: | |
| 51 | pnpm pack --filter @typeagent/* --pack-destination $(publishedPackageDirectory) |
| 52 | displayName: "Pack Published packages" |
| 53 | workingDirectory: $(buildDirectory) |
| 54 | |
| 55 | - script: | |
| 56 | pnpm pack --filter=\!@typeagent/* --pack-destination $(packageDirectory) |
| 57 | displayName: "Pack Non-published packages" |
| 58 | workingDirectory: $(buildDirectory) |
| 59 | |
| 60 | - publish: $(packageDirectory) |
| 61 | artifact: Packages |
| 62 | |
| 63 | - script: | |
| 64 | sudo apt install libsecret-1-0 |
| 65 | displayName: "Install libsecret-1-0" |
| 66 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) |
| 67 | |
| 68 | - script: | |
| 69 | npm run test:local |
| 70 | displayName: "Run Tests (Local)" |
| 71 | workingDirectory: $(buildDirectory) |
| 72 | |
| 73 | - script: | |
| 74 | npm run lint |
| 75 | displayName: "Lint" |
| 76 | workingDirectory: $(buildDirectory) |
| 77 | |
| 78 | - script: | |
| 79 | npm run check:policy |
| 80 | displayName: "Check Policy" |
| 81 | workingDirectory: $(buildDirectory) |
| 82 | |
| 83 | - script: | |
| 84 | echo $(ADO_REGISTRY) |
| 85 | echo "registry=$(ADO_REGISTRY)" > .npmrc |
| 86 | echo "always-auth=true" >> .npmrc |
| 87 | cat .npmrc |
| 88 | displayName: "Create .npmrc file." |
| 89 | workingDirectory: $(NpmRcDirectory) |
| 90 | |
| 91 | - task: npmAuthenticate@0 |
| 92 | inputs: |
| 93 | workingFile: "$(NpmRcDirectory)/.npmrc" |
| 94 | displayName: "Authenticate with Azure Artifacts" |
| 95 | |
| 96 | - script: | |
| 97 | for file in $(publishedPackageDirectory)/*.tgz; do |
| 98 | echo "Publishing file: $file" |
| 99 | npm publish --registry=$(ADO_REGISTRY) "$file" |
| 100 | done |
| 101 | displayName: "Publish packages" |
| 102 | workingDirectory: $(NpmRcDirectory) |
| 103 | |