chore: pump version to 0.1.0, and optimize release workflow

This commit is contained in:
tanzhenxin
2025-10-24 14:26:58 +08:00
parent d482ad28dd
commit 9b86e821bc
9 changed files with 52 additions and 288 deletions

View File

@@ -101,15 +101,27 @@ jobs:
- name: 'Get the version'
id: 'version'
run: |
VERSION_JSON=$(node scripts/get-release-version.js)
VERSION_ARGS=()
if [[ "${IS_NIGHTLY}" == "true" ]]; then
VERSION_ARGS+=(--type=nightly)
elif [[ "${IS_PREVIEW}" == "true" ]]; then
VERSION_ARGS+=(--type=preview)
if [[ -n "${MANUAL_VERSION}" ]]; then
VERSION_ARGS+=("--preview_version_override=${MANUAL_VERSION}")
fi
else
VERSION_ARGS+=(--type=stable)
if [[ -n "${MANUAL_VERSION}" ]]; then
VERSION_ARGS+=("--stable_version_override=${MANUAL_VERSION}")
fi
fi
VERSION_JSON=$(node scripts/get-release-version.js "${VERSION_ARGS[@]}")
echo "RELEASE_TAG=$(echo "$VERSION_JSON" | jq -r .releaseTag)" >> "$GITHUB_OUTPUT"
echo "RELEASE_VERSION=$(echo "$VERSION_JSON" | jq -r .releaseVersion)" >> "$GITHUB_OUTPUT"
echo "NPM_TAG=$(echo "$VERSION_JSON" | jq -r .npmTag)" >> "$GITHUB_OUTPUT"
# Get the previous tag for release notes generation
CURRENT_TAG=$(echo "$VERSION_JSON" | jq -r .releaseTag)
PREVIOUS_TAG=$(node scripts/get-previous-tag.js "$CURRENT_TAG" || echo "")
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> "$GITHUB_OUTPUT"
echo "PREVIOUS_RELEASE_TAG=$(echo "$VERSION_JSON" | jq -r .previousReleaseTag)" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
IS_NIGHTLY: '${{ steps.vars.outputs.is_nightly }}'
@@ -189,13 +201,13 @@ jobs:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
RELEASE_BRANCH: '${{ steps.release_branch.outputs.BRANCH_NAME }}'
RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}'
PREVIOUS_TAG: '${{ steps.version.outputs.PREVIOUS_TAG }}'
PREVIOUS_RELEASE_TAG: '${{ steps.version.outputs.PREVIOUS_RELEASE_TAG }}'
run: |-
gh release create "${RELEASE_TAG}" \
dist/cli.js \
--target "$RELEASE_BRANCH" \
--title "Release ${RELEASE_TAG}" \
--notes-start-tag "$PREVIOUS_TAG" \
--notes-start-tag "$PREVIOUS_RELEASE_TAG" \
--generate-notes
- name: 'Create Issue on Failure'

