-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (69 loc) · 2.47 KB
/
cd.yml
File metadata and controls
78 lines (69 loc) · 2.47 KB
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
name: CD
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches: [ main ]
jobs:
publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: windows-latest
env:
VS_MARKETPLACE_TOKEN: ${{ secrets.VS_MARKETPLACE_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
permissions:
contents: write
actions: read
steps:
- uses: actions/checkout@v4.2.2
- name: Download build artifacts
uses: dawidd6/action-download-artifact@v6
with:
workflow: ci.yml
run_id: ${{ github.event.workflow_run.id }}
name: build-artifacts
path: artifacts
- name: Publish VSIX to marketplace
uses: cezarypiatek/VsixPublisherAction@1.1
with:
extension-file: artifacts/CustomCode-Analyzer.Vsix/bin/Release/CustomCode_Analyzer.vsix
publish-manifest-file: marketplace-publish.json
personal-access-code: ${{ secrets.VS_MARKETPLACE_TOKEN }}
continue-on-error: true
- name: Publish NuGet package
run: |
$packageFiles = Get-ChildItem -Path "artifacts/CustomCode-Analyzer/bin/Release/" -Filter "*.nupkg" -Recurse
foreach ($pkg in $packageFiles) {
Write-Output "Pushing package: $($pkg.FullName)"
dotnet nuget push $pkg.FullName --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json
}
shell: pwsh
continue-on-error: true
- name: Get version
id: version
run: |
$xml = [xml](Get-Content src/CustomCode-Analyzer/CustomCode-Analyzer.csproj)
$version = $xml.Project.PropertyGroup.Version
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Check if release exists
id: check_release
uses: octokit/request-action@v2.x
with:
route: GET /repos/${{ github.repository }}/releases/tags/v${{ steps.version.outputs.VERSION }}
env:
GITHUB_TOKEN: ${{ github.token }}
continue-on-error: true
- name: Create release
if: steps.check_release.outcome == 'failure'
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/CustomCode-Analyzer.Vsix/bin/Release/CustomCode_Analyzer.vsix
artifacts/CustomCode-Analyzer/bin/Release/*.nupkg
tag_name: v${{ steps.version.outputs.VERSION }}
name: Release v${{ steps.version.outputs.VERSION }}
draft: true
prerelease: false
generate_release_notes: true