Skip to content

Commit aefb46b

Browse files
[ROAD-641] Fix: deployment pipeline for vs (#102)
* chore: introduce local action * chore: combine releasing into one workflow step * chore: add version prefix for 2022 vsix file when uploading to releases * chore: incorporate changes from review Co-authored-by: Pavel Sorokin <60606414+pavel-snyk@users.noreply.github.com>
1 parent edef85a commit aefb46b

5 files changed

Lines changed: 108 additions & 137 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: 'Get Next SemVer Tag'
2+
description: 'Get next Git tag in semver format'
3+
outputs:
4+
next-tag:
5+
description: 'next Git tag in semver format'
6+
value: ${{ steps.get-next-semver-tag.outputs.next-tag }}
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- id: get-next-semver-tag
11+
run: ${{ github.action_path }}/next-git-tag.ps1
12+
shell: pwsh
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<#
2+
.SYNOPSIS
3+
This script calculates a next Git tag in SemVer format.
4+
#>
5+
[CmdletBinding()]
6+
Param()
7+
8+
[string[]]$AllTags = (git tag --sort=committerdate)
9+
Write-Verbose "all tags: $AllTags"
10+
$LatestTag = $AllTags[$AllTags.Length - 1]
11+
Write-Host "Found latest Git tag: $LatestTag"
12+
13+
# split the tag by dots and increment patch version
14+
$v = $LatestTag -split "\."
15+
[string] $MajorStr = $v[0]
16+
[int] $Major = 0
17+
if ($MajorStr.StartsWith("v"))
18+
{
19+
$Major = $MajorStr.Substring(1)
20+
}
21+
else
22+
{
23+
$Major = $MajorStr
24+
}
25+
[int] $Minor = $v[1]
26+
[int] $Patch = $v[2]
27+
28+
Write-Verbose "MAJOR part: $Major"
29+
Write-Verbose "MINOR part: $Minor"
30+
Write-Verbose "PATCH part: $Patch"
31+
32+
# hardcoded increment for patch
33+
$Patch += 1;
34+
35+
$NextSemverTag = "$Major.$Minor.$Patch"
36+
Write-Host "Next SemVer tag: $NextSemverTag"
37+
38+
# Return next tag to workflow
39+
echo "::set-output name=next-tag::$NextSemverTag"

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0
25+
2326
- uses: microsoft/variable-substitution@v1
2427
with:
2528
files: '.\Snyk.Common\appsettings.json'
@@ -37,7 +40,7 @@ jobs:
3740
- name: Setup VSTest
3841
uses: darenm/Setup-VSTest@v1
3942

40-
- name: Restore NuGet packages
43+
- name: Restore NuGet packages
4144
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
4245

4346
- name: Build

.github/workflows/release-2022.yml

Lines changed: 0 additions & 108 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ jobs:
2424

2525
steps:
2626
- uses: actions/checkout@v2
27-
28-
- name: Unshallow
29-
run: git fetch --prune --unshallow
30-
27+
with:
28+
fetch-depth: 0
29+
3130
- uses: actions/cache@v2
3231
with:
3332
path: ~/.nuget/packages
3433
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.config') }}
3534
restore-keys: |
3635
${{ runner.os }}-nuget-
37-
36+
3837
- uses: microsoft/variable-substitution@v1
3938
with:
4039
files: '.\Snyk.Common\appsettings.json'
@@ -55,54 +54,80 @@ jobs:
5554
- name: Restore NuGet packages
5655
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
5756

58-
- name: Increment VSIX version
57+
- name: Calculate next semantic version Git tag (vsix version)
5958
id: vsix_version
60-
uses: timheuer/vsix-version-stamp@v1
59+
uses: ./.github/actions/next-git-tag -Verbose
60+
61+
- name: Set VSIX version for 2015-2019
62+
uses: cezarypiatek/VsixVersionAction@1.0
6163
with:
62-
manifest-file: ${{ env.VsixManifestPath }}
63-
64-
- name: Set up Git actions user
65-
uses: fregante/setup-git-user@v1
66-
67-
- name: Commit new version
68-
run: |
69-
git commit -am 'increment new version'
70-
git tag ${{ steps.vsix_version.outputs.version-number }}
71-
git push origin main
72-
git push origin main --tags
73-
64+
version: ${{ steps.vsix_version.outputs.next-tag }}
65+
vsix-manifest-file: .\Snyk.VisualStudio.Extension\source.extension.vsixmanifest
66+
67+
- name: Set VSIX version for 2022
68+
uses: cezarypiatek/VsixVersionAction@1.0
69+
with:
70+
version: ${{ steps.vsix_version.outputs.next-tag }}
71+
vsix-manifest-file: .\Snyk.VisualStudio.Extension.2022\source.extension.vsixmanifest
72+
7473
- name: Build
7574
run: |
7675
msbuild ${{env.SOLUTION_FILE_PATH}} /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m
7776
shell: powershell
7877

7978
- name: Tests
8079
run: vstest.console.exe **\*.Tests.dll
81-
82-
- name: Create Release
80+
81+
- name: Set up Git actions user
82+
uses: fregante/setup-git-user@v1
83+
84+
- name: Create and push Git tag release
85+
run: |
86+
git tag ${{ steps.vsix_version.outputs.next-tag }}
87+
git push origin main
88+
git push origin main --tags
89+
90+
- name: Create GitHub Release
8391
id: create_release
8492
uses: actions/create-release@v1
8593
env:
8694
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8795
with:
88-
tag_name: ${{ steps.vsix_version.outputs.version-number }}
89-
release_name: Release ${{ steps.vsix_version.outputs.version-number }}
96+
tag_name: ${{ steps.vsix_version.outputs.next-tag }}
97+
release_name: Release ${{ steps.vsix_version.outputs.next-tag }}
9098
draft: false
9199
prerelease: false
92-
- name: Upload Release Asset
93-
id: upload-release-asset
100+
101+
- name: Upload GitHub Release 2015-2019 Asset
94102
uses: actions/upload-release-asset@v1
95103
env:
96104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97105
with:
98-
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
106+
upload_url: ${{ steps.create_release.outputs.upload_url }}
99107
asset_path: .\Snyk.VisualStudio.Extension\bin\Release\Snyk.VisualStudio.Extension.vsix
100-
asset_name: Snyk_Vulnerability_Scanner-${{ steps.vsix_version.outputs.version-number }}.vsix
108+
asset_name: Snyk_Vulnerability_Scanner-${{ steps.vsix_version.outputs.next-tag }}.vsix
101109
asset_content_type: application/zip
102-
110+
111+
- name: Upload GitHub Release 2022 Asset
112+
uses: actions/upload-release-asset@v1
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
with:
116+
upload_url: ${{ steps.create_release.outputs.upload_url }}
117+
asset_path: .\Snyk.VisualStudio.Extension.2022\bin\Release\Snyk.VisualStudio.Extension.vsix
118+
asset_name: Snyk_Vulnerability_Scanner-${{ steps.vsix_version.outputs.next-tag }}-2022.vsix
119+
asset_content_type: application/zip
120+
103121
- name: Publish 2015-2019 extension to Marketplace
104122
uses: cezarypiatek/VsixPublisherAction@0.1
105123
with:
106124
extension-file: '.\Snyk.VisualStudio.Extension\bin\Release\Snyk.VisualStudio.Extension.vsix'
107125
publish-manifest-file: '.\Snyk.VisualStudio.Extension\vs-publish.json'
108126
personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }}
127+
128+
- name: Publish 2022 extension to Marketplace
129+
uses: cezarypiatek/VsixPublisherAction@0.1
130+
with:
131+
extension-file: '.\Snyk.VisualStudio.Extension.2022\bin\Release\Snyk.VisualStudio.Extension.vsix'
132+
publish-manifest-file: '.\Snyk.VisualStudio.Extension.2022\vs-publish.json'
133+
personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)