Compare commits
21 Commits
+2
-6
@@ -20,9 +20,9 @@ rules:
|
|||||||
- 1
|
- 1
|
||||||
- allowWithDecorator: true
|
- allowWithDecorator: true
|
||||||
allowStaticOnly: true
|
allowStaticOnly: true
|
||||||
'@typescript-eslint/no-parameter-properties':
|
'@typescript-eslint/parameter-properties':
|
||||||
- 1
|
- 1
|
||||||
- allows: [protected readonly, private readonly, public readonly, readonly]
|
- allow: [protected readonly, private readonly, public readonly, readonly]
|
||||||
'@typescript-eslint/no-throw-literal': [2]
|
'@typescript-eslint/no-throw-literal': [2]
|
||||||
'no-unused-vars': [0]
|
'no-unused-vars': [0]
|
||||||
'@typescript-eslint/no-unused-vars':
|
'@typescript-eslint/no-unused-vars':
|
||||||
@@ -33,9 +33,5 @@ rules:
|
|||||||
'@typescript-eslint/prefer-function-type': [1]
|
'@typescript-eslint/prefer-function-type': [1]
|
||||||
'@typescript-eslint/prefer-nullish-coalescing': [1]
|
'@typescript-eslint/prefer-nullish-coalescing': [1]
|
||||||
'@typescript-eslint/prefer-optional-chain': [1]
|
'@typescript-eslint/prefer-optional-chain': [1]
|
||||||
'@typescript-eslint/ban-types':
|
|
||||||
- 1
|
|
||||||
- types:
|
|
||||||
object: false
|
|
||||||
no-void: [1, { allowAsStatement: true }]
|
no-void: [1, { allowAsStatement: true }]
|
||||||
eqeqeq: [1, smart]
|
eqeqeq: [1, smart]
|
||||||
|
|||||||
@@ -8,30 +8,28 @@ jobs:
|
|||||||
checkin:
|
checkin:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
concurrency:
|
||||||
matrix:
|
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-checkin
|
||||||
node-version: [16.x]
|
cancel-in-progress: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
cache: 'yarn'
|
|
||||||
- name: install
|
- name: install
|
||||||
run: yarn install --frozen-lockfile
|
uses: wyvox/action-setup-pnpm@v3
|
||||||
|
with:
|
||||||
|
node-version: 23
|
||||||
|
pnpm-version: 9
|
||||||
- name: build
|
- name: build
|
||||||
run: yarn build
|
run: pnpm build
|
||||||
- name: test
|
- name: test
|
||||||
run: yarn test
|
run: pnpm test
|
||||||
- name: release
|
- name: release
|
||||||
run: yarn release
|
run: pnpm release
|
||||||
- name: 'check for uncommitted changes'
|
- name: 'check for uncommitted changes'
|
||||||
# Ensure no changes
|
# Ensure no changes
|
||||||
run: |
|
run: |
|
||||||
git add .
|
git add .
|
||||||
if ! git diff --cached --color=always --exit-code -- . ':!node_modules'; then
|
if ! git diff --cached --color=always --exit-code -- . ':!node_modules'; then
|
||||||
echo "::error::Found changed files after build. Please run 'yarn release' and check in all changes."
|
echo "::error::Found changed files after build. Please run 'pnpm release' and check in all changes."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.version }}-test
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
@@ -14,9 +18,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- uses: xmake-io/github-action-setup-xmake@master
|
- uses: xmake-io/github-action-setup-xmake@test
|
||||||
with:
|
with:
|
||||||
xmake-version: ${{ matrix.version }}
|
xmake-version: ${{ matrix.version }}
|
||||||
|
actions-cache-folder: '.xmake-cache'
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
xmake --version
|
xmake --version
|
||||||
|
|||||||
+23
-1
@@ -1 +1,23 @@
|
|||||||
node_modules
|
# dependencies
|
||||||
|
/node_modules/
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
*.log
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# System Files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"npm.packageManager": "yarn",
|
"npm.packageManager": "pnpm",
|
||||||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"],
|
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"],
|
||||||
"eslint.enable": true,
|
"eslint.enable": true,
|
||||||
"files.autoSave": "off",
|
"files.autoSave": "off",
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
"editor.tabSize": 4,
|
"editor.tabSize": 4,
|
||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
},
|
||||||
"[typescript]": {
|
"[typescript]": {
|
||||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||||
|
|||||||
@@ -67,15 +67,16 @@ with:
|
|||||||
### Prepare development environment
|
### Prepare development environment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn install
|
pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Draft a new release
|
### Draft a new release
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn release
|
pnpm release
|
||||||
git add .
|
git add .
|
||||||
yarn version
|
git commit -m "build: release"
|
||||||
|
pnpm version [new-version]
|
||||||
|
|
||||||
# for a minor version or patch of v1
|
# for a minor version or patch of v1
|
||||||
git tag --delete v1
|
git tag --delete v1
|
||||||
@@ -84,3 +85,14 @@ git tag v1
|
|||||||
git push origin master
|
git push origin master
|
||||||
git push --tags --force
|
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
|
||||||
|
```
|
||||||
|
|||||||
+1
-1
@@ -17,5 +17,5 @@ inputs:
|
|||||||
description: The actions cache key.
|
description: The actions cache key.
|
||||||
default: ''
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
Vendored
+33804
-17804
File diff suppressed because one or more lines are too long
Generated
+6092
File diff suppressed because it is too large
Load Diff
+22
-22
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "github-action-setup-xmake",
|
"name": "github-action-setup-xmake",
|
||||||
"version": "1.1.0",
|
"version": "1.1.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",
|
||||||
@@ -10,37 +10,37 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "tsc --watch",
|
"watch": "tsc --watch",
|
||||||
"build": "ncc build src/index.ts",
|
"build": "ncc build src/index.ts",
|
||||||
"rebuild": "yarn clean && yarn build",
|
"rebuild": "pnpm clean && pnpm build",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"lint": "eslint --fix src/**/*.ts",
|
"lint": "eslint --fix src/**/*.ts",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"release": "yarn clean && yarn format && yarn lint && yarn build"
|
"release": "pnpm clean && pnpm format && pnpm lint && pnpm build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.6",
|
"@actions/cache": "^3.2.4",
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.2",
|
"@actions/io": "^1.1.3",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"semver": "^7.3.5"
|
"semver": "^7.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.24",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^16.3.2",
|
"@types/node": "^20.12.4",
|
||||||
"@types/semver": "^7.3.7",
|
"@types/semver": "^7.5.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
||||||
"@typescript-eslint/parser": "^4.28.3",
|
"@typescript-eslint/parser": "^7.5.0",
|
||||||
"@vercel/ncc": "^0.34.0",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^7.30.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-prettier": "^3.4.0",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"jest": "^27.0.6",
|
"jest": "^29.7.0",
|
||||||
"prettier": "^2.3.2",
|
"prettier": "^3.2.5",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^5.0.5",
|
||||||
"ts-jest": "^27.0.3",
|
"ts-jest": "^29.1.2",
|
||||||
"type-fest": "^1.2.2",
|
"type-fest": "^4.15.0",
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^5.4.4"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Yu Zhu"
|
"Yu Zhu"
|
||||||
|
|||||||
Generated
+4448
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -21,7 +21,7 @@ export async function lsRemote(repo: Repo): Promise<RefDic> {
|
|||||||
const data: RefDic = { heads: {}, tags: {}, pull: {} };
|
const data: RefDic = { heads: {}, tags: {}, pull: {} };
|
||||||
out.split('\n').forEach((line) => {
|
out.split('\n').forEach((line) => {
|
||||||
const [ref, tag] = line.trim().split('\t');
|
const [ref, tag] = line.trim().split('\t');
|
||||||
if (ref && tag && tag.startsWith('refs/')) {
|
if (ref && tag?.startsWith('refs/')) {
|
||||||
const tagPath = tag.split('/').splice(1);
|
const tagPath = tag.split('/').splice(1);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
let ldata = data as any; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
let ldata = data as any; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
||||||
|
|||||||
+2
-2
@@ -14,11 +14,11 @@ async function run(): Promise<void> {
|
|||||||
} else {
|
} else {
|
||||||
await unixInstall(version);
|
await unixInstall(version);
|
||||||
}
|
}
|
||||||
await exec('xmake --version');
|
await exec('xmake --root --version');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const ex = error as Error;
|
const ex = error as Error;
|
||||||
core.setFailed(ex.message);
|
core.setFailed(ex.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run().catch((e) => core.error(e));
|
run().catch((e: Error) => core.error(e));
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export async function unixInstall(version: Version): Promise<void> {
|
|||||||
}
|
}
|
||||||
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
|
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
|
||||||
toolDir = fullCachePath;
|
toolDir = fullCachePath;
|
||||||
|
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}".`);
|
||||||
await io.rmRF(fullCachePath);
|
await io.rmRF(fullCachePath);
|
||||||
|
|||||||
+67
-1
@@ -2,9 +2,12 @@ import * as core from '@actions/core';
|
|||||||
import { exec } from '@actions/exec';
|
import { exec } from '@actions/exec';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as toolCache from '@actions/tool-cache';
|
import * as toolCache from '@actions/tool-cache';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
import * as git from './git';
|
||||||
import { Version, GitVersion } from './interfaces';
|
import { Version, GitVersion } from './interfaces';
|
||||||
|
|
||||||
function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
|
function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
|
||||||
@@ -35,12 +38,48 @@ function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function installFromSource(xmakeBin: string, sourceDir: string, binDir: string): Promise<void> {
|
||||||
|
await exec(xmakeBin, ['-y'], { cwd: sourceDir });
|
||||||
|
await exec(xmakeBin, ['install', '-o', binDir, 'cli'], { cwd: sourceDir });
|
||||||
|
}
|
||||||
|
|
||||||
export async function winInstall(version: Version, latest: Version): Promise<void> {
|
export async function winInstall(version: Version, latest: Version): Promise<void> {
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const actionsCacheFolder = core.getInput('actions-cache-folder');
|
||||||
|
let actionsCacheKey = core.getInput('actions-cache-key');
|
||||||
|
if (!actionsCacheKey) {
|
||||||
|
actionsCacheKey = '';
|
||||||
|
}
|
||||||
|
|
||||||
const ver = version.version;
|
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()}-${
|
||||||
|
process.env.RUNNER_OS ?? '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 {
|
||||||
|
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 {
|
||||||
|
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||||
|
await io.rmRF(fullCachePath);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
toolDir = toolCache.find('xmake', ver);
|
||||||
|
}
|
||||||
|
|
||||||
if (!toolDir) {
|
if (!toolDir) {
|
||||||
const installer = await core.group(`download xmake ${String(version)}`, async () => {
|
const installer = await core.group(`download xmake ${String(version)}`, async () => {
|
||||||
const url = getInstallerUrl(version, latest);
|
const url = getInstallerUrl(version, latest);
|
||||||
@@ -65,6 +104,33 @@ export async function winInstall(version: Version, latest: Version): Promise<voi
|
|||||||
await io.rmRF(installer);
|
await io.rmRF(installer);
|
||||||
return cacheDir;
|
return cacheDir;
|
||||||
});
|
});
|
||||||
|
await 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);
|
core.addPath(toolDir);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user