Compare commits
@@ -11,14 +11,14 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macOS-latest, macos-14, macos-13]
|
os: [ubuntu-latest, windows-latest, windows-11-arm, macOS-latest]
|
||||||
version: [branch@test]
|
version: [latest, branch@master, branch@dev]
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- uses: xmake-io/github-action-setup-xmake@test
|
- uses: xmake-io/github-action-setup-xmake@master
|
||||||
with:
|
with:
|
||||||
xmake-version: ${{ matrix.version }}
|
xmake-version: ${{ matrix.version }}
|
||||||
actions-cache-folder: '.xmake-cache'
|
actions-cache-folder: '.xmake-cache'
|
||||||
@@ -31,7 +31,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
sw_vers -productVersion
|
|
||||||
xmake --version
|
xmake --version
|
||||||
cd tests/sample
|
cd tests/sample
|
||||||
xmake -y -vD
|
xmake -y -vD
|
||||||
|
|||||||
Vendored
+40
-26
@@ -70512,9 +70512,9 @@ const core = __nccwpck_require__(7484);
|
|||||||
const exec_1 = __nccwpck_require__(5236);
|
const exec_1 = __nccwpck_require__(5236);
|
||||||
const io = __nccwpck_require__(4994);
|
const io = __nccwpck_require__(4994);
|
||||||
const cache = __nccwpck_require__(5116);
|
const cache = __nccwpck_require__(5116);
|
||||||
const os = __nccwpck_require__(857);
|
|
||||||
const path = __nccwpck_require__(6928);
|
const path = __nccwpck_require__(6928);
|
||||||
const fsutils = __nccwpck_require__(7999);
|
const fsutils = __nccwpck_require__(7999);
|
||||||
|
const system_1 = __nccwpck_require__(7666);
|
||||||
function getBuildTime(hours) {
|
function getBuildTime(hours) {
|
||||||
let key = 'BuildTime';
|
let key = 'BuildTime';
|
||||||
if (hours && hours !== '') {
|
if (hours && hours !== '') {
|
||||||
@@ -70545,8 +70545,7 @@ function getProjectRootPath() {
|
|||||||
}
|
}
|
||||||
return projectRootPath;
|
return projectRootPath;
|
||||||
}
|
}
|
||||||
function getBuildCacheKey(buildCacheTime) {
|
async function getBuildCacheKey(buildCacheTime) {
|
||||||
var _a;
|
|
||||||
let buildCacheKey = core.getInput('build-cache-key');
|
let buildCacheKey = core.getInput('build-cache-key');
|
||||||
if (!buildCacheKey) {
|
if (!buildCacheKey) {
|
||||||
buildCacheKey = '';
|
buildCacheKey = '';
|
||||||
@@ -70554,7 +70553,8 @@ function getBuildCacheKey(buildCacheTime) {
|
|||||||
if (!buildCacheTime || buildCacheTime === '') {
|
if (!buildCacheTime || buildCacheTime === '') {
|
||||||
buildCacheTime = getBuildTime();
|
buildCacheTime = getBuildTime();
|
||||||
}
|
}
|
||||||
return `xmake-build-cache-${buildCacheKey}-${buildCacheTime}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
|
const platformIdentifier = await (0, system_1.getPlatformIdentifier)();
|
||||||
|
return `xmake-build-cache-${buildCacheKey}-${buildCacheTime}-${platformIdentifier}`;
|
||||||
}
|
}
|
||||||
async function getBuildCachePath() {
|
async function getBuildCachePath() {
|
||||||
let buildCachePath = core.getInput('build-cache-path');
|
let buildCachePath = core.getInput('build-cache-path');
|
||||||
@@ -70611,7 +70611,7 @@ async function loadBuildCache() {
|
|||||||
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);
|
||||||
@@ -70644,7 +70644,7 @@ async function saveBuildCache() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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');
|
||||||
if (!hitBuildCache && buildCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(buildCachePath)) {
|
if (!hitBuildCache && buildCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(buildCachePath)) {
|
||||||
@@ -70832,9 +70832,9 @@ const core = __nccwpck_require__(7484);
|
|||||||
const exec_1 = __nccwpck_require__(5236);
|
const exec_1 = __nccwpck_require__(5236);
|
||||||
const io = __nccwpck_require__(4994);
|
const io = __nccwpck_require__(4994);
|
||||||
const cache = __nccwpck_require__(5116);
|
const cache = __nccwpck_require__(5116);
|
||||||
const os = __nccwpck_require__(857);
|
|
||||||
const path = __nccwpck_require__(6928);
|
const path = __nccwpck_require__(6928);
|
||||||
const fsutils = __nccwpck_require__(7999);
|
const fsutils = __nccwpck_require__(7999);
|
||||||
|
const system_1 = __nccwpck_require__(7666);
|
||||||
function getProjectRootPath() {
|
function getProjectRootPath() {
|
||||||
let projectRootPath = core.getInput('project-path');
|
let projectRootPath = core.getInput('project-path');
|
||||||
if (!projectRootPath) {
|
if (!projectRootPath) {
|
||||||
@@ -70847,7 +70847,6 @@ function getProjectRootPath() {
|
|||||||
return projectRootPath;
|
return projectRootPath;
|
||||||
}
|
}
|
||||||
async function getPackageCacheKey() {
|
async function getPackageCacheKey() {
|
||||||
var _a;
|
|
||||||
let packageCacheKey = core.getInput('package-cache-key');
|
let packageCacheKey = core.getInput('package-cache-key');
|
||||||
if (!packageCacheKey) {
|
if (!packageCacheKey) {
|
||||||
packageCacheKey = '';
|
packageCacheKey = '';
|
||||||
@@ -70870,7 +70869,8 @@ async function getPackageCacheKey() {
|
|||||||
await (0, exec_1.exec)('xmake', ['l', 'utils.ci.packageskey'], options);
|
await (0, exec_1.exec)('xmake', ['l', 'utils.ci.packageskey'], options);
|
||||||
packageCacheHash = packageCacheHash.trim();
|
packageCacheHash = packageCacheHash.trim();
|
||||||
}
|
}
|
||||||
return `xmake-package-cache-${packageCacheKey}-${packageCacheHash}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
|
const platformIdentifier = await (0, system_1.getPlatformIdentifier)();
|
||||||
|
return `xmake-package-cache-${packageCacheKey}-${packageCacheHash}-${platformIdentifier}`;
|
||||||
}
|
}
|
||||||
async function getPackageCachePath() {
|
async function getPackageCachePath() {
|
||||||
let packageCachePath = '';
|
let packageCachePath = '';
|
||||||
@@ -70976,23 +70976,16 @@ if (!exports.IsPost) {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9095:
|
/***/ 7666:
|
||||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.unixInstall = unixInstall;
|
exports.getPlatformIdentifier = getPlatformIdentifier;
|
||||||
const core = __nccwpck_require__(7484);
|
const core = __nccwpck_require__(7484);
|
||||||
const exec_1 = __nccwpck_require__(5236);
|
const exec_1 = __nccwpck_require__(5236);
|
||||||
const io = __nccwpck_require__(4994);
|
|
||||||
const toolCache = __nccwpck_require__(3472);
|
|
||||||
const cache = __nccwpck_require__(5116);
|
|
||||||
const os = __nccwpck_require__(857);
|
const os = __nccwpck_require__(857);
|
||||||
const fs = __nccwpck_require__(9896);
|
|
||||||
const path = __nccwpck_require__(6928);
|
|
||||||
const semver = __nccwpck_require__(2088);
|
|
||||||
const git = __nccwpck_require__(1243);
|
|
||||||
async function getPlatformIdentifier() {
|
async function getPlatformIdentifier() {
|
||||||
var _a;
|
var _a;
|
||||||
let identifier = `${os.platform()}-${os.arch()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
|
let identifier = `${os.platform()}-${os.arch()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
|
||||||
@@ -71017,10 +71010,32 @@ async function getPlatformIdentifier() {
|
|||||||
}
|
}
|
||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9095:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.unixInstall = unixInstall;
|
||||||
|
const core = __nccwpck_require__(7484);
|
||||||
|
const exec_1 = __nccwpck_require__(5236);
|
||||||
|
const io = __nccwpck_require__(4994);
|
||||||
|
const toolCache = __nccwpck_require__(3472);
|
||||||
|
const cache = __nccwpck_require__(5116);
|
||||||
|
const os = __nccwpck_require__(857);
|
||||||
|
const fs = __nccwpck_require__(9896);
|
||||||
|
const path = __nccwpck_require__(6928);
|
||||||
|
const semver = __nccwpck_require__(2088);
|
||||||
|
const git = __nccwpck_require__(1243);
|
||||||
|
const system_1 = __nccwpck_require__(7666);
|
||||||
async function install(sourceDir, binDir) {
|
async function install(sourceDir, binDir) {
|
||||||
if (fs.existsSync(path.join(sourceDir, 'configure'))) {
|
if (fs.existsSync(path.join(sourceDir, 'configure'))) {
|
||||||
await (0, exec_1.exec)('sh', ['./configure'], { cwd: sourceDir });
|
await (0, exec_1.exec)('sh', ['./configure'], { cwd: sourceDir });
|
||||||
await (0, exec_1.exec)('make', ['-j6', 'VERBOSE=1'], { cwd: sourceDir });
|
await (0, exec_1.exec)('make', ['-j6'], { cwd: sourceDir });
|
||||||
await (0, exec_1.exec)('make', ['install', `PREFIX=${binDir}`], { cwd: sourceDir });
|
await (0, exec_1.exec)('make', ['install', `PREFIX=${binDir}`], { cwd: sourceDir });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -71038,7 +71053,7 @@ async function unixInstall(version) {
|
|||||||
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 platformIdentifier = await getPlatformIdentifier();
|
const platformIdentifier = await (0, system_1.getPlatformIdentifier)();
|
||||||
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${platformIdentifier}`;
|
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);
|
||||||
@@ -71098,8 +71113,6 @@ async function unixInstall(version) {
|
|||||||
else {
|
else {
|
||||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||||
}
|
}
|
||||||
// xmake l utils.binary.deplibs /Users/ruki/.local/bin/xmake
|
|
||||||
await (0, exec_1.exec)(`xmake l --root utils.binary.deplibs ${path.join(toolDir, 'bin', 'xmake')}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71289,6 +71302,7 @@ const fs = __nccwpck_require__(9896);
|
|||||||
const path = __nccwpck_require__(6928);
|
const path = __nccwpck_require__(6928);
|
||||||
const semver = __nccwpck_require__(2088);
|
const semver = __nccwpck_require__(2088);
|
||||||
const git = __nccwpck_require__(1243);
|
const git = __nccwpck_require__(1243);
|
||||||
|
const system_1 = __nccwpck_require__(7666);
|
||||||
function getInstallerUrl(version, latest) {
|
function getInstallerUrl(version, latest) {
|
||||||
let ver = version.version;
|
let ver = version.version;
|
||||||
switch (version.type) {
|
switch (version.type) {
|
||||||
@@ -71324,7 +71338,6 @@ async function installFromSource(xmakeBin, sourceDir, binDir) {
|
|||||||
await (0, exec_1.exec)(xmakeBin, ['install', '-o', binDir, 'cli'], { cwd: sourceDir });
|
await (0, exec_1.exec)(xmakeBin, ['install', '-o', binDir, 'cli'], { cwd: sourceDir });
|
||||||
}
|
}
|
||||||
async function winInstall(version, latest) {
|
async function winInstall(version, latest) {
|
||||||
var _a;
|
|
||||||
if (version.type === 'local' || latest.type === 'local') {
|
if (version.type === 'local' || latest.type === 'local') {
|
||||||
throw new Error('Local builds for windows is not supported');
|
throw new Error('Local builds for windows is not supported');
|
||||||
}
|
}
|
||||||
@@ -71335,7 +71348,8 @@ async function winInstall(version, latest) {
|
|||||||
}
|
}
|
||||||
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()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
|
const platformIdentifier = await (0, system_1.getPlatformIdentifier)();
|
||||||
|
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${platformIdentifier}`;
|
||||||
let toolDir = '';
|
let toolDir = '';
|
||||||
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);
|
||||||
@@ -71343,14 +71357,14 @@ async function winInstall(version, latest) {
|
|||||||
try {
|
try {
|
||||||
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
||||||
}
|
}
|
||||||
catch (_b) {
|
catch (_a) {
|
||||||
await cache.restoreCache([actionsCacheFolder], cacheKey);
|
await cache.restoreCache([actionsCacheFolder], cacheKey);
|
||||||
}
|
}
|
||||||
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
||||||
toolDir = fullCachePath;
|
toolDir = fullCachePath;
|
||||||
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
||||||
}
|
}
|
||||||
catch (_c) {
|
catch (_b) {
|
||||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||||
await io.rmRF(fullCachePath);
|
await io.rmRF(fullCachePath);
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "github-action-setup-xmake",
|
"name": "github-action-setup-xmake",
|
||||||
"version": "1.2.1",
|
"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.1",
|
"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.1",
|
"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;
|
||||||
|
}
|
||||||
+2
-29
@@ -9,36 +9,12 @@ 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 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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'))) {
|
||||||
await exec('sh', ['./configure'], { cwd: sourceDir });
|
await exec('sh', ['./configure'], { cwd: sourceDir });
|
||||||
await exec('make', ['-j6', 'VERBOSE=1'], { cwd: sourceDir });
|
await exec('make', ['-j6'], { cwd: sourceDir });
|
||||||
await exec('make', ['install', `PREFIX=${binDir}`], { cwd: sourceDir });
|
await exec('make', ['install', `PREFIX=${binDir}`], { cwd: sourceDir });
|
||||||
} else {
|
} else {
|
||||||
await exec('make', ['-j6'], { cwd: sourceDir });
|
await exec('make', ['-j6'], { cwd: sourceDir });
|
||||||
@@ -116,7 +92,4 @@ export async function unixInstall(version: Version): Promise<void> {
|
|||||||
} else {
|
} else {
|
||||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||||
}
|
}
|
||||||
|
|
||||||
// xmake l utils.binary.deplibs /Users/ruki/.local/bin/xmake
|
|
||||||
await exec(`xmake l --root utils.binary.deplibs ${path.join(toolDir, 'bin', 'xmake')}`);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+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