add hints

This commit is contained in:
OpportunityLiu
2020-03-31 22:59:54 +08:00
Unverified
parent 7a6538cab8
commit fb01b4e3c8
5 changed files with 53 additions and 34 deletions
+14 -1
View File
@@ -8,9 +8,22 @@ function makeOpt(ref: string): { cwd: string } {
}
export type RefDic = {
/** branches */
heads: Record<string, string>;
/** tags */
tags: Record<string, string>;
pull: Record<number, { head?: string; merge?: string }>;
/** pull requests */
pull: Record<
number,
{
/** the current state of the pull request */
head: string;
/** the current branch we're merging onto */
base?: string;
/** merge result */
merge?: string;
}
>;
};
export async function lsRemote(): Promise<RefDic> {
+1 -1
View File
@@ -30,7 +30,7 @@ async function selectPr(pr: number): Promise<Version> {
const versions = await lsRemote();
if (pr in versions.pull) {
const prheads = versions.pull[pr];
const sha = prheads.merge ?? prheads.head;
const sha = prheads.head;
if (sha) {
return new VersionImpl(`#${pr}`, sha, 'pull', `pull request #${pr}`);
}
+18 -14
View File
@@ -7,25 +7,29 @@ import * as path from 'path';
import * as semver from 'semver';
import { Version } from './versions';
function getInstallerUrl(version: Version): string {
const ver = version.version;
if (version.type === 'heads') {
// we only use appveyor ci artifacts for branch version
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
return `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=${ver}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`;
} else if (version.type === 'pull') {
throw new Error('PR builds for windows is not supported');
} else {
// we cannot use appveyor ci artifacts, the old version links may be broken.
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
return semver.gt(ver, '2.2.6')
? `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.${arch}.exe`
: `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.exe`;
}
}
export async function winInstall(version: Version): Promise<void> {
const ver = version.version;
let toolDir = toolCache.find('xmake', ver);
if (!toolDir) {
const installer = await core.group(`download xmake ${version}`, async () => {
let url = '';
if (version.type === 'heads') {
// we only use appveyor ci artifacts for branch version
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
url = `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=${ver}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`;
} else if (version.type === 'pull') {
throw new Error('PR builds for windows is not supported');
} else {
// we cannot use appveyor ci artifacts, the old version links may be broken.
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
url = semver.gt(ver, '2.2.6')
? `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.${arch}.exe`
: `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.exe`;
}
const url = getInstallerUrl(version);
core.info(`downloading from ${url}`);
const file = await toolCache.downloadTool(url);
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });