-
Notifications
You must be signed in to change notification settings - Fork 8
165 lines (141 loc) · 5.94 KB
/
publish.yml
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
name: Publish
on:
workflow_dispatch:
inputs:
publish:
type: choice
description: Publish type
default: Preview
options:
- Preview
- Release
# concurrency prevents multiple instances of the workflow from running at the same time,
# using `cancel-in-progress` to cancel any existing runs.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: 16gb_16_core_large_window_runner
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
checks: write
pull-requests: write
# do we want to run this on forks?
if: github.repository_owner == 'sourcegraph'
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
Configuration: Release
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- name: Generate version
uses: ./.github/actions/next-version-gen
id: version
with:
publish-type: ${{ github.event.inputs.publish }}
- name: Add msbuild
uses: microsoft/setup-msbuild@v2
- name: Cache nuget
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ github.sha }}
restore-keys: ${{ runner.os }}-nuget-
- name: Cache agent (${{ steps.version.outputs.agent-version }})
id: cache-agent
uses: actions/cache@v4
with:
path: src/Cody.VisualStudio/Agent
key: ${{ runner.os }}-agent-${{ hashFiles('agent/agent.version', 'agent/buildAgent.ps1', 'agent/runBuildAgent.ps1') }}
- name: Build agent if needed
if: ${{ steps.cache-agent.outputs.cache-hit != 'true' }}
shell: pwsh
run: ./agent/runBuildAgent.ps1
- name: Set version on AssemblyInfo.cs files (${{ steps.version.outputs.next-version }})
uses: dannevesdantas/[email protected]
with:
version: ${{ steps.version.outputs.next-version }}
path: src/
- name: Set version for .vsixmanifest file (${{ steps.version.outputs.next-version }})
uses: cezarypiatek/[email protected]
with:
version: ${{ steps.version.outputs.next-version }}
vsix-manifest-file: src\Cody.VisualStudio\source.extension.vsixmanifest
- name: Build extension (${{ env.Configuration }})
run: msbuild src/Cody.sln -t:Build -restore -verbosity:minimal -property:Configuration=${{ env.Configuration }}
- name: Upload Cody.VisualStudio.vsix artifact
uses: actions/upload-artifact@v4
with:
name: Cody.VisualStudio.vsix
path: src/Cody.VisualStudio/bin/${{ env.Configuration }}/Cody.VisualStudio.vsix
#Running tests
- name: Change Screen Resolution
shell: pwsh
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Run tests
env:
Access_Token_UI_Tests: ${{ secrets.SRC_ACCESS_TOKEN_DOTCOM }}
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: '--remote-debugging-port=9222'
run: dotnet test src/*Tests/bin/${{ env.Configuration }}/*.Tests.dll --logger:trx --verbosity detailed
- name: Upload screenshots for UI tests
uses: actions/upload-artifact@v4
if: always()
with:
name: UI Tests Screenshots
path: src/Cody.VisualStudio.Tests/bin/${{ env.Configuration }}/Screenshots
retention-days: 10
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: TestResults/**/*.trx
#Publish
- name: Create git tag (${{ steps.version.outputs.next-version-tag }})
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.version.outputs.next-version-tag }}",
sha: context.sha
})
- name: Create GitHub release
uses: ncipollo/[email protected]
with:
tag: ${{ steps.version.outputs.next-version-tag }}
name: Cody for Visual Studio ${{ steps.version.outputs.next-version }}
omitBody: true
prerelease: ${{ github.event.inputs.publish == 'Preview' }}
artifacts: src/Cody.VisualStudio/bin/${{ env.Configuration }}/Cody.VisualStudio.vsix
- name: Create custom VSIX feed
if: ${{ github.event.inputs.publish == 'Preview' }}
uses: ./.github/actions/create-vsix-feed
with:
vsix-directory: src/Cody.VisualStudio/bin/${{ env.Configuration }}
feed-file: feed/feed.xml
source-path: https://github.com/sourcegraph/cody-vs/releases/download/${{ steps.version.outputs.next-version-tag }}/
gallery-name: "Sourcegraph preview gallery"
- name: Upload feed files as artifact
if: ${{ github.event.inputs.publish == 'Preview' }}
uses: actions/upload-pages-artifact@v3
with:
name: vsix-gallery-feed
path: feed/
- name: Deploy feed to GitHub Pages
if: ${{ github.event.inputs.publish == 'Preview' }}
uses: actions/deploy-pages@v4
with:
artifact_name: vsix-gallery-feed
- name: Publish to Visual Studio Marketplace
if: ${{ github.event.inputs.publish == 'Release' }}
uses: cezarypiatek/[email protected]
with:
extension-file: src/Cody.VisualStudio/bin/${{ env.Configuration }}/Cody.VisualStudio.vsix
publish-manifest-file: src\Cody.VisualStudio\publishManifest.json
personal-access-code: ${{ secrets.CODY_VS_MARKETPLACE_RELEASE_TOKEN }}