Skip to content

Bump extension version #1756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ jobs:
windows_env_vars: |
CI=1
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
VSCODE_SWIFT_VSIX=vscode-swift.vsix
GITHUB_REPOSITORY=${{github.repository}}
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
windows_pre_build_command: . .github\workflows\scripts\windows\setup.ps1
windows_build_command: scripts\test_windows.ps1
enable_windows_docker: false

Expand All @@ -87,6 +86,7 @@ jobs:
CI=1
VSCODE_VERSION=insiders
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
VSCODE_SWIFT_VSIX_PRERELEASE=1
GITHUB_REPOSITORY=${{github.repository}}
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
linux_build_command: ./scripts/test.sh
Expand All @@ -96,8 +96,8 @@ jobs:
CI=1
VSCODE_VERSION=insiders
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
VSCODE_SWIFT_PRERELEASE_VSIX=vscode-swift-prerelease.vsix
VSCODE_SWIFT_VSIX_PRERELEASE=1
GITHUB_REPOSITORY=${{github.repository}}
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
windows_pre_build_command: . .github\workflows\scripts\windows\setup.ps1
windows_build_command: scripts\test_windows.ps1
enable_windows_docker: false
6 changes: 2 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ jobs:
. .github/workflows/scripts/setup-linux.sh
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm ci
npm run package
npm run preview-package
npm run dev-package
for file in *.vsix; do
name="$(basename "$file" .vsix)-${{github.run_number}}.vsix"
echo "Created bundle $name"
Expand Down Expand Up @@ -67,9 +66,8 @@ jobs:
CI=1
FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}}
VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}}
VSCODE_SWIFT_VSIX=vscode-swift.vsix
GITHUB_REPOSITORY=${{github.repository}}
windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1
windows_pre_build_command: . .github\workflows\scripts\windows\setup.ps1
windows_build_command: scripts\test_windows.ps1
enable_windows_docker: false

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/scripts/setup-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@ env | sort
if [ -n "$VSCODE_SWIFT_VSIX_ID" ]; then
npm ci --ignore-scripts
npx tsx scripts/download_vsix.ts
export VSCODE_SWIFT_VSIX="vscode-swift.vsix"
export VSCODE_SWIFT_PRERELEASE_VSIX="vscode-swift-prerelease.vsix"
fi
5 changes: 5 additions & 0 deletions .github/workflows/scripts/windows/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ if ($Process.ExitCode -eq 0) {
Write-Host ('FAILED ({0})' -f $Process.ExitCode)
exit 1
}

Get-Content $env:GITHUB_ENV | foreach {
$name, $value = $_.split('=')
Set-Content env:\$name $value
}
81 changes: 45 additions & 36 deletions .vscode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
const { defineConfig } = require("@vscode/test-cli");
const path = require("path");
const { version, publisher, name } = require("./package.json");
const { preview } = require("./scripts/versions");

