Compare commits
206 Commits
@@ -0,0 +1,37 @@
|
||||
root: true
|
||||
parser: '@typescript-eslint/parser'
|
||||
parserOptions:
|
||||
project: tsconfig.json
|
||||
plugins:
|
||||
- '@typescript-eslint'
|
||||
- prettier
|
||||
extends:
|
||||
- eslint:recommended
|
||||
- plugin:@typescript-eslint/recommended
|
||||
- plugin:@typescript-eslint/recommended-requiring-type-checking
|
||||
- plugin:prettier/recommended
|
||||
rules:
|
||||
'prettier/prettier': [1]
|
||||
'@typescript-eslint/array-type': [1, { default: array-simple }]
|
||||
'@typescript-eslint/explicit-function-return-type':
|
||||
- 2
|
||||
- allowExpressions: true
|
||||
'@typescript-eslint/no-extraneous-class':
|
||||
- 1
|
||||
- allowWithDecorator: true
|
||||
allowStaticOnly: true
|
||||
'@typescript-eslint/parameter-properties':
|
||||
- 1
|
||||
- allow: [protected readonly, private readonly, public readonly, readonly]
|
||||
'@typescript-eslint/no-throw-literal': [2]
|
||||
'no-unused-vars': [0]
|
||||
'@typescript-eslint/no-unused-vars':
|
||||
- 1
|
||||
- varsIgnorePattern: ^_
|
||||
argsIgnorePattern: ^_
|
||||
'@typescript-eslint/prefer-for-of': [1]
|
||||
'@typescript-eslint/prefer-function-type': [1]
|
||||
'@typescript-eslint/prefer-nullish-coalescing': [1]
|
||||
'@typescript-eslint/prefer-optional-chain': [1]
|
||||
no-void: [1, { allowAsStatement: true }]
|
||||
eqeqeq: [1, smart]
|
||||
@@ -0,0 +1,37 @@
|
||||
name: checkin
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
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: 23
|
||||
pnpm-version: 9
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: test
|
||||
run: pnpm test
|
||||
- name: release
|
||||
run: pnpm release
|
||||
- name: 'check for uncommitted changes'
|
||||
# Ensure no changes
|
||||
run: |
|
||||
pnpm --version
|
||||
node --version
|
||||
git add .
|
||||
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."
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,57 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
- push
|
||||
|
||||
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, windows-11-arm, macOS-latest]
|
||||
version: [latest, branch@master, branch@dev]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: xmake-io/github-action-setup-xmake@master
|
||||
with:
|
||||
xmake-version: ${{ matrix.version }}
|
||||
actions-cache-folder: '.xmake-cache'
|
||||
actions-cache-key: ${{ matrix.version }}-relative
|
||||
build-cache: true
|
||||
build-cache-key: ${{ matrix.version }}-relative
|
||||
package-cache: true
|
||||
package-cache-key: ${{ matrix.version }}-relative
|
||||
project-path: 'tests/sample'
|
||||
|
||||
- name: Run tests with relative cache path
|
||||
run: |
|
||||
xmake --version
|
||||
cd tests/sample
|
||||
xmake -y -vD
|
||||
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
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
# 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
|
||||
@@ -0,0 +1,11 @@
|
||||
singleQuote: true
|
||||
trailingComma: all
|
||||
tabWidth: 2
|
||||
endOfLine: lf
|
||||
printWidth: 120
|
||||
overrides:
|
||||
- files:
|
||||
- '*.js'
|
||||
- '*.ts'
|
||||
options:
|
||||
tabWidth: 4
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"npm.packageManager": "pnpm",
|
||||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"],
|
||||
"eslint.enable": true,
|
||||
"files.autoSave": "off",
|
||||
"eslint.format.enable": true,
|
||||
"editor.tabSize": 4,
|
||||
"editor.formatOnSave": false,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit"
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
},
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,147 @@
|
||||
# GitHub Action - Setup xmake
|
||||
|
||||
[](https://github.com/xmake-io/github-action-setup-xmake/actions)
|
||||
[](https://github.com/marketplace/actions/setup-xmake)
|
||||
|
||||
Set up your GitHub Actions workflow with a specific version of xmake
|
||||
|
||||
## Usage
|
||||
|
||||
See [action.yml](./action.yml).
|
||||
|
||||
## Example
|
||||
|
||||
### Use latest version
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: latest
|
||||
```
|
||||
|
||||
### Use specified version
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.5.3'
|
||||
```
|
||||
|
||||
### Use specified branch
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: branch@master
|
||||
```
|
||||
|
||||
### Use semver
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '>=2.2.6 <=2.5.3'
|
||||
```
|
||||
|
||||
### Cache xmake
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.9.7'
|
||||
actions-cache-folder: '.xmake-cache'
|
||||
```
|
||||
|
||||
### Cache xmake with cachekey
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.9.7'
|
||||
actions-cache-folder: '.xmake-cache'
|
||||
actions-cache-key: 'archlinux-ci'
|
||||
```
|
||||
|
||||
### Cache packages
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.9.7'
|
||||
package-cache: true
|
||||
package-cache-key: 'archlinux-ci'
|
||||
project-path: 'myproject' # we need to compute packages hashkey for project
|
||||
```
|
||||
|
||||
### Cache build
|
||||
|
||||
By default, xmake disables build cache when building on ci, so we need to enable it first.
|
||||
|
||||
```bash
|
||||
$ xmake f --policies=build.ccache:y
|
||||
```
|
||||
|
||||
And xmake v2.9.8 will enable it by default if action/build-cache is enabled.
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.9.7'
|
||||
build-cache: true
|
||||
build-cache-key: 'archlinux-ci'
|
||||
```
|
||||
|
||||
Cache build with the specific project path.
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.9.7'
|
||||
build-cache: true
|
||||
project-path: 'myproject' # we can get the build cache path from project.
|
||||
```
|
||||
|
||||
Cache build with the specific build path.
|
||||
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.9.7'
|
||||
build-cache: true
|
||||
build-cache-path: 'build/.build_cache'
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
### Prepare development environment
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
### Draft a new release
|
||||
|
||||
```bash
|
||||
pnpm release
|
||||
git add .
|
||||
git commit -m "build: release"
|
||||
pnpm version [new-version]
|
||||
|
||||
# for a minor version or patch of v1
|
||||
git tag --delete v1
|
||||
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
|
||||
```
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.0.x | :white_check_mark: |
|
||||
|
||||
<!--
|
||||
| 5.0.x | :x: |
|
||||
| 4.0.x | :white_check_mark: |
|
||||
| < 4.0 | :x: |
|
||||
-->
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Use github issues to report a vulnerability.
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
name: setup xmake
|
||||
description: Set up a xmake environment and add it to the PATH
|
||||
author: OpportunityLiu
|
||||
branding:
|
||||
icon: play
|
||||
color: green
|
||||
|
||||
inputs:
|
||||
xmake-version:
|
||||
required: true
|
||||
default: latest
|
||||
description: The version to use. Should be a semver range or 'latest'. Or use [{repository}#]branch@{branch_name} to select a branch.
|
||||
actions-cache-folder:
|
||||
description: 'Directory to cache xmake in. This folder will go under $GITHUB_HOME (I.e. build dir) and be cached using @actions/cache.'
|
||||
default: ''
|
||||
actions-cache-key:
|
||||
description: The actions cache key.
|
||||
default: ''
|
||||
package-cache:
|
||||
description: Enable package cache.
|
||||
default: false
|
||||
package-cache-key:
|
||||
description: The packages cache key.
|
||||
default: ''
|
||||
project-path:
|
||||
description: The project root path.
|
||||
default: ''
|
||||
build-cache:
|
||||
description: Enable build cache.
|
||||
default: false
|
||||
build-cache-path:
|
||||
description: The build cache path.
|
||||
default: ''
|
||||
build-cache-key:
|
||||
description: The build cache key.
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: 'node20'
|
||||
main: 'dist/index.js'
|
||||
post: 'dist/index.js'
|
||||
Vendored
+84957
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
Generated
+6138
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "github-action-setup-xmake",
|
||||
"version": "1.2.4",
|
||||
"description": "Set up your GitHub Actions workflow with a specific version of xmake",
|
||||
"main": "dist/index.js",
|
||||
"author": "OpportunityLiu",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"repository": "https://github.com/xmake-io/github-action-setup-xmake.git",
|
||||
"homepage": "https://github.com/xmake-io/github-action-setup-xmake",
|
||||
"scripts": {
|
||||
"watch": "tsc --watch",
|
||||
"build": "ncc build src/index.ts",
|
||||
"rebuild": "pnpm clean && pnpm build",
|
||||
"clean": "rimraf dist",
|
||||
"lint": "eslint --fix src/**/*.ts",
|
||||
"format": "prettier --write .",
|
||||
"test": "jest",
|
||||
"release": "pnpm clean && pnpm format && pnpm lint && pnpm build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/cache": "^4.0.3",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.3",
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"semver": "^7.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.12.4",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
||||
"@typescript-eslint/parser": "^7.5.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.2.5",
|
||||
"rimraf": "^5.0.5",
|
||||
"ts-jest": "^29.1.2",
|
||||
"type-fest": "^4.15.0",
|
||||
"typescript": "^5.4.4"
|
||||
},
|
||||
"contributors": [
|
||||
"Yu Zhu"
|
||||
]
|
||||
}
|
||||
Generated
+4483
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,169 @@
|
||||
import * as core from '@actions/core';
|
||||
import { exec, ExecOptions } from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as path from 'path';
|
||||
import * as fsutils from './fsutils';
|
||||
import { getPlatformIdentifier } from './system';
|
||||
|
||||
function getBuildTime(hours?: string): string {
|
||||
let key = 'BuildTime';
|
||||
if (hours && hours !== '') {
|
||||
key = key + hours;
|
||||
}
|
||||
let buildTime = core.getState(key);
|
||||
if (!buildTime || buildTime === '') {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
if (!hours || hours === '') {
|
||||
hours = String(now.getHours()).padStart(2, '0');
|
||||
}
|
||||
buildTime = `${year}${month}${day}_${hours}`;
|
||||
core.saveState(key, buildTime);
|
||||
}
|
||||
return buildTime;
|
||||
}
|
||||
|
||||
function getProjectRootPath(): string {
|
||||
let projectRootPath = core.getInput('project-path');
|
||||
if (!projectRootPath) {
|
||||
projectRootPath = process.cwd();
|
||||
}
|
||||
projectRootPath = projectRootPath.trim();
|
||||
if (projectRootPath && projectRootPath !== '' && !path.isAbsolute(projectRootPath)) {
|
||||
projectRootPath = path.join(process.cwd(), projectRootPath);
|
||||
}
|
||||
return projectRootPath;
|
||||
}
|
||||
|
||||
async function getBuildCacheKey(buildCacheTime?: string): Promise<string> {
|
||||
let buildCacheKey = core.getInput('build-cache-key');
|
||||
if (!buildCacheKey) {
|
||||
buildCacheKey = '';
|
||||
}
|
||||
if (!buildCacheTime || buildCacheTime === '') {
|
||||
buildCacheTime = getBuildTime();
|
||||
}
|
||||
const platformIdentifier = await getPlatformIdentifier();
|
||||
return `xmake-build-cache-${buildCacheKey}-${buildCacheTime}-${platformIdentifier}`;
|
||||
}
|
||||
|
||||
async function getBuildCachePath(): Promise<string> {
|
||||
let buildCachePath = core.getInput('build-cache-path');
|
||||
if (!buildCachePath) {
|
||||
buildCachePath = '';
|
||||
const projectRootPath = getProjectRootPath();
|
||||
if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
|
||||
const options: ExecOptions = {};
|
||||
options.env = {
|
||||
...process.env,
|
||||
XMAKE_ROOT: 'y',
|
||||
};
|
||||
options.cwd = projectRootPath;
|
||||
options.listeners = {
|
||||
stdout: (data: Buffer) => {
|
||||
buildCachePath += data.toString();
|
||||
},
|
||||
};
|
||||
await exec(
|
||||
'xmake',
|
||||
[
|
||||
'l',
|
||||
'-c',
|
||||
'import("core.project.config"); import("private.cache.build_cache"); config.load(); print(build_cache.rootdir())',
|
||||
],
|
||||
options,
|
||||
);
|
||||
buildCachePath = buildCachePath.trim();
|
||||
if (buildCachePath !== '' && !path.isAbsolute(buildCachePath)) {
|
||||
buildCachePath = path.join(projectRootPath, buildCachePath);
|
||||
}
|
||||
} else {
|
||||
buildCachePath = 'build/.build_cache';
|
||||
}
|
||||
}
|
||||
return buildCachePath;
|
||||
}
|
||||
|
||||
function getBuildCacheFolder(): string {
|
||||
return '.xmake-build-cache';
|
||||
}
|
||||
|
||||
export async function loadBuildCache(): Promise<void> {
|
||||
const buildCache = core.getBooleanInput('build-cache');
|
||||
if (!buildCache) {
|
||||
return;
|
||||
}
|
||||
|
||||
// export $XMAKE_ACTION_BUILD_CACHE, xmake will check it and enable build cache by default on ci.
|
||||
core.exportVariable('XMAKE_ACTION_BUILD_CACHE', 'true');
|
||||
|
||||
const buildCacheFolder = getBuildCacheFolder();
|
||||
const buildCachePath = await getBuildCachePath();
|
||||
|
||||
if (buildCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, buildCacheFolder);
|
||||
const filepath = path.join(fullCachePath, 'build_cache_saved.txt');
|
||||
// Since action/cache cannot overwrite updates, we try to restore the cache from the last 24 hours.
|
||||
const now = new Date();
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const hours = now.getHours() - i;
|
||||
if (hours < 0) {
|
||||
break;
|
||||
}
|
||||
const buildCacheKey = await getBuildCacheKey(getBuildTime(String(hours).padStart(2, '0')));
|
||||
if (!fsutils.isFile(filepath)) {
|
||||
core.info(`Restore build cache path: ${fullCachePath} to ${buildCachePath}, key: ${buildCacheKey}`);
|
||||
await cache.restoreCache([buildCacheFolder], buildCacheKey);
|
||||
}
|
||||
if (fsutils.isFile(filepath)) {
|
||||
if (fsutils.isDir(buildCachePath)) {
|
||||
await io.rmRF(buildCachePath);
|
||||
}
|
||||
await io.cp(fullCachePath, buildCachePath, {
|
||||
recursive: true,
|
||||
});
|
||||
/* Even if the historical cache is hit, we need to update to the latest cache
|
||||
* Therefore, only when the latest cache is hit, it is a real hit, and we no longer need to update the cache.
|
||||
*/
|
||||
if (i === 0) {
|
||||
core.saveState('hitBuildCache', 'true');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fsutils.isFile(filepath)) {
|
||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||
await io.rmRF(fullCachePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveBuildCache(): Promise<void> {
|
||||
const buildCache = core.getBooleanInput('build-cache');
|
||||
if (!buildCache) {
|
||||
return;
|
||||
}
|
||||
|
||||
const buildCacheFolder = getBuildCacheFolder();
|
||||
const buildCacheKey = await getBuildCacheKey();
|
||||
const buildCachePath = await getBuildCachePath();
|
||||
|
||||
const hitBuildCache = !!core.getState('hitBuildCache');
|
||||
if (!hitBuildCache && buildCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(buildCachePath)) {
|
||||
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, buildCacheFolder);
|
||||
core.info(`Save build cache path: ${buildCachePath} to ${fullCachePath}, key: ${buildCacheKey}`);
|
||||
await io.cp(buildCachePath, fullCachePath, {
|
||||
recursive: true,
|
||||
});
|
||||
const options: ExecOptions = {};
|
||||
options.env = {
|
||||
...process.env,
|
||||
XMAKE_ROOT: 'y',
|
||||
};
|
||||
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'build_cache_saved.txt')], options);
|
||||
await cache.saveCache([buildCacheFolder], buildCacheKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as fs from 'fs';
|
||||
|
||||
export function isFile(filepath: string): boolean {
|
||||
try {
|
||||
fs.accessSync(filepath, fs.constants.F_OK);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function isDir(filepath: string): boolean {
|
||||
try {
|
||||
const stats = fs.statSync(filepath);
|
||||
if (stats.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as git from './git';
|
||||
import * as semver from 'semver';
|
||||
import { Repo } from './interfaces';
|
||||
|
||||
describe('lsRemote', () => {
|
||||
it('should return correct records', async () => {
|
||||
const records = await git.lsRemote(Repo('xmake-io/xmake'));
|
||||
expect(records).toHaveProperty('heads');
|
||||
expect(records).toHaveProperty('tags');
|
||||
expect(records).toHaveProperty('pull');
|
||||
|
||||
expect(Object.keys(records.tags).length).not.toBeLessThan(10);
|
||||
for (const tag in records.tags) {
|
||||
const ref = records.tags[tag];
|
||||
expect(semver.parse(tag)).toBeInstanceOf(semver.SemVer);
|
||||
expect(ref).toMatch(/^[0-9a-f]{40}$/gi);
|
||||
}
|
||||
for (const branch in records.heads) {
|
||||
const ref = records.heads[branch];
|
||||
expect(ref).toMatch(/^[0-9a-f]{40}$/gi);
|
||||
}
|
||||
}, 100000);
|
||||
});
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
import { exec } from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { Sha, RefDic, Repo } from './interfaces';
|
||||
import { valid as isValidSemver } from 'semver';
|
||||
|
||||
function makeOpt(ref: Sha): { cwd: string } {
|
||||
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
|
||||
}
|
||||
|
||||
const repoUrl = (repo: Repo): string => `https://github.com/${repo}.git`;
|
||||
|
||||
export async function lsRemote(repo: Repo): Promise<RefDic> {
|
||||
let out = '';
|
||||
await exec('git', ['ls-remote', repoUrl(repo)], {
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: (d) => (out += d.toString()),
|
||||
},
|
||||
});
|
||||
const data: RefDic = { heads: {}, tags: {}, pull: {} };
|
||||
out.split('\n').forEach((line) => {
|
||||
const [ref, path] = line.trim().split('\t') as [Sha, string];
|
||||
if (ref && path?.startsWith('refs/')) {
|
||||
const tagPath = path.split('/').splice(1);
|
||||
switch (tagPath[0]) {
|
||||
case 'heads': {
|
||||
// refs/heads/copilot/fix-6807
|
||||
const head = tagPath.slice(1).join('/');
|
||||
data.heads[head] = ref;
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function create(repo: Repo, ref: Sha): Promise<string> {
|
||||
const opt = makeOpt(ref);
|
||||
await io.rmRF(opt.cwd);
|
||||
await io.mkdirP(opt.cwd);
|
||||
await exec('git', ['init'], opt);
|
||||
await exec('git', ['remote', 'add', 'origin', repoUrl(repo)], opt);
|
||||
await exec(
|
||||
'git',
|
||||
['fetch', 'origin', '+refs/pull/*:refs/remotes/origin/pull/*', '+refs/heads/*:refs/remotes/origin/*'],
|
||||
opt,
|
||||
);
|
||||
await exec('git', ['checkout', ref], opt);
|
||||
await exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
||||
return opt.cwd;
|
||||
}
|
||||
|
||||
export async function cleanup(ref: Sha): Promise<void> {
|
||||
const opt = makeOpt(ref);
|
||||
await io.rmRF(opt.cwd);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as stateHelper from './state-helper';
|
||||
import { installXmake } from './install';
|
||||
import { loadBuildCache, saveBuildCache } from './build-cache';
|
||||
import { loadPackageCache, savePackageCache } from './package-cache';
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
await installXmake();
|
||||
await loadBuildCache();
|
||||
await loadPackageCache();
|
||||
} catch (error) {
|
||||
const ex = error as Error;
|
||||
core.setFailed(ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveCache(): Promise<void> {
|
||||
try {
|
||||
await saveBuildCache();
|
||||
await savePackageCache();
|
||||
} catch (error) {
|
||||
const ex = error as Error;
|
||||
core.setFailed(ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!stateHelper.IsPost) {
|
||||
run().catch((e: Error) => core.error(e));
|
||||
} else {
|
||||
saveCache().catch((e: Error) => core.error(e));
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { exec } from '@actions/exec';
|
||||
import * as os from 'os';
|
||||
import { selectVersion } from './versions';
|
||||
import { winInstall } from './win-install';
|
||||
import { unixInstall } from './unix-install';
|
||||
|
||||
export async function installXmake(): Promise<void> {
|
||||
const version = await selectVersion();
|
||||
if (os.platform() === 'win32' || os.platform() === 'cygwin') {
|
||||
await winInstall(version);
|
||||
} else {
|
||||
await unixInstall(version);
|
||||
}
|
||||
await exec('xmake --root --version');
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Opaque } from 'type-fest';
|
||||
|
||||
export type Sha = Opaque<string, 'sha'>;
|
||||
export function Sha(sha: string): Sha {
|
||||
sha = sha.trim().toLowerCase();
|
||||
if (!/^[a-f0-9]{40}$/g.test(sha)) throw new Error(`Invalid sha value ${sha}`);
|
||||
return sha as Sha;
|
||||
}
|
||||
|
||||
export type Repo = Opaque<string, 'repo'>;
|
||||
export function Repo(repo: string): Repo {
|
||||
repo = repo.trim();
|
||||
if (!/^([^/#]+\/[^/#]+)$/g.test(repo)) throw new Error(`Invalid repo value ${repo}`);
|
||||
return repo as Repo;
|
||||
}
|
||||
|
||||
export type RefDic = {
|
||||
/** branches */
|
||||
heads: Record<string, Sha>;
|
||||
/** tags */
|
||||
tags: Record<string, Sha>;
|
||||
/** pull requests */
|
||||
pull: Record<
|
||||
number,
|
||||
{
|
||||
/** the current state of the pull request */
|
||||
head: Sha;
|
||||
/** the current branch we're merging onto */
|
||||
base?: Sha;
|
||||
/** merge result */
|
||||
merge?: Sha;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
export interface GitVersion {
|
||||
version: string;
|
||||
sha: Sha;
|
||||
type: keyof RefDic | 'sha';
|
||||
repo: Repo;
|
||||
}
|
||||
|
||||
export interface LocalVersion {
|
||||
type: 'local';
|
||||
path: string;
|
||||
version: undefined;
|
||||
}
|
||||
|
||||
export type Version = GitVersion | LocalVersion;
|
||||
@@ -0,0 +1,132 @@
|
||||
import * as core from '@actions/core';
|
||||
import { exec, ExecOptions } from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as path from 'path';
|
||||
import * as fsutils from './fsutils';
|
||||
import { getPlatformIdentifier } from './system';
|
||||
|
||||
function getProjectRootPath(): string {
|
||||
let projectRootPath = core.getInput('project-path');
|
||||
if (!projectRootPath) {
|
||||
projectRootPath = process.cwd();
|
||||
}
|
||||
projectRootPath = projectRootPath.trim();
|
||||
if (projectRootPath && projectRootPath !== '' && !path.isAbsolute(projectRootPath)) {
|
||||
projectRootPath = path.join(process.cwd(), projectRootPath);
|
||||
}
|
||||
return projectRootPath;
|
||||
}
|
||||
|
||||
async function getPackageCacheKey(): Promise<string> {
|
||||
let packageCacheKey = core.getInput('package-cache-key');
|
||||
if (!packageCacheKey) {
|
||||
packageCacheKey = '';
|
||||
}
|
||||
let packageCacheHash = '';
|
||||
const projectRootPath = getProjectRootPath();
|
||||
if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
|
||||
const options: ExecOptions = {};
|
||||
options.env = {
|
||||
...process.env,
|
||||
XMAKE_ROOT: 'y',
|
||||
};
|
||||
options.cwd = projectRootPath;
|
||||
options.listeners = {
|
||||
stdout: (data: Buffer) => {
|
||||
packageCacheHash += data.toString();
|
||||
},
|
||||
};
|
||||
await exec('xmake', ['repo', '--update']);
|
||||
await exec('xmake', ['l', 'utils.ci.packageskey'], options);
|
||||
packageCacheHash = packageCacheHash.trim();
|
||||
}
|
||||
const platformIdentifier = await getPlatformIdentifier();
|
||||
return `xmake-package-cache-${packageCacheKey}-${packageCacheHash}-${platformIdentifier}`;
|
||||
}
|
||||
|
||||
async function getPackageCachePath(): Promise<string> {
|
||||
let packageCachePath = '';
|
||||
const options: ExecOptions = {};
|
||||
options.env = {
|
||||
...process.env,
|
||||
XMAKE_ROOT: 'y',
|
||||
};
|
||||
options.listeners = {
|
||||
stdout: (data: Buffer) => {
|
||||
packageCachePath += data.toString();
|
||||
},
|
||||
};
|
||||
await exec('xmake', ['l', '-c', 'import("core.package.package"); print(package.installdir())'], options);
|
||||
packageCachePath = packageCachePath.trim();
|
||||
return packageCachePath;
|
||||
}
|
||||
|
||||
function getPackageCacheFolder(): string {
|
||||
return '.xmake-package-cache';
|
||||
}
|
||||
|
||||
export async function loadPackageCache(): Promise<void> {
|
||||
const packageCache = core.getBooleanInput('package-cache');
|
||||
if (!packageCache) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageCacheFolder = getPackageCacheFolder();
|
||||
const packageCacheKey = await getPackageCacheKey();
|
||||
const packageCachePath = await getPackageCachePath();
|
||||
if (!packageCachePath || packageCachePath === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (packageCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, packageCacheFolder);
|
||||
const filepath = path.join(fullCachePath, 'package_cache_saved.txt');
|
||||
if (!fsutils.isFile(filepath)) {
|
||||
core.info(`Restore package cache path: ${fullCachePath} to ${packageCachePath}, key: ${packageCacheKey}`);
|
||||
await cache.restoreCache([packageCacheFolder], packageCacheKey);
|
||||
}
|
||||
if (fsutils.isFile(filepath)) {
|
||||
if (fsutils.isDir(packageCachePath)) {
|
||||
await io.rmRF(packageCachePath);
|
||||
}
|
||||
await io.cp(fullCachePath, packageCachePath, {
|
||||
recursive: true,
|
||||
});
|
||||
core.saveState('hitPackageCache', 'true');
|
||||
} else {
|
||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||
await io.rmRF(fullCachePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function savePackageCache(): Promise<void> {
|
||||
const packageCache = core.getBooleanInput('package-cache');
|
||||
if (!packageCache) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageCacheFolder = getPackageCacheFolder();
|
||||
const packageCacheKey = await getPackageCacheKey();
|
||||
const packageCachePath = await getPackageCachePath();
|
||||
if (!packageCachePath || packageCachePath === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
const hitPackageCache = !!core.getState('hitPackageCache');
|
||||
if (!hitPackageCache && packageCacheFolder && process.env.GITHUB_WORKSPACE && fsutils.isDir(packageCachePath)) {
|
||||
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, packageCacheFolder);
|
||||
core.info(`Save package cache path: ${packageCachePath} to ${fullCachePath}, key: ${packageCacheKey}`);
|
||||
await io.cp(packageCachePath, fullCachePath, {
|
||||
recursive: true,
|
||||
});
|
||||
const options: ExecOptions = {};
|
||||
options.env = {
|
||||
...process.env,
|
||||
XMAKE_ROOT: 'y',
|
||||
};
|
||||
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'package_cache_saved.txt')], options);
|
||||
await cache.saveCache([packageCacheFolder], packageCacheKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
/**
|
||||
* Indicates whether the POST action is running
|
||||
*/
|
||||
export const IsPost = !!core.getState('isPost');
|
||||
|
||||
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
|
||||
// This is necessary since we don't have a separate entry point.
|
||||
if (!IsPost) {
|
||||
core.saveState('isPost', 'true');
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import * as core from '@actions/core';
|
||||
import { exec } from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import * as git from './git';
|
||||
import { Version } from './interfaces';
|
||||
import { getPlatformIdentifier } from './system';
|
||||
|
||||
async function install(sourceDir: string, binDir: string): Promise<void> {
|
||||
if (fs.existsSync(path.join(sourceDir, 'configure'))) {
|
||||
await exec('sh', ['./configure'], { cwd: sourceDir });
|
||||
await exec('make', ['-j6'], { cwd: sourceDir });
|
||||
await exec('make', ['install', `PREFIX=${binDir}`], { cwd: sourceDir });
|
||||
} else {
|
||||
await exec('make', ['-j6'], { cwd: sourceDir });
|
||||
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||
}
|
||||
}
|
||||
|
||||
export async function unixInstall(version: Version): Promise<void> {
|
||||
let toolDir = '';
|
||||
const actionsCacheFolder = core.getInput('actions-cache-folder');
|
||||
let actionsCacheKey = core.getInput('actions-cache-key');
|
||||
if (!actionsCacheKey) {
|
||||
actionsCacheKey = '';
|
||||
}
|
||||
|
||||
if (version.type !== 'local') {
|
||||
const ver = version.version;
|
||||
const sha = version.sha;
|
||||
const platformIdentifier = await getPlatformIdentifier();
|
||||
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${platformIdentifier}`;
|
||||
|
||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
const fullCachePath = path.resolve(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||
try {
|
||||
try {
|
||||
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
|
||||
} catch {
|
||||
await cache.restoreCache([actionsCacheFolder], cacheKey);
|
||||
}
|
||||
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
|
||||
toolDir = fullCachePath;
|
||||
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
||||
} catch {
|
||||
core.warning(`No cached files found at path "${fullCachePath}, key: ${cacheKey}".`);
|
||||
await io.rmRF(fullCachePath);
|
||||
}
|
||||
} else {
|
||||
toolDir = toolCache.find('xmake', ver);
|
||||
}
|
||||
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core.group(`download xmake ${String(version)}`, () =>
|
||||
git.create(version.repo, version.sha),
|
||||
);
|
||||
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
await install(sourceDir, binDir);
|
||||
let cacheDir = '';
|
||||
|
||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
cacheDir = path.resolve(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||
await io.cp(binDir, cacheDir, {
|
||||
recursive: true,
|
||||
});
|
||||
await cache.saveCache([actionsCacheFolder], cacheKey);
|
||||
} else {
|
||||
cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
}
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// no tool cache for local install
|
||||
toolDir = await core.group(`install local xmake at '${version.path}'`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${Date.now()}`);
|
||||
await install(version.path, binDir);
|
||||
return binDir;
|
||||
});
|
||||
}
|
||||
// for versions 2.3.2 and above, xmake will be installed directly into the bin directory, and no script will be used to wrap it.
|
||||
if (version.type !== 'tags' || semver.gt(version.version, '2.3.1')) {
|
||||
core.addPath(path.join(toolDir, 'bin'));
|
||||
} else {
|
||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
jest.mock('./git', () => ({
|
||||
lsRemote(repo: Repo) {
|
||||
if (repo === 'xmake-io/xmake')
|
||||
return {
|
||||
heads: {
|
||||
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
||||
master: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
test: '18f0605f2e1764d4c07fa4f9fc24274275e1562c',
|
||||
},
|
||||
tags: {
|
||||
'v1.0.1': '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
||||
'v1.0.2': '84fa20ca3ded99b9667609c5cb2e56b2308c8e4b',
|
||||
'v1.0.3': 'e56812a09d3677957c41bccc8988599208e3b49a',
|
||||
'v1.0.4': '825dda9d93448ba783e18f7947eef0b4eb07942e',
|
||||
'v2.0.1': '432fd6a40018f4c29e08f1d4cadf1ccc387a0cff',
|
||||
'v2.0.2': 'd24fcddbc2f1093f3943a917d99c5a8989ef2644',
|
||||
'v2.0.3': 'b5f21a05b1cdaf46314238b4cc665976294df1da',
|
||||
'v2.0.4': '2b15a1b5b149e5156e22358f3d29b4de63473376',
|
||||
'v2.0.5': 'b168ce05d763957ed05844141d77d155bf842e7a',
|
||||
'v2.1.1': '5ba22ca230c3f3f9477491df6d39f11d53132fb1',
|
||||
'v2.1.2': 'bf69a2413117cf21c53bde1edbda713e77d4fd9b',
|
||||
'v2.1.3': '248b2cc8a96d41445a2e46d259d14fea8e4203ec',
|
||||
'v2.1.4': '1d94a23a7db35631f4b33b8b0b3968d0e62ffe2a',
|
||||
'v2.1.5': '72f68f941f9b6d07f71811fe403a2dc178270af0',
|
||||
'v2.1.6': '7ea60d24da152469258a4cb35b3ce591ea2fd961',
|
||||
'v2.1.7': 'a04725662933fbbe3ad4a319d03267fc32907242',
|
||||
'v2.1.8': '6c3f42dad5840210ee7294ca295f6c7b18c32291',
|
||||
'v2.1.9': '0f1e8530e89a9432678ed6fe4fef25d0485d1293',
|
||||
'v2.2.1': 'f15ff1ca73b02ff5f522c9fe59004331b1b410fb',
|
||||
'v2.2.2': '18a42e0e8980e3edc39198b18c5c4b9a464ea381',
|
||||
'v2.2.3': 'c4d0e69abf2b9caa88b997ca1f2935b6e0b00c9f',
|
||||
'v2.2.5': 'd71a01615883fffa53fbd28e578db14353628a52',
|
||||
'v2.2.6': 'eb60a76b7454975d151f2d8b5d9e19b26d561c2d',
|
||||
'v2.2.7': '72bd93de8dd64cc5de8986860819a5873ce08fe5',
|
||||
'v2.2.8': '6a2e390a79c4f0444a03b566d4bf24849a6ee3a3',
|
||||
'v2.2.9': '4c22b7a7823518d538a81081d2e795b9ce4403e2',
|
||||
'v2.3.1': 'f6155f883fd6377e0ee5002425f84f05eb420bef',
|
||||
'v2.3.2': '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
},
|
||||
pull: {
|
||||
'8': { head: '7e3ee3281df2b4caffebe25c87e871ba682dd701' },
|
||||
'11': {
|
||||
head: 'a18d2890ee7615f000b3a6b35150733e2e0013e3',
|
||||
merge: 'ac07a6f13d09ba445af6ba403647f09c6f10dc9b',
|
||||
},
|
||||
'23': {
|
||||
head: 'c33fd5a8b3e7ff7692630bbc8f5d5b6166502493',
|
||||
merge: '9041fc8587c9b797440ec2f58deb4626de688010',
|
||||
},
|
||||
'24': { head: '5777dbc4397360e21e26466634cfddc633531054' },
|
||||
'28': {
|
||||
head: 'a3a28f8abdfe8711b2e4d7496ade02e910070e9f',
|
||||
merge: '3bb5cf13cfa93ab186e7df168dce87718914696b',
|
||||
},
|
||||
'29': { head: '9400826a6fb06bbe08c23550c063eddafa65fe4b' },
|
||||
'38': { head: '745c8f9a3ad7d4c0282fcfbb108bfb053864cbbc' },
|
||||
'45': { head: '0a8ae5b98d2297bbad38fbf96cc78b373ac6f4ff' },
|
||||
'52': { head: 'c53c28bc7b0cd59ea984a3c687273aa47d608c2a' },
|
||||
'59': { head: '1e766da707d9b1075144303755f4e772fa33193d' },
|
||||
'61': {
|
||||
head: '75df3c9a5dafac83a8227ce84b004d3450b10c38',
|
||||
merge: '08962c4c13c6eea78e3c840711b030d30afebeb4',
|
||||
},
|
||||
'63': { head: 'c3fc0841da49c875cadf225ed2da2dc624c1c72f' },
|
||||
'65': {
|
||||
head: '7c6dca6fe620ee41cd09162bc31d2ab0ab371832',
|
||||
merge: '8c50b1e623668850f936ff980080425aedb7fac9',
|
||||
},
|
||||
'72': {
|
||||
head: 'db0f89089bab6a8b6444712b48d4e05d36b05bf4',
|
||||
merge: '3cf6fc8c23edfa66dff224e884a7faed8c2ecf02',
|
||||
},
|
||||
'74': { head: 'e9dde75d0f1159fda52b05f10646eae2cbdfc589' },
|
||||
'75': { head: '3b9b9fb9c1c302be15e87ffe47309b2c6bc8eaec' },
|
||||
'76': { head: '630f5f17601e5a35fb8b2e03fd7e3aad7af76c02' },
|
||||
'77': { head: '61ae623bda980eeb65f5f26c86e9a246a43b93cd' },
|
||||
'78': { head: '831481cdfbf0905b543ad503950233d7736b97d6' },
|
||||
'80': { head: '52c8ee6e3a5782f49e19bb1b4b9c8fa79661c0e0' },
|
||||
'81': { head: 'a145b7c6e0e491df3bc96a8b55201bacf6d73c77' },
|
||||
'82': { head: '55c84b7fc414036f783396b8e8f937c032dc2f34' },
|
||||
'84': { head: 'da6e4cce0e4c1736db0898d53c16ac8ca0441846' },
|
||||
'85': { head: '05590ed02faa985c7b358d4c10126db549e50a77' },
|
||||
'90': { head: 'c57aa4cf4463f33d3deaf8d58e42abbbd83b0e1b' },
|
||||
'91': { head: 'f04981e7a207a25ece6047e83ac3c34c8747e89b' },
|
||||
'92': {
|
||||
head: 'b226dc77e49c31bf41ca55440aede275a642cb0a',
|
||||
merge: '02f98269a1d7580621fedd809a182a47bf832dd6',
|
||||
},
|
||||
'93': { head: '37b4a7647163afdd392c7afcc61955244b6117cb' },
|
||||
'97': { head: 'd35751770b68b1daa7154e3dfbae4169e71af4dd' },
|
||||
'98': { head: '3687f2a29216e84aa182738e91bb0046a3950916' },
|
||||
'100': {
|
||||
head: '4f02b28754d131cbc3354a05535382eefd729231',
|
||||
merge: '0cd4dc9a46b7418e8471c758d6003e4e4d34ce87',
|
||||
},
|
||||
'102': {
|
||||
head: '0042b79375fd532220f9e9639ca6dfdc9007265a',
|
||||
merge: '6eceac557545ef3022e7401ef3daff235694fde3',
|
||||
},
|
||||
'103': { head: 'cbd86c9b25592b81dd010b6fa2e7ce52c31f50db' },
|
||||
'104': { head: 'e0be61b29d1d88ad7daa5f876faaf296e5935f9c' },
|
||||
'105': { head: '4456dbd2f7b2f96812ed00d67cf484178375931c' },
|
||||
'107': { head: '3f3b52d9b053a38b38557bc3a3e9aeb75d749350' },
|
||||
'108': { head: 'b54b263ab4f05564cc463a53d1efedc1c3703f2f' },
|
||||
'110': { head: 'b6724648232ed892301457c05cf5ec4deaefc2ed' },
|
||||
'112': { head: 'ba4864ad076d07320b9d0f0b4b11b3b22644031e' },
|
||||
'113': { head: '2cb7a91bf266680266de51636ce6620cbecc9362' },
|
||||
'114': { head: '1ad0641672627b5ae2cc417b73614c6ce842bb12' },
|
||||
'115': { head: '67a5ad78de9453d14b562cd7c3f2a4364e370d24' },
|
||||
'116': { head: '98a844e670ee733c1036947efd9099f7763fb544' },
|
||||
'118': { head: 'f2d1fc547a2f57da992b947cc3b3f615f9f2d34d' },
|
||||
'119': { head: '64645daebde9aceaeea7f24c9156cdaa4ac5e035' },
|
||||
'131': { head: '28353b3a76db9592acb23fed82461c07c8d6265b' },
|
||||
'187': { head: '92ea65b345d93a88777d02cccaedbccb12fe5fc3' },
|
||||
'188': { head: 'be03b89501a829e19932f86f491df80962bfe8d5' },
|
||||
'198': { head: '49298d9ead57f63b85f2a8ad9e072915617cc58d' },
|
||||
'204': {
|
||||
head: 'ac21734c1d1ae754146754f2656451091ff22014',
|
||||
merge: '39fcf9250a92c05eb837f82aefa0e1dc49660518',
|
||||
},
|
||||
'205': { head: 'd74715b3615e171776a6e5b9971d2ec2bff115d5' },
|
||||
'210': { head: '9ee12112e49db451a49a66d77dd2990d9f6ddab9' },
|
||||
'214': { head: 'b5b1c689f508068ffbde704194b08569151e383a' },
|
||||
'215': { head: '05b6182def036b36c8e4aeac8cdc55441fc4a4db' },
|
||||
'216': { head: 'e8af37c32549f54059f6e7635064c623b80c039c' },
|
||||
'217': {
|
||||
head: '905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||
merge: '2f93475049575ed5e44699daa378239bc141aad3',
|
||||
},
|
||||
'221': { head: 'ca7b50a40cf7c120d49ca8164f9a54c289dd5743' },
|
||||
'228': { head: '92f1645146c22699f4e2b567451f87fb0dbf2fc6' },
|
||||
'231': { head: 'ca72eb0cf60c3e0747444859d9fc738b98ecc4b5' },
|
||||
'235': { head: '69efc61859543613abc7ec553029852cd5693d17' },
|
||||
'245': { head: '5d33e86c3190d37d04ac26da804db3c53218ae7e' },
|
||||
'247': { head: '9ce75001587cc47db9c980dd99ba28d17b9cc7e8' },
|
||||
'248': { head: '8c6cd6b4dc6b6a6b18150480d9711595f0043f26' },
|
||||
'249': { head: 'a7543cbdfa7fcbe04178d53add85de04b54933b7' },
|
||||
'267': { head: '7d0901f3014960bd53afa0918f21c4a53094faad' },
|
||||
'270': { head: 'c584463f1cd693c2a5df78611816697343ac6ac4' },
|
||||
'273': { head: 'da267497a9677d4cfc7175d462494e1334823476' },
|
||||
'276': { head: '8a80645e856deeaa1df5ad6a2ef91a9c4d475cc8' },
|
||||
'282': { head: 'f9df7b9a3594c8613e6f54003add9ffdaa7e4b49' },
|
||||
'286': { head: '4c59f260714576e2c23aa068b4a1beae62756fd3' },
|
||||
'298': { head: '4175116555b4337ad6cd423373462eb9107617ec' },
|
||||
'303': { head: 'f114c56acb0264a094a99ceff5f45735ea17e54c' },
|
||||
'333': { head: '0f2f41de06a0a7e2852ae9d6b01fd8cde6da4965' },
|
||||
'365': { head: '88b7af92f6988abb30b72095592c74a245c06507' },
|
||||
'380': { head: '5462c4ef4fb470c5878a46cb809203fc1459998f' },
|
||||
'381': { head: 'bd186f9cf5a142aec24bf2d17eff4393487fbd87' },
|
||||
'384': { head: 'e3e646d4e39695b398d719c3340345c8f53750bc' },
|
||||
'387': { head: '84a97cf3471a039bbde45491d5db8eb470b3373e' },
|
||||
'392': { head: '4572f4895e11712ba620097cb504195abc060df2' },
|
||||
'394': { head: 'e34797ed62a4f5f7bab841a0982b3138300d637c' },
|
||||
'395': { head: 'c2a04219cf41346bfa2f4871eda8915d43f38f09' },
|
||||
'398': { head: '0e3f93ad95a57e2dbc3360c26292dacb767f8f54' },
|
||||
'402': { head: '9cebcd69efd4587e3ac56b23e488fbbc9b359f48' },
|
||||
'417': { head: '59a6c75f86de2cb080839910fa9395ccf1089083' },
|
||||
'418': { head: 'c2c491ab4bedea3be7b1a6aca8bb4e65a9d763db' },
|
||||
'420': { head: 'c9208456c2d0c8175d19290a50ccb6fdf95139bb' },
|
||||
'421': { head: '82277e5222154ff4463127681f2d18abb07d7f4a' },
|
||||
'422': { head: 'ace80d7f0b4b6e06a53b7d4bbad3eab28cd65915' },
|
||||
'430': { head: '117f22a385f0118eac2aa6ef8fedf4b29062e973' },
|
||||
'431': { head: '52d8932c29ccf051e2cd400493c38ff1c90f4ccb' },
|
||||
'432': { head: '18ac66eebce733b1112b419f9896cdfa2ede395a' },
|
||||
'435': { head: 'acad517e5ce23a82979a87155bb639f91098adaf' },
|
||||
'438': { head: 'b4c94415e8c7ee24cb3f8c0ba6e0536282121adf' },
|
||||
'441': { head: 'a674530614fbce03122c7d9c72712a6e7a23acb4' },
|
||||
'443': { head: '34cf94bc1650a6e909e9fa3ee88d5cc3cb46eec2' },
|
||||
'444': { head: '8049d92b3e9aef35e4f124e5ae361bdd1f5c5435' },
|
||||
'445': { head: '69c93dba3591d9404bc6b38d84aca731db84ad15' },
|
||||
'447': { head: 'a483b7a9f28c232d66a5c7596926e5c31af865e2' },
|
||||
'448': { head: '9c2c26c81c8c43bc1a834522bc085392c766e7e0' },
|
||||
'449': { head: '52f3bbe24e365b28f4bcd1e277d178a2561a1e8b' },
|
||||
'450': { head: 'fddedb324fbff0546c2cbe304fe95c8e254da6fb' },
|
||||
'451': { head: '17332ad1070bb6190bcd24f0a96cca823b4d8d26' },
|
||||
'452': { head: 'b357d95010f883bff0d1a92ba2390f4c0a50e8ec' },
|
||||
'453': { head: '3ac4190baf80ca6734a35acdfd5ac5f089acbe3e' },
|
||||
'454': { head: '3a5a625a1f498350b05eaa70066c9e77e32ee85f' },
|
||||
'455': { head: '98d4504577b586ef2398346a0db2743081cf03a8' },
|
||||
'457': { head: '72f86392dd7bf482f409dfe4dd00219ef422ad9c' },
|
||||
'458': { head: '4e01df47f2e594796ba6b36858cbe924533dd7aa' },
|
||||
'459': { head: '608f198b3ab87f83b2458e58c1f7dcc6a2beebc0' },
|
||||
'460': { head: 'f264f50f6c1ec488c1608bf69c463d57cc7ccca9' },
|
||||
'462': { head: '5d8c5b6d686b802c48ff52bfe72f188c92509f49' },
|
||||
'464': { head: 'f38741505acb528f609a8b269c911fc037a03fcc' },
|
||||
'465': { head: '318bb739dd64d19a4b4d91d8be49b22fc3403cff' },
|
||||
'468': { head: '117c7cc8a9bea5c9ef65bf00689e1917d91571ec' },
|
||||
'470': { head: '9f73278f8f7631bc53daba27ffdf84d96068c562' },
|
||||
'472': { head: '8cd138e181b63fa327b4b3caa3250fb1dce4b407' },
|
||||
'473': { head: '45a4253be8540240758a69eb8c0c103a3edde057' },
|
||||
'475': { head: 'b93b3d0cc8241e099fc508ffb1f9dace6ab8586a' },
|
||||
'476': { head: '639552074da609025ca6609350c90263ebe684e7' },
|
||||
'477': { head: 'dae10753450c75af10c300dbaf00653b15a27e87' },
|
||||
'478': { head: '9ec42e0f156e0f82068eabbab6ccbfd17549486a' },
|
||||
'481': { head: 'b11c6f57662624732501045e6cccf6b6188dacee' },
|
||||
'482': { head: '887d8d84223de495f0442baa9ae143c382747285' },
|
||||
'483': { head: '4cc123809f92db0a32f4fedbcbf4862484406da0' },
|
||||
'484': { head: '7cff50433386d8c7793884cddd1eb6e1c3c2681e' },
|
||||
'485': { head: '9ce1420b43db72da9d6a57bcc3d4ba478d614484' },
|
||||
'486': { head: '18714381a6257fd93c93344cb559fc409f6b1017' },
|
||||
'488': { head: 'ca45f8941e0b69582021d34061873c8752f76154' },
|
||||
'491': { head: 'e7bcde1188f02ac07e64f6b9a798e0b1ca1e049c' },
|
||||
'492': { head: '09f10b74034b040a6cb56640cd2c2f1027051b50' },
|
||||
'495': { head: 'a6396622cdb3af334c1ec044d5a699affa0dccc2' },
|
||||
'496': { head: 'e5ddd73878d170312580a9284edd5521a2115873' },
|
||||
'497': { head: '74909f788acd34051cf4d32e94b5bcfe1f2c292b' },
|
||||
'498': { head: '08c5864bbfcdc8238716ca8929a71554d08dabfd' },
|
||||
'499': { head: 'bc6896917a2e150adb5aa2a063f72fc85d2ab9f5' },
|
||||
'500': { head: 'ff0595d384a9b4e7656e0c44f327f7614e2a8fd6' },
|
||||
'501': { head: '81acc02e79365957d37e98fbe70887edccfebba6' },
|
||||
'503': { head: '145358ba831e7a90f275118a0556787754fe2fa6' },
|
||||
'505': { head: '1cf79ba882fb24eca13829c12f6e39584ccd1f5f' },
|
||||
'506': { head: '49f14868b5fa9bca4aa2f51ea2b70f9edae89cb6' },
|
||||
'507': { head: '726997c8d83f2a9dff3bb96685dd35ea555e7b8c' },
|
||||
'508': { head: 'a99ed5924ed00e195c0dacc036625bdb4d10f9a8' },
|
||||
'509': { head: '7d4023cf698bff82b2c0f2b4aad86286d4890b49' },
|
||||
'510': { head: 'fb9a434ada47e47e543f62e353c7375f93f82c39' },
|
||||
'523': { head: '0bdcae97d8d9b2b3afe725f9b857a9994d3b28fa' },
|
||||
'525': { head: 'ebe4099e7ea32b023edfc7a5559db5d1d5262e20' },
|
||||
'526': { head: '454f1c64dae6c213177007885e54a1ab497f4b1b' },
|
||||
'527': { head: '786c94fb869b6bbcf310e93f3068b795b177fc0b' },
|
||||
'529': { head: 'df6f615305180ef67c9daa25038af1bc91ff44b0' },
|
||||
'530': { head: '4f2e25226853830f157a2da79097c527030d42b4' },
|
||||
'531': { head: '0b57414998b5404f93209f5b06141911cc9af503' },
|
||||
'534': { head: 'bd4181e0321ec9db4dd6b304db51f5cf6566a484' },
|
||||
'537': { head: 'b515795919b7eb114032a441564512645fae489c' },
|
||||
'542': { head: '7ce304f9ee9946471d4ad11e78ea25149a05483f' },
|
||||
'543': { head: 'f6b1a4866e1c73aafe6decdc6bfc1d99653f2b64' },
|
||||
'547': { head: '9943cbae2e39a219cd5f889802d9db11aaefda5c' },
|
||||
'550': { head: '172076db9fa929c5b6dd20a733d15cf28ef092aa' },
|
||||
'551': { head: 'ff103cd4816ca50102c3bc10906695581c734f60' },
|
||||
'552': { head: '99a3da1ff1e25e76a2cbf19f2f3a3ff43b6be013' },
|
||||
'554': { head: '689068989bcda7bd099f920691dc388eae82bd9a' },
|
||||
'557': { head: '416efddbbac77ecad9be41bdafd36bdea89e25d5' },
|
||||
'563': { head: '3d72809db048911efec3d52106dd6968349ef4d1' },
|
||||
'569': { head: 'ce51c2de7c11b6368ce8956329f9ebbe4ffd1b67' },
|
||||
'593': { head: 'f00316a42943a9a75303658f8d646d35f9e8d1b9' },
|
||||
'613': { head: '155deaae3ea36460929db9c8f28f2b97a319f54c' },
|
||||
'625': { head: 'a027cf0843001dd2cb608c1c42cf643f48a56749' },
|
||||
'628': { head: '23ae1e8af491342ef3e4f899ed0bdb5dd1a1284a' },
|
||||
'631': { head: '30d4183095aa5dcdb9cbe00b1b48e45ca31424fe' },
|
||||
'633': { head: '54ba9a0faf46957c3da37366119e0dab52fc02cc' },
|
||||
'642': { head: 'c68a8ac90d822f74478cc36b6ba5a7e9ac225ee9' },
|
||||
'655': { head: '6da12e9e3387be62b5b00cba64d1fb4d2e1ac140' },
|
||||
'664': { head: 'e011000482dccb3e215d0eb895e280de6cda627e' },
|
||||
'667': { head: 'dc25ac7a87256a0470f523017ee790b29e9b6f2d' },
|
||||
'669': { head: 'd0b39e229426a336f71a0cc24f6319a47e2ce975' },
|
||||
'671': { head: 'aa0cd8e58d2effab424214d12ab2122ff39a0f4a' },
|
||||
'672': { head: '0cb3bd5f5aa0605835d7c785bd58e9d75b362fdd' },
|
||||
'673': { head: '97b0e9c8e673325545d2e55288d66a2dd99d1cc0' },
|
||||
'674': { head: '5d7a6efa13021da59a370bb011f4caf494b35da3' },
|
||||
'678': { head: '98d788b6df2e95725e2435fff8469deb3ff74e8c' },
|
||||
'679': { head: 'ea8ee4a153af424e238ed0e0772c32bfb0a881b1' },
|
||||
'682': { head: 'fd12dc4bd31ebe9dc6370ab150c39441ce4d6061' },
|
||||
'686': { head: 'd76b2b96872e3860af34b3256bc1df2189835829' },
|
||||
'703': { head: '3b0f6e396c4a1d53b1b046c416681da6229fbdce' },
|
||||
'708': { head: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a' },
|
||||
},
|
||||
};
|
||||
if (repo === 'my/xmake')
|
||||
return {
|
||||
heads: {
|
||||
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
||||
master: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
'patch-1': '77cd51991f8b9c76e54d668103a06ca6c597e64a',
|
||||
},
|
||||
tags: {},
|
||||
pull: {},
|
||||
};
|
||||
},
|
||||
}));
|
||||
import { selectVersion } from './versions';
|
||||
import { Repo } from './interfaces';
|
||||
import { resolve } from 'path';
|
||||
|
||||
describe('selectVersion', () => {
|
||||
it('should return correct version for latest', async () => {
|
||||
await expect(selectVersion('latest')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v2.3.2',
|
||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
type: 'tags',
|
||||
});
|
||||
});
|
||||
it('should throw for no matched', async () => {
|
||||
await expect(selectVersion('0.2.3')).rejects.toThrowError('No matched releases of xmake-version 0.2.3');
|
||||
await expect(selectVersion('v0.2.3')).rejects.toThrowError('No matched releases of xmake-version 0.2.3');
|
||||
await expect(selectVersion('<0.2.3 > 0.1')).rejects.toThrowError(
|
||||
'No matched releases of xmake-version <0.2.3 >=0.2.0',
|
||||
);
|
||||
});
|
||||
it('should return correct version for given', async () => {
|
||||
await expect(selectVersion('v1.0.1')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v1.0.1',
|
||||
sha: '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
||||
type: 'tags',
|
||||
});
|
||||
});
|
||||
it('should return correct version for range', async () => {
|
||||
await expect(selectVersion('>=2')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v2.3.2',
|
||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
type: 'tags',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return correct branch', async () => {
|
||||
await expect(selectVersion('branch@master')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'master',
|
||||
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
type: 'heads',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw not found branch', async () => {
|
||||
await expect(selectVersion('branch@xxx')).rejects.toThrowError(`Branch xxx not found`);
|
||||
});
|
||||
|
||||
it('should return correct pr', async () => {
|
||||
await expect(selectVersion('pr@708')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'pr#708',
|
||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
||||
type: 'pull',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw not found pr', async () => {
|
||||
await expect(selectVersion('pr@999')).rejects.toThrowError('Pull requrest #999 not found');
|
||||
});
|
||||
|
||||
it('should throw invalid pr', async () => {
|
||||
await expect(selectVersion('pr@xxx')).rejects.toThrowError(
|
||||
'Invalid pull requrest xxx, should be a positive integer',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return branch of sha', async () => {
|
||||
await expect(selectVersion('sha@efad01e547f30d66d90e486c91c3afa0dbaceed3')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'master',
|
||||
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
type: 'heads',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return tag of sha', async () => {
|
||||
await expect(selectVersion('sha@31bacc4f76101e6a865ec254c48d8bcba456378f')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v2.3.2',
|
||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
type: 'tags',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return pr merge of sha', async () => {
|
||||
await expect(selectVersion('sha@2f93475049575ed5e44699daa378239bc141aad3')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'pr#217',
|
||||
sha: '2f93475049575ed5e44699daa378239bc141aad3',
|
||||
type: 'pull',
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return pr head of sha if merge present', async () => {
|
||||
await expect(selectVersion('sha@905a8607f3f31ab9efeb68684d40df8284683f3a')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'sha#905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||
sha: '905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||
type: 'sha',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return pr head of sha', async () => {
|
||||
await expect(selectVersion('sha@af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'pr#708',
|
||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
||||
type: 'pull',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return correct normalized sha', async () => {
|
||||
await expect(selectVersion('sha@Af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'sha#af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
||||
type: 'sha',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw invalid length sha', async () => {
|
||||
await expect(selectVersion('sha@af28dba1f52990cb7b6c3c8f69f1f1bcf017c90')).rejects.toThrowError(
|
||||
'Invalid sha value af28dba1f52990cb7b6c3c8f69f1f1bcf017c90',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw invalid char sha', async () => {
|
||||
await expect(selectVersion('sha@af28dba1f52990cb7b6c3c8f69f1f1bcf017c90g')).rejects.toThrowError(
|
||||
'Invalid sha value af28dba1f52990cb7b6c3c8f69f1f1bcf017c90g',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return correct repo', async () => {
|
||||
await expect(selectVersion('my/xmake#branch@patch-1')).resolves.toEqual({
|
||||
repo: 'my/xmake',
|
||||
version: 'patch-1',
|
||||
sha: '77cd51991f8b9c76e54d668103a06ca6c597e64a',
|
||||
type: 'heads',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return local cwd', async () => {
|
||||
await expect(selectVersion('local#')).resolves.toEqual({
|
||||
path: process.cwd(),
|
||||
type: 'local',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return absolute path', async () => {
|
||||
await expect(selectVersion('local#/usr/bin')).resolves.toEqual({
|
||||
path: resolve('/usr/bin'),
|
||||
type: 'local',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return relative path', async () => {
|
||||
await expect(selectVersion('local#xmake')).resolves.toEqual({
|
||||
path: resolve('xmake'),
|
||||
type: 'local',
|
||||
});
|
||||
});
|
||||
});
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as semver from 'semver';
|
||||
import { lsRemote } from './git';
|
||||
import { RefDic, Sha, Version, Repo, GitVersion, LocalVersion } from './interfaces';
|
||||
import * as p from 'path';
|
||||
|
||||
const DEFAULT_REPO = Repo('xmake-io/xmake');
|
||||
|
||||
const VERSIONS = new Map<Repo, RefDic>();
|
||||
async function getVersions(repo: Repo): Promise<RefDic> {
|
||||
const cache = VERSIONS.get(repo);
|
||||
if (cache) return cache;
|
||||
const result = await lsRemote(repo);
|
||||
VERSIONS.set(repo, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
class GitVersionImpl implements GitVersion {
|
||||
constructor(
|
||||
readonly repo: Repo,
|
||||
readonly version: string,
|
||||
readonly sha: Sha,
|
||||
readonly type: GitVersion['type'],
|
||||
toString: string,
|
||||
) {
|
||||
this.#string = toString;
|
||||
}
|
||||
readonly #string: string;
|
||||
toString(): string {
|
||||
return this.#string;
|
||||
}
|
||||
}
|
||||
|
||||
class LocalVersionImpl implements LocalVersion {
|
||||
readonly type = 'local';
|
||||
readonly version: undefined;
|
||||
constructor(readonly path: string) {
|
||||
this.path = p.resolve(path);
|
||||
}
|
||||
}
|
||||
|
||||
async function selectBranch(repo: Repo, branch: string): Promise<Version> {
|
||||
const versions = await getVersions(repo);
|
||||
if (branch in versions.heads) {
|
||||
return new GitVersionImpl(repo, branch, versions.heads[branch], 'heads', `branch ${branch}`);
|
||||
}
|
||||
throw new Error(`Branch ${branch} not found`);
|
||||
}
|
||||
|
||||
async function selectPr(repo: Repo, pr: number): Promise<Version> {
|
||||
const versions = await getVersions(repo);
|
||||
if (pr in versions.pull) {
|
||||
const prHeads = versions.pull[pr];
|
||||
const sha = prHeads.merge ?? prHeads.head;
|
||||
if (sha) {
|
||||
return new GitVersionImpl(repo, `pr#${pr}`, sha, 'pull', `pull request #${pr}`);
|
||||
}
|
||||
}
|
||||
throw new Error(`Pull requrest #${pr} not found`);
|
||||
}
|
||||
|
||||
async function selectSemver(repo: Repo, version: string): Promise<Version> {
|
||||
// check version valid
|
||||
const v = new semver.Range(version);
|
||||
if (!v) {
|
||||
throw new Error(`Invalid semver`);
|
||||
}
|
||||
|
||||
const versions = await getVersions(repo);
|
||||
const ver = semver.maxSatisfying(Object.keys(versions.tags), v);
|
||||
if (!ver) {
|
||||
throw new Error(`No matched releases of xmake-version ${v.format()}`);
|
||||
}
|
||||
|
||||
const sha = versions.tags[ver];
|
||||
return new GitVersionImpl(repo, ver, sha, 'tags', ver);
|
||||
}
|
||||
|
||||
async function selectSha(repo: Repo, sha: string): Promise<Version> {
|
||||
const shaValue = Sha(sha);
|
||||
const versions = await getVersions(repo);
|
||||
for (const branch in versions.heads) {
|
||||
if (versions.heads[branch] === shaValue) {
|
||||
return selectBranch(repo, branch);
|
||||
}
|
||||
}
|
||||
for (const tag in versions.tags) {
|
||||
if (versions.tags[tag] === shaValue) {
|
||||
return selectSemver(repo, tag);
|
||||
}
|
||||
}
|
||||
for (const pr in versions.pull) {
|
||||
const prData = versions.pull[pr];
|
||||
if ((prData.merge ?? prData.head) === shaValue) {
|
||||
return selectPr(repo, Number.parseInt(pr));
|
||||
}
|
||||
}
|
||||
return Promise.resolve(
|
||||
new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substring(0, 8)}`),
|
||||
);
|
||||
}
|
||||
|
||||
export async function selectVersion(version?: string, _fallback: boolean = false): Promise<Version> {
|
||||
// get version string
|
||||
version = (version ?? core.getInput('xmake-version')) || 'latest';
|
||||
if (version.toLowerCase() === 'latest') version = '';
|
||||
|
||||
let repo = DEFAULT_REPO;
|
||||
let ret: Version | undefined;
|
||||
// select local
|
||||
if (version.startsWith('local#')) {
|
||||
const path = version.slice('local#'.length);
|
||||
ret = new LocalVersionImpl(path);
|
||||
}
|
||||
|
||||
{
|
||||
const match = /^([^/#]+\/[^/#]+)#(.+)$/.exec(version);
|
||||
if (match) {
|
||||
repo = Repo(match[1]);
|
||||
version = match[2];
|
||||
}
|
||||
}
|
||||
|
||||
// select branch
|
||||
if (version.startsWith('branch@')) {
|
||||
const branch = version.substring('branch@'.length);
|
||||
ret = await selectBranch(repo, branch);
|
||||
}
|
||||
// select pr
|
||||
if (version.startsWith('pr@')) {
|
||||
const pr = Number.parseInt(version.substring('pr@'.length));
|
||||
if (Number.isNaN(pr) || pr <= 0) {
|
||||
throw new Error(`Invalid pull requrest ${version.substring('pr@'.length)}, should be a positive integer`);
|
||||
}
|
||||
ret = await selectPr(repo, pr);
|
||||
}
|
||||
// select sha
|
||||
if (version.startsWith('sha@')) {
|
||||
const sha = version.substring('sha@'.length);
|
||||
ret = await selectSha(repo, sha);
|
||||
}
|
||||
// select version
|
||||
if (semver.validRange(version)) {
|
||||
ret = await selectSemver(repo, version);
|
||||
}
|
||||
if (!ret) {
|
||||
throw new Error(`Invalid input xmake-version ${core.getInput('xmake-version')}`);
|
||||
}
|
||||
if (ret.type === 'local') {
|
||||
core.info(`Use local xmake at '${ret.path}'`);
|
||||
} else if (!_fallback) {
|
||||
core.info(
|
||||
`Selected xmake ${String(ret)} (commit: ${ret.sha.substring(0, 8)})` +
|
||||
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''),
|
||||
);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
import * as core from '@actions/core';
|
||||
import { exec } from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import * as git from './git';
|
||||
import { Version, GitVersion } from './interfaces';
|
||||
import { selectVersion } from './versions';
|
||||
import { getPlatformIdentifier } from './system';
|
||||
|
||||
async function getInstallerUrl(version: GitVersion, _fallback: boolean = false): Promise<string> {
|
||||
const latest = (await selectVersion('latest', _fallback)) as GitVersion;
|
||||
const latestVers = latest.version;
|
||||
let vers = version.version;
|
||||
let finalUrl: string;
|
||||
switch (version.type) {
|
||||
case 'heads': {
|
||||
const arch = os.arch() === 'arm64' ? 'arm64' : os.arch() === 'x64' ? 'win64' : 'win32';
|
||||
if (vers !== 'dev' && vers !== 'master') {
|
||||
vers = latestVers;
|
||||
}
|
||||
finalUrl = `https://github.com/xmake-io/xmake/releases/download/${latestVers}/xmake-${vers}.${arch}.exe`;
|
||||
break;
|
||||
}
|
||||
case 'pull': {
|
||||
throw new Error('PR builds for windows is not supported');
|
||||
}
|
||||
case 'sha': {
|
||||
throw new Error('Sha builds for windows is not supported');
|
||||
}
|
||||
case 'tags': {
|
||||
const arch = os.arch() === 'arm64' ? 'arm64' : os.arch() === 'x64' ? 'win64' : 'win32';
|
||||
finalUrl = semver.gt(vers, '2.2.6')
|
||||
? `https://github.com/xmake-io/xmake/releases/download/${vers}/xmake-${vers}.${arch}.exe`
|
||||
: `https://github.com/xmake-io/xmake/releases/download/${vers}/xmake-${vers}.exe`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// check that we have tested all types
|
||||
const _: never = 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> {
|
||||
await exec(xmakeBin, ['-y'], { cwd: sourceDir });
|
||||
await exec(xmakeBin, ['install', '-o', binDir, 'cli'], { cwd: sourceDir });
|
||||
}
|
||||
|
||||
export async function winInstall(version: Version): Promise<void> {
|
||||
if (version.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;
|
||||
const sha = version.sha;
|
||||
const platformIdentifier = await getPlatformIdentifier();
|
||||
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${platformIdentifier}`;
|
||||
|
||||
let toolDir = '';
|
||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
const fullCachePath = path.resolve(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) {
|
||||
const installer = await core.group(`download xmake ${String(version)}`, async () => {
|
||||
const url = await getInstallerUrl(version);
|
||||
core.info(`downloading from ${url}`);
|
||||
const file = await toolCache.downloadTool(url);
|
||||
const exe = path.format({
|
||||
...path.parse(file),
|
||||
ext: '.exe',
|
||||
base: undefined,
|
||||
});
|
||||
await io.mv(file, exe);
|
||||
core.info(`downloaded to ${exe}`);
|
||||
return exe;
|
||||
});
|
||||
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
core.info(`installing to ${binDir}`);
|
||||
await exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
||||
core.info(`installed to ${binDir}`);
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
await io.rmRF(binDir);
|
||||
await io.rmRF(installer);
|
||||
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.resolve(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||
await io.cp(toolDir, cacheDir, {
|
||||
recursive: true,
|
||||
});
|
||||
await cache.saveCache([actionsCacheFolder], cacheKey);
|
||||
toolDir = cacheDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
core.addPath(toolDir);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# Xmake cache
|
||||
.xmake/
|
||||
build/
|
||||
|
||||
# MacOS Cache
|
||||
.DS_Store
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::cout << "hello world!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
add_rules("mode.debug", "mode.release")
|
||||
|
||||
add_requires("libpng", "libogg", {system = false})
|
||||
|
||||
target("sample")
|
||||
set_kind("binary")
|
||||
add_files("src/*.cpp")
|
||||
add_packages("libpng", "libogg")
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"include": ["src/**/*"],
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"module": "commonjs",
|
||||
"target": "es2018",
|
||||
"outDir": "dist",
|
||||
"types": ["node", "jest"]
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"1.0.1": "723ec3e970e17f48a601fe2a919b9802b5e516fa",
|
||||
"1.0.2": "84fa20ca3ded99b9667609c5cb2e56b2308c8e4b",
|
||||
"1.0.3": "e56812a09d3677957c41bccc8988599208e3b49a",
|
||||
"1.0.4": "825dda9d93448ba783e18f7947eef0b4eb07942e",
|
||||
"2.0.1": "432fd6a40018f4c29e08f1d4cadf1ccc387a0cff",
|
||||
"2.0.2": "d24fcddbc2f1093f3943a917d99c5a8989ef2644",
|
||||
"2.0.3": "b5f21a05b1cdaf46314238b4cc665976294df1da",
|
||||
"2.0.4": "2b15a1b5b149e5156e22358f3d29b4de63473376",
|
||||
"2.0.5": "b168ce05d763957ed05844141d77d155bf842e7a",
|
||||
"2.1.1": "5ba22ca230c3f3f9477491df6d39f11d53132fb1",
|
||||
"2.1.2": "bf69a2413117cf21c53bde1edbda713e77d4fd9b",
|
||||
"2.1.3": "248b2cc8a96d41445a2e46d259d14fea8e4203ec",
|
||||
"2.1.4": "1d94a23a7db35631f4b33b8b0b3968d0e62ffe2a",
|
||||
"2.1.5": "72f68f941f9b6d07f71811fe403a2dc178270af0",
|
||||
"2.1.6": "7ea60d24da152469258a4cb35b3ce591ea2fd961",
|
||||
"2.1.7": "a04725662933fbbe3ad4a319d03267fc32907242",
|
||||
"2.1.8": "6c3f42dad5840210ee7294ca295f6c7b18c32291",
|
||||
"2.1.9": "0f1e8530e89a9432678ed6fe4fef25d0485d1293",
|
||||
"2.2.1": "f15ff1ca73b02ff5f522c9fe59004331b1b410fb",
|
||||
"2.2.2": "18a42e0e8980e3edc39198b18c5c4b9a464ea381",
|
||||
"2.2.3": "c4d0e69abf2b9caa88b997ca1f2935b6e0b00c9f",
|
||||
"2.2.5": "d71a01615883fffa53fbd28e578db14353628a52",
|
||||
"2.2.6": "eb60a76b7454975d151f2d8b5d9e19b26d561c2d",
|
||||
"2.2.7": "72bd93de8dd64cc5de8986860819a5873ce08fe5",
|
||||
"2.2.8": "6a2e390a79c4f0444a03b566d4bf24849a6ee3a3"
|
||||
}
|
||||
Reference in New Issue
Block a user