Compare commits
5 Commits
Vendored
+52282
-55212
File diff suppressed because one or more lines are too long
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "github-action-setup-xmake",
|
"name": "github-action-setup-xmake",
|
||||||
"version": "1.2.0",
|
"version": "1.2.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "github-action-setup-xmake",
|
"name": "github-action-setup-xmake",
|
||||||
"version": "1.2.0",
|
"version": "1.2.2",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^4.0.3",
|
"@actions/cache": "^4.0.3",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "github-action-setup-xmake",
|
"name": "github-action-setup-xmake",
|
||||||
"version": "1.2.0",
|
"version": "1.2.2",
|
||||||
"description": "Set up your GitHub Actions workflow with a specific version of xmake",
|
"description": "Set up your GitHub Actions workflow with a specific version of xmake",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"author": "OpportunityLiu",
|
"author": "OpportunityLiu",
|
||||||
|
|||||||
+6
-5
@@ -2,9 +2,9 @@ import * as core from '@actions/core';
|
|||||||
import { exec, ExecOptions } from '@actions/exec';
|
import { exec, ExecOptions } from '@actions/exec';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fsutils from './fsutils';
|
import * as fsutils from './fsutils';
|
||||||
|
import { getPlatformIdentifier } from './system';
|
||||||
|
|
||||||
function getBuildTime(hours?: string): string {
|
function getBuildTime(hours?: string): string {
|
||||||
let key = 'BuildTime';
|
let key = 'BuildTime';
|
||||||
@@ -38,7 +38,7 @@ function getProjectRootPath(): string {
|
|||||||
return projectRootPath;
|
return projectRootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBuildCacheKey(buildCacheTime?: string): string {
|
async function getBuildCacheKey(buildCacheTime?: string): Promise<string> {
|
||||||
let buildCacheKey = core.getInput('build-cache-key');
|
let buildCacheKey = core.getInput('build-cache-key');
|
||||||
if (!buildCacheKey) {
|
if (!buildCacheKey) {
|
||||||
buildCacheKey = '';
|
buildCacheKey = '';
|
||||||
@@ -46,7 +46,8 @@ function getBuildCacheKey(buildCacheTime?: string): string {
|
|||||||
if (!buildCacheTime || buildCacheTime === '') {
|
if (!buildCacheTime || buildCacheTime === '') {
|
||||||
buildCacheTime = getBuildTime();
|
buildCacheTime = getBuildTime();
|
||||||
}
|
}
|
||||||
return `xmake-build-cache-${buildCacheKey}-${buildCacheTime}-${os.arch()}-${os.platform()}-${process.env.RUNNER_OS ?? 'unknown'}`;
|
const platformIdentifier = await getPlatformIdentifier();
|
||||||
|
return `xmake-build-cache-${buildCacheKey}-${buildCacheTime}-${platformIdentifier}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBuildCachePath(): Promise<string> {
|
async function getBuildCachePath(): Promise<string> {
|
||||||
@@ -112,7 +113,7 @@ export async function loadBuildCache(): Promise<void> {
|
|||||||
if (hours < 0) {
|
if (hours < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const buildCacheKey = getBuildCacheKey(getBuildTime(String(hours).padStart(2, '0')));
|
const buildCacheKey = await getBuildCacheKey(getBuildTime(String(hours).padStart(2, '0')));
|
||||||
if (!fsutils.isFile(filepath)) {
|
if (!fsutils.isFile(filepath)) {
|
||||||
core.info(`Restore build cache path: ${fullCachePath} to ${buildCachePath}, key: ${buildCacheKey}`);
|
core.info(`Restore build cache path: ${fullCachePath} to ${buildCachePath}, key: ${buildCacheKey}`);
|
||||||
await cache.restoreCache([buildCacheFolder], buildCacheKey);
|
await cache.restoreCache([buildCacheFolder], buildCacheKey);
|
||||||
@@ -147,7 +148,7 @@ export async function saveBuildCache(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const buildCacheFolder = getBuildCacheFolder();
|
const buildCacheFolder = getBuildCacheFolder();
|
||||||
const buildCacheKey = getBuildCacheKey();
|
const buildCacheKey = await getBuildCacheKey();
|
||||||
const buildCachePath = await getBuildCachePath();
|
const buildCachePath = await getBuildCachePath();
|
||||||
|
|
||||||
const hitBuildCache = !!core.getState('hitBuildCache');
|
const hitBuildCache = !!core.getState('hitBuildCache');
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import * as core from '@actions/core';
|
|||||||
import { exec, ExecOptions } from '@actions/exec';
|
import { exec, ExecOptions } from '@actions/exec';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fsutils from './fsutils';
|
import * as fsutils from './fsutils';
|
||||||
|
import { getPlatformIdentifier } from './system';
|
||||||
|
|
||||||
function getProjectRootPath(): string {
|
function getProjectRootPath(): string {
|
||||||
let projectRootPath = core.getInput('project-path');
|
let projectRootPath = core.getInput('project-path');
|
||||||
@@ -41,7 +41,8 @@ async function getPackageCacheKey(): Promise<string> {
|
|||||||
await exec('xmake', ['l', 'utils.ci.packageskey'], options);
|
await exec('xmake', ['l', 'utils.ci.packageskey'], options);
|
||||||
packageCacheHash = packageCacheHash.trim();
|
packageCacheHash = packageCacheHash.trim();
|
||||||
}
|
}
|
||||||
return `xmake-package-cache-${packageCacheKey}-${packageCacheHash}-${os.arch()}-${os.platform()}-${process.env.RUNNER_OS ?? 'unknown'}`;
|
const platformIdentifier = await getPlatformIdentifier();
|
||||||
|
return `xmake-package-cache-${packageCacheKey}-${packageCacheHash}-${platformIdentifier}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPackageCachePath(): Promise<string> {
|
async function getPackageCachePath(): Promise<string> {
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import { exec } from '@actions/exec';
|
||||||
|
import * as os from 'os';
|
||||||
|
|
||||||
|
export async function getPlatformIdentifier(): Promise<string> {
|
||||||
|
let identifier = `${os.platform()}-${os.arch()}-${process.env.RUNNER_OS ?? 'unknown'}`;
|
||||||
|
if (os.platform() === 'darwin') {
|
||||||
|
let productVersion = '';
|
||||||
|
try {
|
||||||
|
await exec('sw_vers', ['-productVersion'], {
|
||||||
|
silent: true,
|
||||||
|
listeners: {
|
||||||
|
stdout: (data: Buffer) => {
|
||||||
|
productVersion = data.toString().trim();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (productVersion) {
|
||||||
|
identifier += `-${productVersion}`;
|
||||||
|
}
|
||||||
|
} catch (error: unknown) {
|
||||||
|
core.warning(
|
||||||
|
`Failed to get macOS product version: ${error instanceof Error ? error.message : String(error)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
+4
-4
@@ -9,6 +9,7 @@ import * as path from 'path';
|
|||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as git from './git';
|
import * as git from './git';
|
||||||
import { Version } from './interfaces';
|
import { Version } from './interfaces';
|
||||||
|
import { getPlatformIdentifier } from './system';
|
||||||
|
|
||||||
async function install(sourceDir: string, binDir: string): Promise<void> {
|
async function install(sourceDir: string, binDir: string): Promise<void> {
|
||||||
if (fs.existsSync(path.join(sourceDir, 'configure'))) {
|
if (fs.existsSync(path.join(sourceDir, 'configure'))) {
|
||||||
@@ -32,9 +33,8 @@ export async function unixInstall(version: Version): Promise<void> {
|
|||||||
if (version.type !== 'local') {
|
if (version.type !== 'local') {
|
||||||
const ver = version.version;
|
const ver = version.version;
|
||||||
const sha = version.sha;
|
const sha = version.sha;
|
||||||
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${os.arch()}-${os.platform()}-${
|
const platformIdentifier = await getPlatformIdentifier();
|
||||||
process.env.RUNNER_OS ?? 'unknown'
|
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${platformIdentifier}`;
|
||||||
}`;
|
|
||||||
|
|
||||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||||
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||||
@@ -48,7 +48,7 @@ export async function unixInstall(version: Version): Promise<void> {
|
|||||||
toolDir = fullCachePath;
|
toolDir = fullCachePath;
|
||||||
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
||||||
} catch {
|
} catch {
|
||||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
core.warning(`No cached files found at path "${fullCachePath}, key: ${cacheKey}".`);
|
||||||
await io.rmRF(fullCachePath);
|
await io.rmRF(fullCachePath);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-3
@@ -9,6 +9,7 @@ import * as path from 'path';
|
|||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as git from './git';
|
import * as git from './git';
|
||||||
import { Version, GitVersion } from './interfaces';
|
import { Version, GitVersion } from './interfaces';
|
||||||
|
import { getPlatformIdentifier } from './system';
|
||||||
|
|
||||||
function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
|
function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
|
||||||
let ver = version.version;
|
let ver = version.version;
|
||||||
@@ -59,9 +60,8 @@ export async function winInstall(version: Version, latest: Version): Promise<voi
|
|||||||
|
|
||||||
const ver = version.version;
|
const ver = version.version;
|
||||||
const sha = version.sha;
|
const sha = version.sha;
|
||||||
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${os.arch()}-${os.platform()}-${
|
const platformIdentifier = await getPlatformIdentifier();
|
||||||
process.env.RUNNER_OS ?? 'unknown'
|
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${platformIdentifier}`;
|
||||||
}`;
|
|
||||||
|
|
||||||
let toolDir = '';
|
let toolDir = '';
|
||||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user