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
+1 -2
View File
@@ -38,11 +38,10 @@ async function selectBranch(branch) {
throw new Error(`Branch ${branch} not found`); throw new Error(`Branch ${branch} not found`);
} }
async function selectPr(pr) { async function selectPr(pr) {
var _a;
const versions = await git_1.lsRemote(); const versions = await git_1.lsRemote();
if (pr in versions.pull) { if (pr in versions.pull) {
const prheads = versions.pull[pr]; const prheads = versions.pull[pr];
const sha = (_a = prheads.merge) !== null && _a !== void 0 ? _a : prheads.head; const sha = prheads.head;
if (sha) { if (sha) {
return new VersionImpl(`#${pr}`, sha, 'pull', `pull request #${pr}`); return new VersionImpl(`#${pr}`, sha, 'pull', `pull request #${pr}`);
} }
+19 -16
View File
@@ -7,27 +7,30 @@ const toolCache = require("@actions/tool-cache");
const os = require("os"); const os = require("os");
const path = require("path"); const path = require("path");
const semver = require("semver"); const semver = require("semver");
function getInstallerUrl(version) {
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`;
}
}
async function winInstall(version) { async function winInstall(version) {
const ver = version.version; const ver = version.version;
let toolDir = toolCache.find('xmake', ver); let toolDir = toolCache.find('xmake', ver);
if (!toolDir) { if (!toolDir) {
const installer = await core.group(`download xmake ${version}`, async () => { const installer = await core.group(`download xmake ${version}`, async () => {
let url = ''; const url = getInstallerUrl(version);
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`;
}
core.info(`downloading from ${url}`); core.info(`downloading from ${url}`);
const file = await toolCache.downloadTool(url); const file = await toolCache.downloadTool(url);
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined }); const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
+14 -1
View File
@@ -8,9 +8,22 @@ function makeOpt(ref: string): { cwd: string } {
} }
export type RefDic = { export type RefDic = {
/** branches */
heads: Record<string, string>; heads: Record<string, string>;
/** tags */
tags: Record<string, string>; 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> { 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(); const versions = await lsRemote();
if (pr in versions.pull) { if (pr in versions.pull) {
const prheads = versions.pull[pr]; const prheads = versions.pull[pr];
const sha = prheads.merge ?? prheads.head; const sha = prheads.head;
if (sha) { if (sha) {
return new VersionImpl(`#${pr}`, sha, 'pull', `pull request #${pr}`); 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 * as semver from 'semver';
import { Version } from './versions'; 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> { export async function winInstall(version: Version): Promise<void> {
const ver = version.version; const ver = version.version;
let toolDir = toolCache.find('xmake', ver); let toolDir = toolCache.find('xmake', ver);
if (!toolDir) { if (!toolDir) {
const installer = await core.group(`download xmake ${version}`, async () => { const installer = await core.group(`download xmake ${version}`, async () => {
let url = ''; const url = getInstallerUrl(version);
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`;
}
core.info(`downloading from ${url}`); core.info(`downloading from ${url}`);
const file = await toolCache.downloadTool(url); const file = await toolCache.downloadTool(url);
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined }); const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });