Skip to content

Commit

Permalink
ci: Only publish components if they had relevant changes in the last …
Browse files Browse the repository at this point in the history
…release (closes #84)
  • Loading branch information
chrissimon-au committed Sep 11, 2024
1 parent 9281e37 commit cdf2d4a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 30 deletions.
14 changes: 13 additions & 1 deletion src/.releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@
"numReplacements": 1
}],
"countMatches": true
},{
"files": ["LAST_RELEASE_NOTES.md"],
"from": ".*",
"to": "${nextRelease.notes}",
"results": [{
"file": "LAST_RELEASE_NOTES.md",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}],
"countMatches": true
}]
}],
["@semantic-release/npm",{
Expand All @@ -128,7 +139,8 @@
"intellij/contextive/src/main/resources/META-INF/plugin.xml",
"visualstudio/contextive/contextive/contextive.csproj",
"visualstudio/contextive/contextive/README.md",
"visualstudio/contextive/contextive/ContextiveExtension.cs"
"visualstudio/contextive/contextive/ContextiveExtension.cs",
"LAST_RELEASE_NOTES.md"
]
}],
"@semantic-release/github"
Expand Down
16 changes: 16 additions & 0 deletions src/LAST_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# [1.12.0](https://github.com/dev-cycles/contextive/compare/v1.11.1...v1.12.0) (2024-09-04)


### Bug Fixes

