Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 10, 2024
1 parent 65def61 commit 41b488c
Show file tree
Hide file tree
Showing 8 changed files with 8,998 additions and 2,306 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/checkin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ jobs:
checkin:
runs-on: ubuntu-latest

concurrency:
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-checkin
cancel-in-progress: true

steps:
- uses: actions/checkout@v4
- name: install
uses: wyvox/action-setup-pnpm@v3
with:
node-version: 20
pnpm-version: 8
node-version: 23
pnpm-version: 9
- name: build
run: pnpm build
- name: test
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:

jobs:
build:
concurrency:
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.version }}-test
cancel-in-progress: true

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
Expand All @@ -14,9 +18,11 @@ jobs:

steps:
- uses: actions/checkout@v1
- uses: xmake-io/github-action-setup-xmake@master
- uses: xmake-io/github-action-setup-xmake@test
with:
xmake-version: ${{ matrix.version }}
actions-cache-folder: '.xmake-cache'

- name: Run tests
run: |
xmake --version
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ git tag v1
git push origin master
git push --tags --force
```

### Development and debug

```bash
git branch test
git checkout test
pnpm build
pnpm release
git-commit -a -m "..."
git push origin test
```
62 changes: 61 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82596,6 +82596,7 @@ async function unixInstall(version) {
}
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
toolDir = fullCachePath;
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
}
catch (_c) {
core.warning(`No cached files found at path "${fullCachePath}".`);
Expand Down Expand Up @@ -82827,9 +82828,12 @@ const core = __nccwpck_require__(9093);
const exec_1 = __nccwpck_require__(7775);
const io = __nccwpck_require__(2826);
const toolCache = __nccwpck_require__(5561);
const cache = __nccwpck_require__(6878);
const os = __nccwpck_require__(2037);
const fs = __nccwpck_require__(7147);
const path = __nccwpck_require__(1017);
const semver = __nccwpck_require__(117);
const git = __nccwpck_require__(3555);
function getInstallerUrl(version, latest) {
const ver = version.version;
switch (version.type) {
Expand Down Expand Up @@ -82857,12 +82861,45 @@ function getInstallerUrl(version, latest) {
}
}
}
async function installFromSource(xmakeBin, sourceDir, binDir) {
await (0, exec_1.exec)(xmakeBin, ['-y'], { cwd: sourceDir });
await (0, exec_1.exec)(xmakeBin, ['install', '-o', binDir, 'cli'], { cwd: sourceDir });
}
async function winInstall(version, latest) {
var _a;
if (version.type === 'local' || latest.type === 'local') {
throw new Error('Local builds for windows is not supported');
}
const actionsCacheFolder = core.getInput('actions-cache-folder');
let actionsCacheKey = core.getInput('actions-cache-key');
if (!actionsCacheKey) {
actionsCacheKey = '';
}
const ver = version.version;
let toolDir = toolCache.find('xmake', ver);
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'}`;
let toolDir = '';
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
try {
try {
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
}
catch (_b) {
await cache.restoreCache([actionsCacheFolder], cacheKey);
}
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
toolDir = fullCachePath;
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
}
catch (_c) {
core.warning(`No cached files found at path "${fullCachePath}".`);
await io.rmRF(fullCachePath);
}
}
else {
toolDir = toolCache.find('xmake', ver);
}
if (!toolDir) {
const installer = await core.group(`download xmake ${String(version)}`, async () => {
const url = getInstallerUrl(version, latest);
Expand All @@ -82887,6 +82924,29 @@ async function winInstall(version, latest) {
await io.rmRF(installer);
return cacheDir;
});
await (0, exec_1.exec)(`"${toolDir}/xmake.exe" --version`);
if (version.type === 'heads') {
const sourceDir = await core.group(`download xmake source ${String(version)}`, () => git.create(version.repo, version.sha));
toolDir = await core.group(`install xmake source ${String(version)}`, async () => {
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
await installFromSource(`${toolDir}/xmake.exe`, `${sourceDir}/core`, binDir);
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
await io.rmRF(binDir);
await git.cleanup(version.sha);
return cacheDir;
});
}
if (toolDir) {
let cacheDir = '';
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
cacheDir = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
await io.cp(toolDir, cacheDir, {
recursive: true,
});
await cache.saveCache([actionsCacheFolder], cacheKey);
toolDir = cacheDir;
}
}
}
core.addPath(toolDir);
}
Expand Down
Loading

0 comments on commit 41b488c

Please sign in to comment.