12
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@qwen-code/qwen-code",
"version": "0.0.14",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@qwen-code/qwen-code",
"version": "0.0.14",
"version": "0.1.0",
"workspaces": [
"packages/*"
],
@@ -16024,7 +16024,7 @@
},
"packages/cli": {
"name": "@qwen-code/qwen-code",
"version": "0.0.14",
"version": "0.1.0",
"dependencies": {
"@google/genai": "1.16.0",
"@iarna/toml": "^2.2.5",
@@ -16139,7 +16139,7 @@
},
"packages/core": {
"name": "@qwen-code/qwen-code-core",
"version": "0.0.14",
"version": "0.1.0",
"hasInstallScript": true,
"dependencies": {
"@google/genai": "1.16.0",
@@ -16278,7 +16278,7 @@
},
"packages/test-utils": {
"name": "@qwen-code/qwen-code-test-utils",
"version": "0.0.14",
"version": "0.1.0",
"dev": true,
"license": "Apache-2.0",
"devDependencies": {
@@ -16290,7 +16290,7 @@
},
"packages/vscode-ide-companion": {
"name": "qwen-code-vscode-ide-companion",
"version": "0.0.14",
"version": "0.1.0",
"license": "LICENSE",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.15.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@qwen-code/qwen-code",
"version": "0.0.14",
"version": "0.1.0",
"engines": {
"node": ">=20.0.0"
},
@@ -13,7 +13,7 @@
"url": "git+https://github.com/QwenLM/qwen-code.git"
},
"config": {
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.0.14"
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.1.0"
},
"scripts": {
"start": "cross-env node scripts/start.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@qwen-code/qwen-code",
"version": "0.0.14",
"version": "0.1.0",
"description": "Qwen Code",
"repository": {
"type": "git",
@@ -25,7 +25,7 @@
"dist"
],
"config": {
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.0.14"
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.1.0"
},
"dependencies": {
"@google/genai": "1.16.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@qwen-code/qwen-code-core",
"version": "0.0.14",
"version": "0.1.0",
"description": "Qwen Code Core",
"repository": {
"type": "git",

View File

@@ -1,6 +1,6 @@
{
"name": "@qwen-code/qwen-code-test-utils",
"version": "0.0.14",
"version": "0.1.0",
"private": true,
"main": "src/index.ts",
"license": "Apache-2.0",

View File

@@ -2,7 +2,7 @@
"name": "qwen-code-vscode-ide-companion",
"displayName": "Qwen Code Companion",
"description": "Enable Qwen Code with direct access to your VS Code workspace.",
"version": "0.0.14",
"version": "0.1.0",
"publisher": "qwenlm",
"icon": "assets/icon.png",
"repository": {

View File

@@ -1,213 +0,0 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { execSync } from 'child_process';
/**
* Determines the correct previous tag for release notes generation.
* This function handles the complexity of mixed tag types (regular releases vs nightly releases).
*
* @param {string} currentTag - The current release tag (e.g., "v0.1.23")
* @returns {string|null} - The previous tag to compare against, or null if no suitable tag found
*/
export function getPreviousTag(currentTag) {
try {
// Parse the current tag to understand its type
const currentTagInfo = parseTag(currentTag);
if (!currentTagInfo) {
console.error(`Invalid current tag format: ${currentTag}`);
return null;
}
// Find the appropriate previous tag based on the current tag type
let previousTag = null;
if (currentTagInfo.isNightly) {
// For nightly releases, find the last stable release
previousTag = findLastStableTag(currentTagInfo);
} else {
// For stable releases, find the previous stable release
previousTag = findPreviousStableTag(currentTagInfo);
}
return previousTag;
} catch (error) {
console.error('Error getting previous tag:', error.message);
return null;
}
}
/**
* Parses a tag string to extract version information and type
*/
function parseTag(tag) {
// Remove 'v' prefix if present
const cleanTag = tag.startsWith('v') ? tag.substring(1) : tag;
// Match pattern: X.Y.Z or X.Y.Z-prerelease
const match = cleanTag.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
if (!match) {
return null;
}
const [, major, minor, patch, prerelease] = match;
return {
original: tag,
major: parseInt(major),
minor: parseInt(minor),
patch: parseInt(patch),
prerelease: prerelease || null,
isNightly: prerelease && prerelease.startsWith('nightly'),
isPreview: prerelease && prerelease.startsWith('preview'),
version: `${major}.${minor}.${patch}`,
};
}
/**
* Finds the last stable tag for a nightly release
* Assumes version numbers are incremental and checks backwards from current version
*/
function findLastStableTag(currentTagInfo) {
// For nightly releases, find the stable version of the same version number first
const baseVersion = `v${currentTagInfo.version}`;
// Check if the stable version of the current version exists
if (tagExists(baseVersion)) {
return baseVersion;
}
// If not, look for the previous stable versions by decrementing version numbers
let { major, minor, patch } = currentTagInfo;
// Try decrementing patch version first
while (patch > 0) {
patch--;
const candidateTag = `v${major}.${minor}.${patch}`;
if (tagExists(candidateTag)) {
return candidateTag;
}
}
// Try decrementing minor version
while (minor > 0) {
minor--;
patch = 999; // Start from a high patch number and work backwards
while (patch >= 0) {
const candidateTag = `v${major}.${minor}.${patch}`;
if (tagExists(candidateTag)) {
return candidateTag;
}
patch--;
// Don't check too many patch versions to avoid infinite loops
if (patch < 0) break;
}
}
// Try decrementing major version
while (major > 0) {
major--;
minor = 999; // Start from a high minor number and work backwards
while (minor >= 0) {
patch = 999;
while (patch >= 0) {
const candidateTag = `v${major}.${minor}.${patch}`;
if (tagExists(candidateTag)) {
return candidateTag;
}
patch--;
if (patch < 0) break;
}
minor--;
if (minor < 0) break;
}
}
return null;
}
/**
* Finds the previous stable tag for a stable release
* Assumes version numbers are incremental and checks backwards from current version
*/
function findPreviousStableTag(currentTagInfo) {
let { major, minor, patch } = currentTagInfo;
// Try decrementing patch version first
while (patch > 0) {
patch--;
const candidateTag = `v${major}.${minor}.${patch}`;
if (tagExists(candidateTag)) {
return candidateTag;
}
}
// Try decrementing minor version
while (minor > 0) {
minor--;
patch = 999; // Start from a high patch number and work backwards
while (patch >= 0) {
const candidateTag = `v${major}.${minor}.${patch}`;
if (tagExists(candidateTag)) {
return candidateTag;
}
patch--;
// Don't check too many patch versions to avoid infinite loops
if (patch < 0) break;
}
}
// Try decrementing major version
while (major > 0) {
major--;
minor = 999; // Start from a high minor number and work backwards
while (minor >= 0) {
patch = 999;
while (patch >= 0) {
const candidateTag = `v${major}.${minor}.${patch}`;
if (tagExists(candidateTag)) {
return candidateTag;
}
patch--;
if (patch < 0) break;
}
minor--;
if (minor < 0) break;
}
}
return null;
}
/**
* Checks if a git tag exists
*/
function tagExists(tag) {
try {
execSync(`git rev-parse --verify ${tag}`, { stdio: 'ignore' });
return true;
} catch {
return false;
}
}
// CLI usage
if (process.argv[1] === new URL(import.meta.url).pathname) {
const currentTag = process.argv[2];
if (!currentTag) {
console.error('Usage: node get-previous-tag.js <current-tag>');
process.exit(1);
}
const previousTag = getPreviousTag(currentTag);
if (previousTag) {
console.log(previousTag);
} else {
console.error('No suitable previous tag found');
process.exit(1);
}
}

View File

@@ -26,36 +26,8 @@ function getArgs() {
return args;
}
function getLatestTag(pattern) {
const command = `git tag -l '${pattern}'`;
try {
const tags = execSync(command)
.toString()
.trim()
.split('\n')
.filter(Boolean);
if (tags.length === 0) return '';
// Convert tags to versions (remove 'v' prefix) and sort by semver
const versions = tags
.map((tag) => tag.replace(/^v/, ''))
.filter((version) => semver.valid(version))
.sort((a, b) => semver.rcompare(a, b)); // rcompare for descending order
if (versions.length === 0) return '';
// Return the latest version with 'v' prefix restored
return `v${versions[0]}`;
} catch (error) {
console.error(
`Failed to get latest git tag for pattern "${pattern}": ${error.message}`,
);
return '';
}
}
function getVersionFromNPM(distTag) {
const command = `npm view @google/gemini-cli version --tag=${distTag}`;
const command = `npm view @qwen-code/qwen-code version --tag=${distTag}`;
try {
return execSync(command).toString().trim();
} catch (error) {
@@ -67,7 +39,7 @@ function getVersionFromNPM(distTag) {
}
function getAllVersionsFromNPM() {
const command = `npm view @google/gemini-cli versions --json`;
const command = `npm view @qwen-code/qwen-code versions --json`;
try {
const versionsJson = execSync(command).toString().trim();
return JSON.parse(versionsJson);
@@ -78,7 +50,7 @@ function getAllVersionsFromNPM() {
}
function isVersionDeprecated(version) {
const command = `npm view @google/gemini-cli@${version} deprecated`;
const command = `npm view @qwen-code/qwen-code@${version} deprecated`;
try {
const output = execSync(command).toString().trim();
return output.length > 0;
@@ -159,7 +131,7 @@ function detectRollbackAndGetBaseline(npmDistTag) {
function doesVersionExist(version) {
// Check NPM
try {
const command = `npm view @google/gemini-cli@${version} version 2>/dev/null`;
const command = `npm view @qwen-code/qwen-code@${version} version 2>/dev/null`;
const output = execSync(command).toString().trim();
if (output === version) {
console.error(`Version ${version} already exists on NPM.`);
@@ -229,11 +201,20 @@ function getAndVerifyTags(npmDistTag, _gitTagPattern) {
};
}
function getLatestStableReleaseTag() {
try {
const { latestTag } = getAndVerifyTags('latest', 'v[0-9].[0-9].[0-9]');
return latestTag;
} catch (error) {
console.error(
`Failed to determine latest stable release tag: ${error.message}`,
);
return '';
}
}
function promoteNightlyVersion() {
const { latestVersion, latestTag } = getAndVerifyTags(
'nightly',
'v*-nightly*',
);
const { latestVersion } = getAndVerifyTags('nightly', 'v*-nightly*');
const baseVersion = latestVersion.split('-')[0];
const versionParts = baseVersion.split('.');
const major = versionParts[0];
@@ -244,7 +225,6 @@ function promoteNightlyVersion() {
return {
releaseVersion: `${major}.${nextMinor}.0-nightly.${date}.${gitShortHash}`,
npmTag: 'nightly',
previousReleaseTag: latestTag,
};
}
@@ -254,12 +234,9 @@ function getNightlyVersion() {
const date = new Date().toISOString().slice(0, 10).replace(/-/g, '');
const gitShortHash = execSync('git rev-parse --short HEAD').toString().trim();
const releaseVersion = `${baseVersion}-nightly.${date}.${gitShortHash}`;
const previousReleaseTag = getLatestTag('v*-nightly*');
return {
releaseVersion,
npmTag: 'nightly',
previousReleaseTag,
};
}
@@ -290,15 +267,9 @@ function getStableVersion(args) {
releaseVersion = latestPreviewVersion.replace(/-preview.*/, '');
}
const { latestTag: previousStableTag } = getAndVerifyTags(
'latest',
'v[0-9].[0-9].[0-9]',
);
return {
releaseVersion,
npmTag: 'latest',
previousReleaseTag: previousStableTag,
};
}
@@ -321,15 +292,9 @@ function getPreviewVersion(args) {
latestNightlyVersion.replace(/-nightly.*/, '') + '-preview.0';
}
const { latestTag: previousPreviewTag } = getAndVerifyTags(
'preview',
'v*-preview*',
);
return {
releaseVersion,
npmTag: 'preview',
previousReleaseTag: previousPreviewTag,
};
}
@@ -341,7 +306,7 @@ function getPatchVersion(patchFrom) {
}
const distTag = patchFrom === 'stable' ? 'latest' : 'preview';
const pattern = distTag === 'latest' ? 'v[0-9].[0-9].[0-9]' : 'v*-preview*';
const { latestVersion, latestTag } = getAndVerifyTags(distTag, pattern);
const { latestVersion } = getAndVerifyTags(distTag, pattern);
if (patchFrom === 'stable') {
// For stable versions, increment the patch number: 0.5.4 -> 0.5.5
@@ -353,7 +318,6 @@ function getPatchVersion(patchFrom) {
return {
releaseVersion,
npmTag: distTag,
previousReleaseTag: latestTag,
};
} else {
// For preview versions, increment the preview number: 0.6.0-preview.2 -> 0.6.0-preview.3
@@ -373,7 +337,6 @@ function getPatchVersion(patchFrom) {
return {
releaseVersion,
npmTag: distTag,
previousReleaseTag: latestTag,
};
}
}
@@ -438,6 +401,8 @@ export function getVersion(options = {}) {
...versionData,
};
result.previousReleaseTag = getLatestStableReleaseTag();
return result;
}