* **intellij:** Add support for 2042.2 series of intellij platform ([08308bf](https://github.com/dev-cycles/contextive/commit/08308bff2056fd1af764d88649de7fe90b8516b1))


### Features

* **language-server:** Add support for LSP Clients that only support rootUri and not workspaces (e.g. Visual Studio) ([7fe11b3](https://github.com/dev-cycles/contextive/commit/7fe11b3831d6f8b8f86d1d10817c7ba50a0163c0))
* **language-server:** Add yaml schema for definitions file ([#74](https://github.com/dev-cycles/contextive/issues/74)) ([65ec44a](https://github.com/dev-cycles/contextive/commit/65ec44a16de20357b69d1662cfc70521298287da))
* **language-server:** Only use 'window/showMessage' if it is supported by the LanguageClient (e.g. Visual Studio does not support it) ([965cb30](https://github.com/dev-cycles/contextive/commit/965cb30539ea05357dfd6cdf4e2bb44406d8a16c))
* **language-server:** validate definitions file for missing term names ([0fb0978](https://github.com/dev-cycles/contextive/commit/0fb0978640f594843d1f8ff25959ea3d0bf729ae))
* **visual-studio:** Add Visual Studio integration ([b052a82](https://github.com/dev-cycles/contextive/commit/b052a82df7df39d518760f8dfcae84771505262f)), closes [#28](https://github.com/dev-cycles/contextive/issues/28)
* **vscode:** Publish to Open-Vsx Marketplace (closes [#80](https://github.com/dev-cycles/contextive/issues/80)) ([2d23775](https://github.com/dev-cycles/contextive/commit/2d23775c6c99468319fdf68d7bad2b1997fad883))
18 changes: 10 additions & 8 deletions src/ci/common.fsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#r "nuget: Fun.Build, 1.0.5"
#r "nuget: Fun.Build, 1.1.7"

open Fun.Build

Expand Down Expand Up @@ -44,9 +44,6 @@ let ifTopLevelStage fn (ctx: Internal.StageContext) =
| ValueSome(Internal.StageParent.Pipeline _) -> fn ctx
| _ -> ()

let echoGitHubGroupStart (ctx: Internal.StageContext) = printfn "::group::%s" ctx.Name
let echoGitHubGroupEnd (_: Internal.StageContext) = printfn "::endgroup::"

let ghError msg =
printfn $"::error ::{msg}"
Error(msg)
Expand All @@ -70,10 +67,6 @@ let unzipCmd zipPath outputPath =
| "" -> $"unzip {zipPath} -d {outputPath}"
| _ -> $"7z e {zipPath} -o{outputPath}"

let gitHubGroupStart = ifTopLevelStage <| echoGitHubGroupStart

let gitHubGroupEnd = ifTopLevelStage <| echoGitHubGroupEnd

let dotnetRestoreTools =
stage $"Dotnet Restore Tools" { run "dotnet tool restore" }

Expand Down Expand Up @@ -103,3 +96,12 @@ let core =
let languageServer =
{ Name = "Contextive.LanguageServer"
Path = "language-server/Contextive.LanguageServer" }

let whenComponentInRelease (component': string) = whenStage $"Check for component {component'} in LAST_CHANGE.md" {
run (fun ctx ->
seq { component'; "language-server" }
|> String.concat "|"
|> sprintf "grep -E (%s) LAST_RELEASE_NOTES.md"
|> ctx.RunCommand
)
}
10 changes: 6 additions & 4 deletions src/intellij/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#load "../ci/common.fsx"

open Fun.Build

open Fun.Build.Github
open Common

let distPath: string = "intellij/contextive/build/distributions"
Expand All @@ -16,8 +16,7 @@ let intelliJAssetLabel (ctx: Internal.StageContext) =
pipeline "Contextive IntelliJ Plugin" {
description "Build & Test"
noPrefixForStep
runBeforeEachStage gitHubGroupStart
runAfterEachStage gitHubGroupEnd
collapseGithubActionLogs

logEnvironment

Expand All @@ -33,7 +32,10 @@ pipeline "Contextive IntelliJ Plugin" {
run (fun ctx -> $"gh release upload {ctx.GetCmdArg(args.release)} {intelliJAssetFileName ctx}")
}

stage "Publish Package" { run (bashCmd "./gradlew publishPlugin") }
stage "Publish Package" {
whenComponentInRelease "intellij"
run (bashCmd "./gradlew publishPlugin")
}
}

runIfOnlySpecified false
Expand Down
5 changes: 2 additions & 3 deletions src/language-server/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#load "../ci/common.fsx"

open Fun.Build

open Fun.Build.Github
open Common

let languageServerLabel (ctx: Internal.StageContext) =
Expand Down Expand Up @@ -100,8 +100,7 @@ let zipAndUploadAsset app =
pipeline languageServer.Name {
description "Build & Test"
// noPrefixForStep
runBeforeEachStage gitHubGroupStart
runAfterEachStage gitHubGroupEnd
collapseGithubActionLogs

logEnvironment

Expand Down
4 changes: 2 additions & 2 deletions src/release.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#load "ci/common.fsx"

open Fun.Build
open Fun.Build.Github
open FSharp.Data
open FsToolkit.ErrorHandling
open FsToolkit.ErrorHandling.Operator.AsyncResult
Expand Down Expand Up @@ -72,8 +73,7 @@ let checkReleaseStatus (ctx: Internal.StageContext) =

pipeline "Contextive Release" {
noPrefixForStep
runBeforeEachStage gitHubGroupStart
runAfterEachStage gitHubGroupEnd
collapseGithubActionLogs

stage "Check Build Status" {
whenEnv { name args.headSha.Name }
Expand Down
11 changes: 6 additions & 5 deletions src/visualstudio/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#load "../ci/common.fsx"

open Fun.Build

open Fun.Build.Github
open Common

let visualStudioProjectPath = "visualstudio/contextive/contextive"
Expand All @@ -19,8 +19,7 @@ let vsixPublisherExe = """C:\Program Files\Microsoft Visual Studio\2022\Enterpri
pipeline "Contextive Visual Studio Extension" {
description "Build & Test"
noPrefixForStep
runBeforeEachStage gitHubGroupStart
runAfterEachStage gitHubGroupEnd
collapseGithubActionLogs

logEnvironment

Expand Down Expand Up @@ -64,8 +63,10 @@ pipeline "Contextive Visual Studio Extension" {
}

// See https://learn.microsoft.com/en-us/visualstudio/extensibility/walkthrough-publishing-a-visual-studio-extension-via-command-line?view=vs-2022
stage "Publish to Marketplace" { run (fun ctx ->
$"\"{vsixPublisherExe}\" publish -payload \"{visualStudioAssetRelativePath}/{visualStudioAssetFileName}\" -publishManifest \"publishmanifest.json\" -personalAccessToken \"{ctx.GetEnvVar(args.vscePat.Name)}\""
stage "Publish to Marketplace" {
whenComponentInRelease "visual-studio"
run (fun ctx ->
$"\"{vsixPublisherExe}\" publish -payload \"{visualStudioAssetRelativePath}/{visualStudioAssetFileName}\" -publishManifest \"publishmanifest.json\" -personalAccessToken \"{ctx.GetEnvVar(args.vscePat.Name)}\""
) }
}

Expand Down
16 changes: 9 additions & 7 deletions src/vscode/build.fsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#r "nuget: Fun.Build, 1.0.5"
#load "../ci/common.fsx"

open Fun.Build

open Fun.Build.Github
open Common

let vsCodeAssetFileName (ctx: Internal.StageContext) =
Expand All @@ -21,9 +20,8 @@ let publishTag (ctx: Internal.StageContext) =
pipeline "Contextive VsCode Extension" {
description "Build & Test"
noPrefixForStep
runBeforeEachStage gitHubGroupStart
runAfterEachStage gitHubGroupEnd

collapseGithubActionLogs

logEnvironment

stage "Install Tools" {
Expand Down Expand Up @@ -133,8 +131,12 @@ pipeline "Contextive VsCode Extension" {
run (fun ctx -> $"gh release upload {ctx.GetCmdArg(args.release)} {vsCodeAssetFileName ctx}")
}

stage "Publish to Microsoft VS Marketplace" { run (fun ctx -> $"npx vsce publish --packagePath {vsCodeAssetFileName ctx}") }
stage "Publish to Open-Vsx Marketplace" { run (fun ctx -> $"npx ovsx publish {vsCodeAssetFileName ctx} -p \"{ctx.GetEnvVar(args.ovsxPat.Name)}\"") }
stage "Publish to Marketplaces" {
whenComponentInRelease "vscode"

stage "To Microsoft VS Marketplace" { run (fun ctx -> $"npx vsce publish --packagePath {vsCodeAssetFileName ctx}") }
stage "To Open-Vsx Marketplace" { run (fun ctx -> $"npx ovsx publish {vsCodeAssetFileName ctx} -p \"{ctx.GetEnvVar(args.ovsxPat.Name)}\"") }
}
}

runIfOnlySpecified false
Expand Down

0 comments on commit cdf2d4a

Please sign in to comment.