microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
pipelines/azure-build-ts.yml
104lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # Licensed under the MIT License. |
| 3 | |
| 4 | resources: |
| 5 | repositories: |
| 6 | - repository: TypeAgent-GH |
| 7 | type: github |
| 8 | endpoint: AI_Systems |
| 9 | name: microsoft/typeagent |
| 10 | ref: refs/heads/main |
| 11 | |
| 12 | trigger: |
| 13 | branches: |
| 14 | include: |
| 15 | - main |
| 16 | |
| 17 | pr: |
| 18 | branches: |
| 19 | exclude: |
| 20 | - "*" |
| 21 | |
| 22 | pool: |
| 23 | vmImage: "ubuntu-latest" |
| 24 | |
| 25 | variables: |
| 26 | workingDirectory: "ts" |
| 27 | agentsdk_folder: "ts/packages/agentSdk" |
| 28 | |
| 29 | jobs: |
| 30 | - job: build_ts |
| 31 | displayName: "Build TypeScript Project" |
| 32 | strategy: |
| 33 | matrix: |
| 34 | node_22: |
| 35 | nodeVersion: "22" |
| 36 | steps: |
| 37 | - script: | |
| 38 | sudo apt install libsecret-1-0 |
| 39 | displayName: "Install libsecret-1-0" |
| 40 | condition: eq(variables['Agent.OS'], 'Linux') |
| 41 | |
| 42 | - checkout: TypeAgent-GH |
| 43 | displayName: "Checkout TypeAgent Repository" |
| 44 | path: "typeagent" |
| 45 | |
| 46 | - task: UseNode@1 |
| 47 | displayName: "Setup Node.js" |
| 48 | inputs: |
| 49 | version: $(nodeVersion) |
| 50 | checkLatest: true |
| 51 | |
| 52 | - template: include-install-pnpm.yml |
| 53 | parameters: |
| 54 | buildDirectory: $(Build.SourcesDirectory)/ts |
| 55 | |
| 56 | - script: | |
| 57 | pnpm install --frozen-lockfile --strict-peer-dependencies |
| 58 | displayName: "Install dependencies" |
| 59 | workingDirectory: $(workingDirectory) |
| 60 | |
| 61 | - script: | |
| 62 | current_version=$(node -p "require('./package.json').version") |
| 63 | new_version="${current_version}-$(Build.BuildId)" |
| 64 | echo "##vso[task.setvariable variable=package_version]$new_version" |
| 65 | jq ".version=\"$new_version\"" package.json > package.tmp.json |
| 66 | mv package.tmp.json package.json |
| 67 | echo "Updated package.json to version $new_version" |
| 68 | cat package.json |
| 69 | displayName: "Update Package Version" |
| 70 | workingDirectory: $(agentsdk_folder) |
| 71 | |
| 72 | - script: | |
| 73 | npm run build |
| 74 | displayName: "Build" |
| 75 | workingDirectory: $(workingDirectory) |
| 76 | |
| 77 | - script: | |
| 78 | npm run test:local |
| 79 | displayName: "Run Tests (Local)" |
| 80 | workingDirectory: $(workingDirectory) |
| 81 | |
| 82 | - script: | |
| 83 | npm run lint |
| 84 | displayName: "Lint" |
| 85 | workingDirectory: $(workingDirectory) |
| 86 | |
| 87 | - script: | |
| 88 | echo $(ADO_REGISTRY) |
| 89 | echo "registry=$(ADO_REGISTRY)" > .npmrc |
| 90 | echo "always-auth=true" >> .npmrc |
| 91 | cat .npmrc |
| 92 | displayName: "Create .npmrc file." |
| 93 | workingDirectory: $(agentsdk_folder) |
| 94 | |
| 95 | - task: npmAuthenticate@0 |
| 96 | inputs: |
| 97 | workingFile: "$(agentsdk_folder)/.npmrc" |
| 98 | displayName: "Authenticate with Azure Artifacts" |
| 99 | |
| 100 | - script: | |
| 101 | cd $(Build.SourcesDirectory)/$(agentsdk_folder) |
| 102 | npm publish --registry=$(ADO_REGISTRY) |
| 103 | displayName: "Pack and Publish agent-sdk Module" |
| 104 | condition: succeeded() |
| 105 | |