Skip to content

Commit 3e4d419

Browse files
authored
Patch release (#1951)
* Allow doing a patch release * Turn off Windows 6.2
1 parent 90e62a0 commit 3e4d419

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

.github/workflows/nightly.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
schedule:
88
- cron: "0 0 * * *"
99
workflow_dispatch:
10+
inputs:
11+
patchRelease:
12+
description: 'Make a patch release'
13+
required: false
14+
type: boolean
1015

1116
jobs:
1217
package:
@@ -27,7 +32,12 @@ jobs:
2732
. .github/workflows/scripts/setup-linux.sh
2833
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
2934
npm ci
30-
npm run package
35+
if [ "${{github.event.inputs.patchRelease}}" = "true" ]; then
36+
echo "Making patch release\n"
37+
npm run patch-package
38+
else
39+
npm run package
40+
fi
3141
npm run preview-package
3242
for file in *.vsix; do
3343
name="$(basename "$file" .vsix)-${{github.run_number}}.vsix"
@@ -65,7 +75,7 @@ jobs:
6575
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
6676
linux_build_command: ./scripts/test.sh
6777
# Windows
68-
windows_exclude_swift_versions: '[{"swift_version": "nightly-6.1"},{"swift_version": "nightly"}]' # Missing https://github.com/swiftlang/swift/pull/80144
78+
windows_exclude_swift_versions: '[{"swift_version": "nightly-6.1"}, {"swift_version": "nightly"}, {"swift_version": "6.2"}]' # Missing https://github.com/swiftlang/swift/pull/80144
6979
windows_env_vars: |
7080
CI=1
7181
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
@@ -94,7 +104,7 @@ jobs:
94104
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
95105
linux_build_command: ./scripts/test.sh
96106
# Windows
97-
windows_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "6.0"}, {"swift_version": "6.1"}, {"swift_version": "nightly-6.1"}, {"swift_version": "nightly-6.2"}, {"swift_version": "nightly"}]'
107+
windows_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "6.0"}, {"swift_version": "6.1"}, {"swift_version": "6.2"}, {"swift_version": "nightly-6.1"}, {"swift_version": "nightly-6.2"}, {"swift_version": "nightly"}]'
98108
windows_env_vars: |
99109
CI=1
100110
VSCODE_VERSION=insiders

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,7 @@
20482048
"package": "tsx ./scripts/package.ts",
20492049
"dev-package": "tsx ./scripts/dev_package.ts",
20502050
"preview-package": "tsx ./scripts/preview_package.ts",
2051+
"patch-package": "tsx ./scripts/patch_package.ts",
20512052
"tag": "./scripts/tag_release.sh $npm_package_version",
20522053
"contributors": "./scripts/generate_contributors_list.sh",
20532054
"prepare": "husky"

scripts/lib/utilities.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function exec(
8080
command: string,
8181
args: string[],
8282
options: child_process.SpawnOptionsWithoutStdio = {}
83-
): Promise<void> {
83+
): Promise<string> {
8484
let logMessage = "> " + command;
8585
if (args.length > 0) {
8686
logMessage += " " + args.join(" ");
@@ -93,7 +93,8 @@ export async function exec(
9393
command = command + ".cmd";
9494
options.shell = true;
9595
}
96-
return new Promise<void>((resolve, reject) => {
96+
let output = "";
97+
return new Promise<string>((resolve, reject) => {
9798
const childProcess = child_process.spawn(command, args, { stdio: "inherit", ...options });
9899
childProcess.once("error", reject);
99100
childProcess.once("close", (code, signal) => {
@@ -102,10 +103,13 @@ export async function exec(
102103
} else if (code !== 0) {
103104
reject(new Error(`Process exited with code ${code}`));
104105
} else {
105-
resolve();
106+
resolve(output);
106107
}
107108
console.log("");
108109
});
110+
childProcess.stdout?.on("data", buf => {
111+
output += buf.toString("utf-8");
112+
});
109113
});
110114
}
111115

@@ -187,3 +191,13 @@ export async function packageExtension(version: string, options: PackageExtensio
187191
console.error(error);
188192
});
189193
}
194+
195+
export async function releasedVersions(extensionId: string): Promise<string[]> {
196+
const output = await exec("npx", ["vsce", "show", extensionId, "--json"], {
197+
stdio: "pipe",
198+
cwd: getRootDirectory(),
199+
});
200+
201+
const extensionInfo = JSON.parse(output.trim());
202+
return extensionInfo.versions.map((v: { version: string }) => v.version);
203+
}

scripts/patch_package.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the VS Code Swift open source project
4+
//
5+
// Copyright (c) 2025 the VS Code Swift project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
/* eslint-disable no-console */
15+
import { getExtensionVersion, main, packageExtension, releasedVersions } from "./lib/utilities";
16+
17+
import "@vscode/vsce";
18+
19+
main(async () => {
20+
const releases = await releasedVersions("swiftlang.swift-vscode");
21+
const version = await getExtensionVersion();
22+
// Decrement the minor version and set a patch
23+
const minor = version.minor - 2;
24+
let patch = 1;
25+
let previewVersion = "";
26+
while (
27+
(previewVersion = `${version.major}.${minor}.${patch}`) &&
28+
releases.includes(previewVersion)
29+
) {
30+
patch += 1;
31+
}
32+
// Make sure that the new minor version is odd
33+
if (minor % 2 !== 0) {
34+
throw new Error(
35+
`The minor version for the patch release extension is odd (${previewVersion}).` +
36+
" The version in the package.json has probably been incorrectly set to an even minor version."
37+
);
38+
}
39+
await packageExtension(previewVersion);
40+
});

0 commit comments

Comments
 (0)