Compare commits

...

22 Commits

15 changed files with 52539 additions and 55402 deletions
+2
View File
@@ -28,6 +28,8 @@ jobs:
- name: 'check for uncommitted changes' - name: 'check for uncommitted changes'
# Ensure no changes # Ensure no changes
run: | run: |
pnpm --version
node --version
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 'pnpm release' and check in all changes." echo "::error::Found changed files after build. Please run 'pnpm release' and check in all changes."
+24 -4
View File
@@ -22,16 +22,36 @@ jobs:
with: with:
xmake-version: ${{ matrix.version }} xmake-version: ${{ matrix.version }}
actions-cache-folder: '.xmake-cache' actions-cache-folder: '.xmake-cache'
actions-cache-key: ${{ matrix.version }} actions-cache-key: ${{ matrix.version }}-relative
build-cache: true build-cache: true
build-cache-key: ${{ matrix.version }} build-cache-key: ${{ matrix.version }}-relative
package-cache: true package-cache: true
package-cache-key: ${{ matrix.version }} package-cache-key: ${{ matrix.version }}-relative
project-path: 'tests/sample' project-path: 'tests/sample'
- name: Run tests - name: Run tests with relative cache path
run: | run: |
xmake --version xmake --version
cd tests/sample cd tests/sample
xmake -y -vD xmake -y -vD
xmake run xmake run
xmake clean
- uses: xmake-io/github-action-setup-xmake@master
with:
xmake-version: ${{ matrix.version }}
actions-cache-folder: '${{ runner.temp }}/xmake-cache'
actions-cache-key: ${{ matrix.version }}-absolute
build-cache: true
build-cache-key: ${{ matrix.version }}-absolute
package-cache: true
package-cache-key: ${{ matrix.version }}-absolute
project-path: 'tests/sample'
- name: Run tests with absolute cache path
run: |
xmake --version
cd tests/sample
xmake -y -vD
xmake run
xmake clean
+1 -1
View File
@@ -142,6 +142,6 @@ git branch test
git checkout test git checkout test
pnpm build pnpm build
pnpm release pnpm release
git-commit -a -m "..." git commit -a -m "..."
git push origin test git push origin test
``` ```
+52355 -55254
View File
File diff suppressed because one or more lines are too long
+13 -28
View File
@@ -1,20 +1,20 @@
{ {
"name": "github-action-setup-xmake", "name": "github-action-setup-xmake",
"version": "1.1.9", "version": "1.2.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "github-action-setup-xmake", "name": "github-action-setup-xmake",
"version": "1.1.9", "version": "1.2.4",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"dependencies": { "dependencies": {
"@actions/cache": "^4.0.3", "@actions/cache": "^4.0.3",
"@actions/core": "^1.10.1", "@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3", "@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.2",
"semver": "^7.6.0" "semver": "^7.7.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
@@ -103,22 +103,15 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@actions/tool-cache": { "node_modules/@actions/tool-cache": {
"version": "2.0.1", "version": "2.0.2",
"license": "MIT", "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
"integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.11.1",
"@actions/exec": "^1.0.0", "@actions/exec": "^1.0.0",
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
"@actions/io": "^1.1.1", "@actions/io": "^1.1.1",
"semver": "^6.1.0", "semver": "^6.1.0"
"uuid": "^3.3.2"
}
},
"node_modules/@actions/tool-cache/node_modules/@actions/exec": {
"version": "1.1.0",
"license": "MIT",
"dependencies": {
"@actions/io": "^1.0.1"
} }
}, },
"node_modules/@actions/tool-cache/node_modules/semver": { "node_modules/@actions/tool-cache/node_modules/semver": {
@@ -128,13 +121,6 @@
"semver": "bin/semver.js" "semver": "bin/semver.js"
} }
}, },
"node_modules/@actions/tool-cache/node_modules/uuid": {
"version": "3.4.0",
"license": "MIT",
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/@ampproject/remapping": { "node_modules/@ampproject/remapping": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
@@ -5476,10 +5462,9 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.6.3", "version": "7.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
"integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
"license": "ISC",
"bin": { "bin": {
"semver": "bin/semver.js" "semver": "bin/semver.js"
}, },
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "github-action-setup-xmake", "name": "github-action-setup-xmake",
"version": "1.1.9", "version": "1.2.4",
"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",
@@ -19,11 +19,11 @@
}, },
"dependencies": { "dependencies": {
"@actions/cache": "^4.0.3", "@actions/cache": "^4.0.3",
"@actions/core": "^1.10.1", "@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3", "@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.2",
"semver": "^7.6.0" "semver": "^7.7.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
+20 -55
View File
@@ -11,8 +11,8 @@ importers:
specifier: ^4.0.3 specifier: ^4.0.3
version: 4.0.3 version: 4.0.3
'@actions/core': '@actions/core':
specifier: ^1.10.1 specifier: ^1.11.1
version: 1.10.1 version: 1.11.1
'@actions/exec': '@actions/exec':
specifier: ^1.1.1 specifier: ^1.1.1
version: 1.1.1 version: 1.1.1
@@ -20,11 +20,11 @@ importers:
specifier: ^1.1.3 specifier: ^1.1.3
version: 1.1.3 version: 1.1.3
'@actions/tool-cache': '@actions/tool-cache':
specifier: ^2.0.1 specifier: ^2.0.2
version: 2.0.1 version: 2.0.2
semver: semver:
specifier: ^7.6.0 specifier: ^7.7.2
version: 7.6.0 version: 7.7.2
devDependencies: devDependencies:
'@types/jest': '@types/jest':
specifier: ^29.5.12 specifier: ^29.5.12
@@ -82,10 +82,6 @@ packages:
resolution: resolution:
{ integrity: sha512-SvrqFtYJ7I48A/uXNkoJrnukx5weQv1fGquhs3+4nkByZThBH109KTIqj5x/cGV7JGNvb8dLPVywUOqX1fjiXg== } { integrity: sha512-SvrqFtYJ7I48A/uXNkoJrnukx5weQv1fGquhs3+4nkByZThBH109KTIqj5x/cGV7JGNvb8dLPVywUOqX1fjiXg== }
'@actions/core@1.10.1':
resolution:
{ integrity: sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g== }
'@actions/core@1.11.1': '@actions/core@1.11.1':
resolution: resolution:
{ integrity: sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A== } { integrity: sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A== }
@@ -106,9 +102,9 @@ packages:
resolution: resolution:
{ integrity: sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q== } { integrity: sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q== }
'@actions/tool-cache@2.0.1': '@actions/tool-cache@2.0.2':
resolution: resolution:
{ integrity: sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA== } { integrity: sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w== }
'@ampproject/remapping@2.3.0': '@ampproject/remapping@2.3.0':
resolution: resolution:
@@ -1706,11 +1702,6 @@ packages:
resolution: resolution:
{ integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== } { integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== }
lru-cache@6.0.0:
resolution:
{ integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== }
engines: { node: '>=10' }
make-dir@4.0.0: make-dir@4.0.0:
resolution: resolution:
{ integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== } { integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== }
@@ -2012,9 +2003,9 @@ packages:
{ integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== } { integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== }
hasBin: true hasBin: true
semver@7.6.0: semver@7.7.2:
resolution: resolution:
{ integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== } { integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA== }
engines: { node: '>=10' } engines: { node: '>=10' }
hasBin: true hasBin: true
@@ -2255,12 +2246,6 @@ packages:
resolution: resolution:
{ integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== } { integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== }
uuid@3.4.0:
resolution:
{ integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== }
deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
hasBin: true
uuid@8.3.2: uuid@8.3.2:
resolution: resolution:
{ integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== } { integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== }
@@ -2327,10 +2312,6 @@ packages:
resolution: resolution:
{ integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== } { integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== }
yallist@4.0.0:
resolution:
{ integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== }
yargs-parser@21.1.1: yargs-parser@21.1.1:
resolution: resolution:
{ integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== } { integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== }
@@ -2364,11 +2345,6 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- encoding - encoding
'@actions/core@1.10.1':
dependencies:
'@actions/http-client': 2.2.1
uuid: 8.3.2
'@actions/core@1.11.1': '@actions/core@1.11.1':
dependencies: dependencies:
'@actions/exec': 1.1.1 '@actions/exec': 1.1.1
@@ -2390,14 +2366,13 @@ snapshots:
'@actions/io@1.1.3': {} '@actions/io@1.1.3': {}
'@actions/tool-cache@2.0.1': '@actions/tool-cache@2.0.2':
dependencies: dependencies:
'@actions/core': 1.10.1 '@actions/core': 1.11.1
'@actions/exec': 1.1.1 '@actions/exec': 1.1.1
'@actions/http-client': 2.2.1 '@actions/http-client': 2.2.1
'@actions/io': 1.1.3 '@actions/io': 1.1.3
semver: 6.3.1 semver: 6.3.1
uuid: 3.4.0
'@ampproject/remapping@2.3.0': '@ampproject/remapping@2.3.0':
dependencies: dependencies:
@@ -3051,7 +3026,7 @@ snapshots:
graphemer: 1.4.0 graphemer: 1.4.0
ignore: 5.3.1 ignore: 5.3.1
natural-compare: 1.4.0 natural-compare: 1.4.0
semver: 7.6.0 semver: 7.7.2
ts-api-utils: 1.3.0(typescript@5.4.4) ts-api-utils: 1.3.0(typescript@5.4.4)
optionalDependencies: optionalDependencies:
typescript: 5.4.4 typescript: 5.4.4
@@ -3098,7 +3073,7 @@ snapshots:
globby: 11.1.0 globby: 11.1.0
is-glob: 4.0.3 is-glob: 4.0.3
minimatch: 9.0.3 minimatch: 9.0.3
semver: 7.6.0 semver: 7.7.2
ts-api-utils: 1.3.0(typescript@5.4.4) ts-api-utils: 1.3.0(typescript@5.4.4)
optionalDependencies: optionalDependencies:
typescript: 5.4.4 typescript: 5.4.4
@@ -3114,7 +3089,7 @@ snapshots:
'@typescript-eslint/types': 7.5.0 '@typescript-eslint/types': 7.5.0
'@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4) '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4)
eslint: 8.57.0 eslint: 8.57.0
semver: 7.6.0 semver: 7.7.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
- typescript - typescript
@@ -3696,7 +3671,7 @@ snapshots:
'@babel/parser': 7.24.4 '@babel/parser': 7.24.4
'@istanbuljs/schema': 0.1.3 '@istanbuljs/schema': 0.1.3
istanbul-lib-coverage: 3.2.2 istanbul-lib-coverage: 3.2.2
semver: 7.6.0 semver: 7.7.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@@ -3981,7 +3956,7 @@ snapshots:
jest-util: 29.7.0 jest-util: 29.7.0
natural-compare: 1.4.0 natural-compare: 1.4.0
pretty-format: 29.7.0 pretty-format: 29.7.0
semver: 7.6.0 semver: 7.7.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@@ -4089,13 +4064,9 @@ snapshots:
dependencies: dependencies:
yallist: 3.1.1 yallist: 3.1.1
lru-cache@6.0.0:
dependencies:
yallist: 4.0.0
make-dir@4.0.0: make-dir@4.0.0:
dependencies: dependencies:
semver: 7.6.0 semver: 7.7.2
make-error@1.3.6: {} make-error@1.3.6: {}
@@ -4288,9 +4259,7 @@ snapshots:
semver@6.3.1: {} semver@6.3.1: {}
semver@7.6.0: semver@7.7.2: {}
dependencies:
lru-cache: 6.0.0
shebang-command@2.0.0: shebang-command@2.0.0:
dependencies: dependencies:
@@ -4400,7 +4369,7 @@ snapshots:
json5: 2.2.3 json5: 2.2.3
lodash.memoize: 4.1.2 lodash.memoize: 4.1.2
make-error: 1.3.6 make-error: 1.3.6
semver: 7.6.0 semver: 7.7.2
typescript: 5.4.4 typescript: 5.4.4
yargs-parser: 21.1.1 yargs-parser: 21.1.1
optionalDependencies: optionalDependencies:
@@ -4446,8 +4415,6 @@ snapshots:
dependencies: dependencies:
punycode: 2.3.1 punycode: 2.3.1
uuid@3.4.0: {}
uuid@8.3.2: {} uuid@8.3.2: {}
v8-to-istanbul@9.2.0: v8-to-istanbul@9.2.0:
@@ -4501,8 +4468,6 @@ snapshots:
yallist@3.1.1: {} yallist@3.1.1: {}
yallist@4.0.0: {}
yargs-parser@21.1.1: {} yargs-parser@21.1.1: {}
yargs@17.7.2: yargs@17.7.2:
+6 -5
View File
@@ -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');
+31 -16
View File
@@ -3,6 +3,7 @@ import * as io from '@actions/io';
import * as os from 'os'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import { Sha, RefDic, Repo } from './interfaces'; import { Sha, RefDic, Repo } from './interfaces';
import { valid as isValidSemver } from 'semver';
function makeOpt(ref: Sha): { cwd: string } { function makeOpt(ref: Sha): { cwd: string } {
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) }; return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
@@ -20,24 +21,38 @@ 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, path] = line.trim().split('\t') as [Sha, string];
if (ref && tag?.startsWith('refs/')) { if (ref && path?.startsWith('refs/')) {
const tagPath = tag.split('/').splice(1); const tagPath = path.split('/').splice(1);
// eslint-disable-next-line @typescript-eslint/no-explicit-any switch (tagPath[0]) {
let ldata = data as any; // eslint-disable-line @typescript-eslint/no-unsafe-assignment case 'heads': {
for (let i = 0; i < tagPath.length - 1; i++) { // refs/heads/copilot/fix-6807
const seg = tagPath[i]; const head = tagPath.slice(1).join('/');
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access data.heads[head] = ref;
if (typeof ldata[seg] === 'object') { break;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ldata = ldata[seg]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
} else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ldata = ldata[seg] = {};
} }
case 'pull': {
// refs/pull/11/head
// refs/pull/11/merge
const pr = Number(tagPath[1]);
if (!data.pull[pr]) {
data.pull[pr] = {} as RefDic['pull'][number];
}
data.pull[pr][tagPath[2] as 'head' | 'merge'] = ref;
break;
}
case 'tags': {
// refs/tags/preview
// refs/tags/v3.0.3
const tag = tagPath.slice(1).join('/');
if (isValidSemver(tag)) {
data.tags[tag] = ref;
}
break;
}
default:
break;
} }
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ldata[tagPath[tagPath.length - 1]] = ref;
} }
}); });
return data; return data;
+1 -2
View File
@@ -7,8 +7,7 @@ import { unixInstall } from './unix-install';
export async function installXmake(): Promise<void> { export async function installXmake(): Promise<void> {
const version = await selectVersion(); const version = await selectVersion();
if (os.platform() === 'win32' || os.platform() === 'cygwin') { if (os.platform() === 'win32' || os.platform() === 'cygwin') {
const latest = await selectVersion('latest'); await winInstall(version);
await winInstall(version, latest);
} else { } else {
await unixInstall(version); await unixInstall(version);
} }
+3 -2
View File
@@ -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> {
+28
View File
@@ -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;
}
+6 -6
View File
@@ -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,12 +33,11 @@ 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.resolve(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
try { try {
try { try {
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK); fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
@@ -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 {
@@ -65,7 +65,7 @@ export async function unixInstall(version: Version): Promise<void> {
let cacheDir = ''; let cacheDir = '';
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) { if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
cacheDir = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder); cacheDir = path.resolve(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
await io.cp(binDir, cacheDir, { await io.cp(binDir, cacheDir, {
recursive: true, recursive: true,
}); });
+8 -8
View File
@@ -96,11 +96,11 @@ async function selectSha(repo: Repo, sha: string): Promise<Version> {
} }
} }
return Promise.resolve( return Promise.resolve(
new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`), new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substring(0, 8)}`),
); );
} }
export async function selectVersion(version?: string): Promise<Version> { export async function selectVersion(version?: string, _fallback: boolean = false): Promise<Version> {
// get version string // get version string
version = (version ?? core.getInput('xmake-version')) || 'latest'; version = (version ?? core.getInput('xmake-version')) || 'latest';
if (version.toLowerCase() === 'latest') version = ''; if (version.toLowerCase() === 'latest') version = '';
@@ -123,20 +123,20 @@ export async function selectVersion(version?: string): Promise<Version> {
// select branch // select branch
if (version.startsWith('branch@')) { if (version.startsWith('branch@')) {
const branch = version.substr('branch@'.length); const branch = version.substring('branch@'.length);
ret = await selectBranch(repo, branch); ret = await selectBranch(repo, branch);
} }
// select pr // select pr
if (version.startsWith('pr@')) { if (version.startsWith('pr@')) {
const pr = Number.parseInt(version.substr('pr@'.length)); const pr = Number.parseInt(version.substring('pr@'.length));
if (Number.isNaN(pr) || pr <= 0) { if (Number.isNaN(pr) || pr <= 0) {
throw new Error(`Invalid pull requrest ${version.substr('pr@'.length)}, should be a positive integer`); throw new Error(`Invalid pull requrest ${version.substring('pr@'.length)}, should be a positive integer`);
} }
ret = await selectPr(repo, pr); ret = await selectPr(repo, pr);
} }
// select sha // select sha
if (version.startsWith('sha@')) { if (version.startsWith('sha@')) {
const sha = version.substr('sha@'.length); const sha = version.substring('sha@'.length);
ret = await selectSha(repo, sha); ret = await selectSha(repo, sha);
} }
// select version // select version
@@ -148,9 +148,9 @@ export async function selectVersion(version?: string): Promise<Version> {
} }
if (ret.type === 'local') { if (ret.type === 'local') {
core.info(`Use local xmake at '${ret.path}'`); core.info(`Use local xmake at '${ret.path}'`);
} else { } else if (!_fallback) {
core.info( core.info(
`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` + `Selected xmake ${String(ret)} (commit: ${ret.sha.substring(0, 8)})` +
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''), (repo !== DEFAULT_REPO ? ` of ${repo}` : ''),
); );
} }
+37 -17
View File
@@ -9,17 +9,22 @@ 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 { selectVersion } from './versions';
import { getPlatformIdentifier } from './system';
function getInstallerUrl(version: GitVersion, latest: GitVersion): string { async function getInstallerUrl(version: GitVersion, _fallback: boolean = false): Promise<string> {
let ver = version.version; const latest = (await selectVersion('latest', _fallback)) as GitVersion;
const latestVers = latest.version;
let vers = version.version;
let finalUrl: string;
switch (version.type) { switch (version.type) {
case 'heads': { case 'heads': {
const arch = os.arch() === 'arm64' ? 'arm64' : os.arch() === 'x64' ? 'win64' : 'win32'; const arch = os.arch() === 'arm64' ? 'arm64' : os.arch() === 'x64' ? 'win64' : 'win32';
const latestver = latest.version; if (vers !== 'dev' && vers !== 'master') {
if (ver !== 'dev' && ver !== 'master') { vers = latestVers;
ver = latestver;
} }
return `https://github.com/xmake-io/xmake/releases/download/${latestver}/xmake-${ver}.${arch}.exe`; finalUrl = `https://github.com/xmake-io/xmake/releases/download/${latestVers}/xmake-${vers}.${arch}.exe`;
break;
} }
case 'pull': { case 'pull': {
throw new Error('PR builds for windows is not supported'); throw new Error('PR builds for windows is not supported');
@@ -29,9 +34,10 @@ function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
} }
case 'tags': { case 'tags': {
const arch = os.arch() === 'arm64' ? 'arm64' : os.arch() === 'x64' ? 'win64' : 'win32'; const arch = os.arch() === 'arm64' ? 'arm64' : os.arch() === 'x64' ? 'win64' : 'win32';
return semver.gt(ver, '2.2.6') finalUrl = semver.gt(vers, '2.2.6')
? `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.${arch}.exe` ? `https://github.com/xmake-io/xmake/releases/download/${vers}/xmake-${vers}.${arch}.exe`
: `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.exe`; : `https://github.com/xmake-io/xmake/releases/download/${vers}/xmake-${vers}.exe`;
break;
} }
default: { default: {
// check that we have tested all types // check that we have tested all types
@@ -39,6 +45,21 @@ function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
throw new Error('Unknown version type'); throw new Error('Unknown version type');
} }
} }
// check if the URL returns 404. If so, xmake may have just released a
// new version, causing some binaries to be temporarily unavailable, so
// we need to fallback to the previous version.
if (!_fallback) {
const head = await fetch(finalUrl, { method: 'HEAD' });
if (head.status === 404) {
const currentVers = latestVers || vers;
const previousVersion = (await selectVersion('<' + currentVers)) as GitVersion;
core.warning(
`The requested version ${currentVers} (${finalUrl}) resource is temporarily unavailable, trying to fallback to the previous version...`,
);
return await getInstallerUrl(previousVersion, true);
}
}
return finalUrl;
} }
async function installFromSource(xmakeBin: string, sourceDir: string, binDir: string): Promise<void> { async function installFromSource(xmakeBin: string, sourceDir: string, binDir: string): Promise<void> {
@@ -46,8 +67,8 @@ async function installFromSource(xmakeBin: string, sourceDir: string, binDir: st
await exec(xmakeBin, ['install', '-o', binDir, 'cli'], { 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): Promise<void> {
if (version.type === 'local' || latest.type === 'local') { if (version.type === 'local') {
throw new Error('Local builds for windows is not supported'); throw new Error('Local builds for windows is not supported');
} }
@@ -59,13 +80,12 @@ 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) {
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder); const fullCachePath = path.resolve(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
try { try {
try { try {
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK); fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
@@ -85,7 +105,7 @@ export async function winInstall(version: Version, latest: Version): Promise<voi
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 = await getInstallerUrl(version);
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({ const exe = path.format({
@@ -126,7 +146,7 @@ export async function winInstall(version: Version, latest: Version): Promise<voi
if (toolDir) { if (toolDir) {
let cacheDir = ''; let cacheDir = '';
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) { if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
cacheDir = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder); cacheDir = path.resolve(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
await io.cp(toolDir, cacheDir, { await io.cp(toolDir, cacheDir, {
recursive: true, recursive: true,
}); });