Skip to content

Commit

Permalink
chore: support minor major semver bumps (#339)
Browse files Browse the repository at this point in the history
* feat: support major and minor semver bumps

* chore: set default CLI release channel to stable

* chore: test new wf

* chore: revert back test wf

* fix: use gh input options
  • Loading branch information
ShawkyZ authored Jan 9, 2025
1 parent 6794ceb commit 3a304bb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
26 changes: 23 additions & 3 deletions .github/actions/next-git-tag/next-git-tag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
Param(
[Parameter(Mandatory = $true)]
[ValidateSet("semver", "time")]
[string]$VersionType # Parameter to choose the versioning method: "semver" or "time"
[string]$VersionType, # Parameter to choose the versioning method: "semver" or "time"

[Parameter(Mandatory = $false)]
[ValidateSet("incrementPatch", "incrementMinor", "incrementMajor")]
[string]$BumpType = "incrementPatch" # Parameter to choose the bump type for semver mode
)

if ($VersionType -eq "semver") {
Expand All @@ -36,8 +40,24 @@ if ($VersionType -eq "semver") {
Write-Verbose "MINOR part: $Minor"
Write-Verbose "PATCH part: $Patch"

# Hardcoded increment for patch
$Patch += 1
switch ($BumpType) {
"incrementMajor" {
$Major += 1
$Minor = 0
$Patch = 0
}
"incrementMinor" {
$Minor += 1
$Patch = 0
}
"incrementPatch" {
$Patch += 1
}
default {
Write-Error "Invalid bump type specified: $BumpType"
exit 1
}
}

$NextSemverTag = "$Major.$Minor.$Patch"
Write-Host "Next SemVer tag: $NextSemverTag"
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
channel:
type: string
default: preview
incrementLevel:
description: 'Version level to increment'
type: string
default: incrementPatch
outputs:
version:
description: 'next Git tag in semver format'
Expand All @@ -32,7 +36,7 @@ jobs:
id: vsix_version
run: |
if ("${{ inputs.channel}}" -eq "stable") {
& ".\.github\actions\next-git-tag\next-git-tag.ps1" semver
& ".\.github\actions\next-git-tag\next-git-tag.ps1" semver "${{ inputs.incrementLevel }}"
}
elseif ("${{ inputs.channel }}" -eq "preview") {
& ".\.github\actions\next-git-tag\next-git-tag.ps1" time
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
with:
solution-file-path: .
channel: preview
incrementLevel: incrementPatch
secrets: inherit
run-integration-tests:
needs: build-project
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ name: Release Extension

on:
workflow_dispatch:

inputs:
incrementLevel:
description: 'Version level to increment'
required: true
type: choice
options:
- incrementPatch
- incrementMinor
- incrementMajor
default: incrementPatch
env:
SOLUTION_FILE_PATH: .
DEFAULT_BRANCH: main
Expand All @@ -13,6 +22,7 @@ jobs:
with:
solution-file-path: .
channel: stable
incrementLevel: ${{ inputs.incrementLevel }}
secrets: inherit
run-integration-tests:
needs: build-project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Snyk.VisualStudio.Extension.Download
public class SnykCliDownloader
{
public const string DefaultBaseDownloadUrl = "https://downloads.snyk.io";
public const string DefaultReleaseChannel = "preview";
public const string DefaultReleaseChannel = "stable";

private const string LatestReleaseVersionUrlScheme = "{0}/cli/{1}/ls-protocol-version-" + LsConstants.ProtocolVersion;
private const string LatestReleaseDownloadUrlScheme = "{0}/cli/{1}/" + SnykCli.CliFileName;
Expand Down

0 comments on commit 3a304bb

Please sign in to comment.