mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix release workflow (#172)
This commit is contained in:
24
.github/workflows/release.yml
vendored
24
.github/workflows/release.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
|||||||
environment:
|
environment:
|
||||||
name: production-release
|
name: production-release
|
||||||
url: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.version.outputs.RELEASE_TAG }}
|
url: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.version.outputs.RELEASE_TAG }}
|
||||||
if: github.repository == 'google-gemini/gemini-cli'
|
if: github.repository == 'QwenLM/qwen-code'
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
@@ -95,7 +95,9 @@ jobs:
|
|||||||
npm run test:integration:sandbox:none
|
npm run test:integration:sandbox:none
|
||||||
npm run test:integration:sandbox:docker
|
npm run test:integration:sandbox:docker
|
||||||
env:
|
env:
|
||||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
|
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
|
||||||
|
OPENAI_MODEL: ${{ secrets.OPENAI_MODEL }}
|
||||||
|
|
||||||
- name: Configure Git User
|
- name: Configure Git User
|
||||||
run: |
|
run: |
|
||||||
@@ -133,22 +135,22 @@ jobs:
|
|||||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
registry-url: 'https://wombat-dressing-room.appspot.com'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
scope: '@google'
|
scope: '@qwen-code'
|
||||||
|
|
||||||
- name: Publish @google/gemini-cli-core
|
- name: Publish @qwen-code/qwen-code-core
|
||||||
run: npm publish --workspace=@google/gemini-cli-core --tag=${{ steps.version.outputs.NPM_TAG }} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
|
run: npm publish --workspace=@qwen-code/qwen-code-core --tag=${{ steps.version.outputs.NPM_TAG }} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.WOMBAT_TOKEN_CORE }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
- name: Install latest core package
|
- name: Install latest core package
|
||||||
if: steps.vars.outputs.is_dry_run == 'false'
|
if: steps.vars.outputs.is_dry_run == 'false'
|
||||||
run: npm install @google/gemini-cli-core@${{ steps.version.outputs.RELEASE_VERSION }} --workspace=@google/gemini-cli --save-exact
|
run: npm install @qwen-code/qwen-code-core@${{ steps.version.outputs.RELEASE_VERSION }} --workspace=@qwen-code/qwen-code --save-exact
|
||||||
|
|
||||||
- name: Publish @google/gemini-cli
|
- name: Publish @qwen-code/qwen-code
|
||||||
run: npm publish --workspace=@google/gemini-cli --tag=${{ steps.version.outputs.NPM_TAG }} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
|
run: npm publish --workspace=@qwen-code/qwen-code --tag=${{ steps.version.outputs.NPM_TAG }} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.WOMBAT_TOKEN_CLI }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
- name: Create GitHub Release and Tag
|
- name: Create GitHub Release and Tag
|
||||||
if: ${{ steps.vars.outputs.is_dry_run == 'false' }}
|
if: ${{ steps.vars.outputs.is_dry_run == 'false' }}
|
||||||
|
|||||||
@@ -14,20 +14,44 @@ function getPackageVersion() {
|
|||||||
return packageJson.version;
|
return packageJson.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getShortSha() {
|
function incrementPatchVersion(version) {
|
||||||
return execSync('git rev-parse --short HEAD').toString().trim();
|
const parts = version.split('.');
|
||||||
|
const major = parseInt(parts[0]);
|
||||||
|
const minor = parseInt(parts[1]);
|
||||||
|
const patch = parseInt(parts[2].split('-')[0]); // Handle pre-release versions
|
||||||
|
return `${major}.${minor}.${patch + 1}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLatestNightlyCount() {
|
||||||
|
try {
|
||||||
|
// Try to get the latest nightly tag from git to determine the counter
|
||||||
|
const currentVersion = getPackageVersion();
|
||||||
|
const nextVersion = incrementPatchVersion(currentVersion);
|
||||||
|
const tags = execSync(`git tag -l "v${nextVersion}-nightly.*"`)
|
||||||
|
.toString()
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
if (!tags) return 0;
|
||||||
|
|
||||||
|
const nightlyTags = tags.split('\n').filter(Boolean);
|
||||||
|
const counts = nightlyTags.map((tag) => {
|
||||||
|
const match = tag.match(/nightly\.(\d+)$/);
|
||||||
|
return match ? parseInt(match[1]) : 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Math.max(...counts, -1) + 1;
|
||||||
|
} catch (_error) {
|
||||||
|
// If we can't get tags, start from 0
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNightlyTagName() {
|
export function getNightlyTagName() {
|
||||||
const version = getPackageVersion();
|
const version = getPackageVersion();
|
||||||
const now = new Date();
|
const nextVersion = incrementPatchVersion(version);
|
||||||
const year = now.getUTCFullYear().toString().slice(-2);
|
const nightlyCount = getLatestNightlyCount();
|
||||||
const month = (now.getUTCMonth() + 1).toString().padStart(2, '0');
|
|
||||||
const day = now.getUTCDate().toString().padStart(2, '0');
|
|
||||||
const date = `${year}${month}${day}`;
|
|
||||||
|
|
||||||
const sha = getShortSha();
|
return `v${nextVersion}-nightly.${nightlyCount}`;
|
||||||
return `v${version}-nightly.${date}.${sha}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReleaseVersion() {
|
export function getReleaseVersion() {
|
||||||
@@ -72,7 +96,13 @@ export function getReleaseVersion() {
|
|||||||
const releaseVersion = releaseTag.substring(1);
|
const releaseVersion = releaseTag.substring(1);
|
||||||
let npmTag = 'latest';
|
let npmTag = 'latest';
|
||||||
if (releaseVersion.includes('-')) {
|
if (releaseVersion.includes('-')) {
|
||||||
npmTag = releaseVersion.split('-')[1].split('.')[0];
|
const prereleasePart = releaseVersion.split('-')[1];
|
||||||
|
npmTag = prereleasePart.split('.')[0];
|
||||||
|
|
||||||
|
// Ensure nightly releases use 'nightly' tag, not 'latest'
|
||||||
|
if (npmTag === 'nightly') {
|
||||||
|
npmTag = 'nightly';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { releaseTag, releaseVersion, npmTag };
|
return { releaseTag, releaseVersion, npmTag };
|
||||||
|
|||||||
@@ -41,15 +41,14 @@ describe('getReleaseVersion', () => {
|
|||||||
|
|
||||||
it('should calculate nightly version when IS_NIGHTLY is true', () => {
|
it('should calculate nightly version when IS_NIGHTLY is true', () => {
|
||||||
process.env.IS_NIGHTLY = 'true';
|
process.env.IS_NIGHTLY = 'true';
|
||||||
const knownDate = new Date('2025-07-20T10:00:00.000Z');
|
|
||||||
vi.setSystemTime(knownDate);
|
|
||||||
vi.mocked(fs.default.readFileSync).mockReturnValue(
|
vi.mocked(fs.default.readFileSync).mockReturnValue(
|
||||||
JSON.stringify({ version: '0.1.0' }),
|
JSON.stringify({ version: '0.1.0' }),
|
||||||
);
|
);
|
||||||
vi.mocked(execSync).mockReturnValue('abcdef');
|
// Mock git tag command to return empty (no existing nightly tags)
|
||||||
|
vi.mocked(execSync).mockReturnValue('');
|
||||||
const { releaseTag, releaseVersion, npmTag } = getReleaseVersion();
|
const { releaseTag, releaseVersion, npmTag } = getReleaseVersion();
|
||||||
expect(releaseTag).toBe('v0.1.0-nightly.250720.abcdef');
|
expect(releaseTag).toBe('v0.1.1-nightly.0');
|
||||||
expect(releaseVersion).toBe('0.1.0-nightly.250720.abcdef');
|
expect(releaseVersion).toBe('0.1.1-nightly.0');
|
||||||
expect(npmTag).toBe('nightly');
|
expect(npmTag).toBe('nightly');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,8 +98,8 @@ describe('getReleaseVersion', () => {
|
|||||||
describe('get-release-version script', () => {
|
describe('get-release-version script', () => {
|
||||||
it('should print version JSON to stdout when executed directly', () => {
|
it('should print version JSON to stdout when executed directly', () => {
|
||||||
const expectedJson = {
|
const expectedJson = {
|
||||||
releaseTag: 'v0.1.0-nightly.20250705',
|
releaseTag: 'v0.1.1-nightly.0',
|
||||||
releaseVersion: '0.1.0-nightly.20250705',
|
releaseVersion: '0.1.1-nightly.0',
|
||||||
npmTag: 'nightly',
|
npmTag: 'nightly',
|
||||||
};
|
};
|
||||||
execSync.mockReturnValue(JSON.stringify(expectedJson));
|
execSync.mockReturnValue(JSON.stringify(expectedJson));
|
||||||
|
|||||||
@@ -23,18 +23,24 @@ function writeJson(filePath, data) {
|
|||||||
writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n');
|
writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Get the version type from the command line arguments.
|
// 1. Get the version from the command line arguments.
|
||||||
const versionType = process.argv[2];
|
const versionArg = process.argv[2];
|
||||||
if (!versionType) {
|
if (!versionArg) {
|
||||||
console.error('Error: No version type specified.');
|
console.error('Error: No version specified.');
|
||||||
console.error('Usage: npm run version <patch|minor|major|prerelease>');
|
console.error(
|
||||||
|
'Usage: npm run version <version> (e.g., 1.2.3 or patch|minor|major|prerelease)',
|
||||||
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Bump the version in the root and all workspace package.json files.
|
// 2. Determine if we have a specific version or a version type
|
||||||
run(`npm version ${versionType} --no-git-tag-version --allow-same-version`);
|
const isSpecificVersion = /^\d+\.\d+\.\d+/.test(versionArg);
|
||||||
|
const npmVersionArg = isSpecificVersion ? versionArg : versionArg;
|
||||||
|
|
||||||
|
// 3. Bump the version in the root and all workspace package.json files.
|
||||||
|
run(`npm version ${npmVersionArg} --no-git-tag-version --allow-same-version`);
|
||||||
run(
|
run(
|
||||||
`npm version ${versionType} --workspaces --no-git-tag-version --allow-same-version`,
|
`npm version ${npmVersionArg} --workspaces --no-git-tag-version --allow-same-version`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 3. Get the new version number from the root package.json
|
// 3. Get the new version number from the root package.json
|
||||||
|
|||||||
Reference in New Issue
Block a user