const isCIBuild = process.env["CI"] === "1";
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
Expand All @@ -41,51 +40,67 @@ if (dataDir) {
if (process.platform === "darwin" && process.arch === "x64") {
launchArgs.push("--disable-gpu");
}
const isStableRun = process.env["VSCODE_VERSION"] !== "insiders";

const installExtensions = [];
let vsixPath = process.env["VSCODE_SWIFT_VSIX"];
let versionStr = version;
if (!isStableRun) {
const segments = version.split(".").map(v => parseInt(v, 10));
versionStr = preview({ major: segments[0], minor: segments[1], patch: segments[2] });
}
let vsixPath = isStableRun
? process.env["VSCODE_SWIFT_VSIX"]
: process.env["VSCODE_SWIFT_PRERELEASE_VSIX"];
const install = [];
const installExtensions = ["vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap"];
let extensionDevelopmentPath;
if (vsixPath) {
// https://github.com/swiftlang/vscode-swift/issues/1751
// Will install extensions before CI tests run
installExtensions.push("vadimcn.vscode-lldb", "llvm-vs-code-extensions.lldb-dap");

// Absolute path to vsix needed
if (!path.isAbsolute(vsixPath)) {
vsixPath = path.join(__dirname, vsixPath);
}
console.log("Installing " + vsixPath);
console.log("Installing VSIX " + vsixPath);
installExtensions.push(vsixPath);

// Determine version to use
const match = /swift-vscode-(\d+.\d+.\d+(-dev)?)(-\d+)?.vsix/g.exec(path.basename(vsixPath));
if (match) {
versionStr = match[1];
}
console.log("Running tests against extension version " + versionStr);

extensionDevelopmentPath = `${__dirname}/.vscode-test/extensions/${publisher}.${name}-${versionStr}`;
console.log("Running tests against extension development path " + extensionDevelopmentPath);
}

const vscodeVersion = process.env["VSCODE_VERSION"] ?? "stable";
console.log("Running tests against VS Code version " + vscodeVersion);

const installConfigs = [];
for (const ext of installExtensions) {
install.push({
installConfigs.push({
label: `installExtension-${ext}`,
installExtensions: [ext],
launchArgs,
launchArgs: launchArgs.concat("--disable-extensions"),
files: ["dist/test/sleep.test.js"],
version: process.env["VSCODE_VERSION"] ?? "stable",
version: vscodeVersion,
skipExtensionDependencies: true,
reuseMachineInstall: !isCIBuild,
});
}

const env = {
...process.env,
RUNNING_UNDER_VSCODE_TEST_CLI: "1",
};
console.log("Running tests against environment:\n" + JSON.stringify(env, undefined, 2));

module.exports = defineConfig({
tests: [
...install,
...installConfigs,
{
label: "integrationTests",
files: ["dist/test/common.js", "dist/test/integration-tests/**/*.test.js"],
version: process.env["VSCODE_VERSION"] ?? "stable",
version: vscodeVersion,
workspaceFolder: "./assets/test",
launchArgs,
extensionDevelopmentPath: vsixPath
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${versionStr}`]
: undefined,
env: {
VSCODE_TEST: "1",
},
extensionDevelopmentPath,
env,
mocha: {
ui: "tdd",
color: true,
Expand All @@ -102,7 +117,7 @@ module.exports = defineConfig({
},
},
},
skipExtensionDependencies: install.length > 0,
skipExtensionDependencies: installConfigs.length > 0,
reuseMachineInstall: !isCIBuild,
},
{
Expand All @@ -116,15 +131,11 @@ module.exports = defineConfig({
"dist/test/integration-tests/testexplorer/TestExplorerIntegration.test.js",
"dist/test/integration-tests/commands/dependency.test.js",
],
version: process.env["VSCODE_VERSION"] ?? "stable",
version: vscodeVersion,
workspaceFolder: "./assets/test.code-workspace",
launchArgs,
extensionDevelopmentPath: vsixPath
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${versionStr}`]
: undefined,
env: {
VSCODE_TEST: "1",
},
extensionDevelopmentPath,
env,
mocha: {
ui: "tdd",
color: true,
Expand All @@ -141,17 +152,15 @@ module.exports = defineConfig({
},
},
},
skipExtensionDependencies: install.length > 0,
skipExtensionDependencies: installConfigs.length > 0,
reuseMachineInstall: !isCIBuild,
},
{
label: "unitTests",
files: ["dist/test/common.js", "dist/test/unit-tests/**/*.test.js"],
version: process.env["VSCODE_VERSION"] ?? "stable",
version: vscodeVersion,
launchArgs: launchArgs.concat("--disable-extensions"),
env: {
VSCODE_TEST: "1",
},
env,
mocha: {
ui: "tdd",
color: true,
Expand Down
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**/*
!LICENSE
!NOTICE.txt
!CHANGELOG.md
!CHANGELOG-*.md
!README.md
!icon.png
!package.json
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "swift-vscode",
"displayName": "Swift",
"description": "Swift Language Support for Visual Studio Code.",
"version": "2.10.0",
"version": "2.12.0-dev",
"publisher": "swiftlang",
"icon": "icon.png",
"repository": {
Expand Down
21 changes: 3 additions & 18 deletions scripts/dev_package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,11 @@
//===----------------------------------------------------------------------===//
/* eslint-disable no-console */

import {
exec,
getExtensionVersion,
getRootDirectory,
main,
updateChangelog,
} from "./lib/utilities";
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { dev } = require("./versions");
import { getExtensionVersion, main, packageExtension } from "./lib/utilities";

// eslint-disable-next-line @typescript-eslint/no-floating-promises
main(async () => {
const rootDirectory = getRootDirectory();
const version = await getExtensionVersion();
// Increment the patch version from the package.json
const devVersion = dev(version);
// Update version in CHANGELOG
await updateChangelog(devVersion);
// Use VSCE to package the extension
await exec("npx", ["vsce", "package", "--no-update-package-json", devVersion], {
cwd: rootDirectory,
});
const devVersion = `${version.major}.${version.minor}.${version.patch}-dev`;
await packageExtension(devVersion);
});
51 changes: 33 additions & 18 deletions scripts/download_vsix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
//===----------------------------------------------------------------------===//
/* eslint-disable no-console */

import decompress from "decompress";
import * as DecompressType from "decompress";
import { createWriteStream } from "node:fs";
import { rename, unlink } from "node:fs/promises";
import { appendFile, unlink } from "node:fs/promises";
import { pipeline } from "node:stream/promises";
import { Octokit } from "octokit";

// eslint-disable-next-line @typescript-eslint/no-require-imports
const decompress: typeof DecompressType = require("decompress");

const artifact_id = process.env["VSCODE_SWIFT_VSIX_ID"];
if (!artifact_id) {
console.error("No VSCODE_SWIFT_VSIX_ID provided");
Expand All @@ -29,6 +32,11 @@ if (!token) {
console.error("No GITHUB_TOKEN provided");
process.exit(1);
}
const envFile = process.env["GITHUB_ENV"];
if (!envFile) {
console.error("No GITHUB_ENV provided");
process.exit(1);
}
const repository = process.env["GITHUB_REPOSITORY"] || "swiftlang/vscode-swift";
const owner = repository.split("/")[0];
const repo = repository.split("/")[1];
Expand Down Expand Up @@ -57,22 +65,29 @@ const repo = repository.split("/")[1];
await pipeline(data, createWriteStream("artifacts.zip", data));
const files = await decompress("artifacts.zip", process.cwd());
console.log(`Downloaded artifact(s): ${files.map(f => f.path).join(", ")}`);
const newName = process.env["VSCODE_SWIFT_VSIX"] || "vscode-swift.vsix";
const releaseVSIX = files.find(f => /swift-vscode-\d+.\d+.\d+-\d+.vsix/m.test(f.path));
if (!releaseVSIX) {
console.error("Cound not find vscode-swift release VSIX in artifact bundle");
process.exit(1);
}
await rename(releaseVSIX.path, newName);
const prereleaseVSIX = files.find(f => /swift-vscode-\d+.\d+.\d{8}-\d+.vsix/m.test(f.path));
if (!prereleaseVSIX) {
console.error("Cound not find vscode-swift pre-release VSIX in artifact bundle");
process.exit(1);
const testPrerelease = process.env["VSCODE_SWIFT_VSIX_PRERELEASE"] === "1";
if (testPrerelease) {
const prereleaseVSIX = files.find(f =>
/swift-vscode-\d+.\d+.\d{8}(-dev)?-\d+.vsix/m.test(f.path)
);
if (prereleaseVSIX) {
await appendFile(envFile, `VSCODE_SWIFT_VSIX=${prereleaseVSIX.path}\n`);
console.log(`Running tests against: ${prereleaseVSIX.path}`);
} else {
console.error("Cound not find vscode-swift pre-release VSIX in artifact bundle");
process.exit(1);
}
} else {
const releaseVSIX = files.find(f =>
/swift-vscode-\d+.\d+.\d+(-dev)?-\d+.vsix/m.test(f.path)
);
if (releaseVSIX) {
await appendFile(envFile, `VSCODE_SWIFT_VSIX=${releaseVSIX.path}\n`);
console.log(`Running tests against: ${releaseVSIX.path}`);
} else {
console.error("Cound not find vscode-swift release VSIX in artifact bundle");
process.exit(1);
}
}
console.log(`Renamed artifact: ${releaseVSIX.path} => ${newName}`);
const preNewName =
process.env["VSCODE_SWIFT_PRERELEASE_VSIX"] || "vscode-swift-prerelease.vsix";
await rename(prereleaseVSIX.path, preNewName);
console.log(`Renamed artifact: ${prereleaseVSIX.path} => ${preNewName}`);
await unlink("artifacts.zip");
})();
Loading