mirror of
https://github.com/ilammy/msvc-dev-cmd.git
synced 2026-09-07 06:07:19 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b44b596ee5 | |||
| 6bcb337df2 | |||
| 074eec8db2 | |||
| b5113e7e9d | |||
| 1eed9c1215 | |||
| 233eac407f |
+11
-58
@@ -13,72 +13,25 @@ jobs:
|
||||
test:
|
||||
name: default
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v4
|
||||
- name: Download Internet
|
||||
run: npm install
|
||||
- name: Run eslint
|
||||
run: npm run lint
|
||||
- name: Enable Developer Command Prompt (amd64)
|
||||
uses: ./
|
||||
with:
|
||||
arch: amd64
|
||||
- name: Compile and run some C code (amd64)
|
||||
shell: cmd
|
||||
run: |
|
||||
cl.exe hello.c
|
||||
hello.exe
|
||||
- name: Enable Developer Command Prompt (amd64_x86)
|
||||
uses: ./
|
||||
with:
|
||||
arch: amd64_x86
|
||||
- name: Compile and run some C code (x86)
|
||||
shell: cmd
|
||||
run: |
|
||||
cl.exe hello.c
|
||||
hello.exe
|
||||
- name: Enable Developer Command Prompt (amd64_arm)
|
||||
uses: ./
|
||||
with:
|
||||
arch: amd64_arm
|
||||
- name: Compile some C code (arm)
|
||||
shell: cmd
|
||||
run: |
|
||||
cl.exe hello.c
|
||||
dumpbin /headers hello.exe
|
||||
- name: Enable Developer Command Prompt (amd64_arm64)
|
||||
uses: ./
|
||||
with:
|
||||
arch: amd64_arm64
|
||||
- name: Compile some C code (arm64)
|
||||
shell: cmd
|
||||
run: |
|
||||
cl.exe hello.c
|
||||
dumpbin /headers hello.exe
|
||||
audit:
|
||||
name: npm audit
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v4
|
||||
- run: npm install
|
||||
- run: npm audit --audit-level=moderate --production
|
||||
- run: npm audit --audit-level=critical
|
||||
alias-arch:
|
||||
name: arch aliases
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v1
|
||||
- name: Download Internet
|
||||
run: npm install
|
||||
- name: Enable Developer Command Prompt
|
||||
uses: ./
|
||||
with:
|
||||
arch: Win32
|
||||
- name: Compile and run some C code
|
||||
shell: cmd
|
||||
run: |
|
||||
cl.exe hello.c
|
||||
hello.exe
|
||||
audit:
|
||||
name: npm audit
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v1
|
||||
- run: npm install
|
||||
- run: npm audit --audit-level=moderate
|
||||
|
||||
@@ -11,11 +11,13 @@ jobs:
|
||||
test:
|
||||
name: release
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Setup Developer Command Prompt
|
||||
uses: ilammy/msvc-dev-cmd@release/v1
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v1
|
||||
- name: Compile and run some C code
|
||||
shell: cmd
|
||||
run: |
|
||||
@@ -23,9 +25,8 @@ jobs:
|
||||
hello.exe
|
||||
audit:
|
||||
name: npm audit
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v4
|
||||
- run: npm audit --audit-level=moderate --production
|
||||
- run: npm audit --audit-level=critical
|
||||
uses: actions/checkout@v1
|
||||
- run: npm audit --audit-level=moderate
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
node_modules
|
||||
|
||||
@@ -8,57 +8,12 @@ This sets up the environment for compiling C/C++ code from command line.
|
||||
|
||||
Supports Windows. Does nothing on Linux and macOS.
|
||||
|
||||
## Example usage
|
||||
|
||||
Basic usage for default compilation settings is like this:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
test:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Build something requiring CL.EXE
|
||||
run: |
|
||||
cmake -G "NMake Makefiles" .
|
||||
nmake
|
||||
# ...
|
||||
```
|
||||
|
||||
If you want something non-default,
|
||||
like using a specific version of Visual Studio,
|
||||
or cross-compling for a different target,
|
||||
you will need to configure those settings via inputs:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
test:
|
||||
# Run a job for each of the specified target architectures:
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- amd64
|
||||
- amd64_x86
|
||||
- amd64_arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: Build something requiring CL.EXE
|
||||
run: |
|
||||
cmake -G "NMake Makefiles" .
|
||||
nmake
|
||||
# ...
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
- `arch` – target architecture
|
||||
- native compilation:
|
||||
- `x64` (default) or its synonyms: `amd64`, `win64`, `x86_64`, `x86-64`
|
||||
- `x86` or its synonyms: `win32`
|
||||
- cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`, `amd64_x86`, `amd64_arm`, `amd64_arm64`
|
||||
- native compilation: `x86`, `x64` (default), `amd64` (synonym for x64)
|
||||
- cross-compilation: `x86_amd64`, `x86_arm`, `x86_arm64`,
|
||||
`amd64_x86`, `amd64_arm`, `amd64_arm64`
|
||||
- `sdk` – Windows SDK to use
|
||||
- do not specify to use the default SDK
|
||||
- or specify full Windows 10 SDK number (e.g, `10.0.10240.0`)
|
||||
@@ -70,66 +25,21 @@ jobs:
|
||||
- `14.XX.YYYYY` for a specific full version number (e.g, `14.11.25503`)
|
||||
- `uwp` – set `true` to build for Universal Windows Platform (i.e., for Windows Store)
|
||||
- `spectre` – set `true` to use Visual Studio libraries with [Spectre](https://meltdownattack.com) mitigations
|
||||
- `vsversion` – the Visual Studio version to use. This can be the version number (e.g. 16.0 for 2019) or the year (e.g. "2019"); omit this input to select the latest version of Visual Studio. On [GitHub-hosted runners](https://docs.github.com/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners), this input is not required because there is only one Visual Studio in the environment.
|
||||
|
||||
## Caveats
|
||||
|
||||
### Name conflicts with `shell: bash`
|
||||
|
||||
Using `shell: bash` in Actions may shadow some of the paths added by MSVC.
|
||||
In particular, `link.exe` (Microsoft C linker) is prone to be shadowed by `/usr/bin/link` (GNU filesystem link tool).
|
||||
|
||||
Unfortunately, this happens because GitHub Actions unconditionally *prepend* GNU paths when `shell: bash` is used,
|
||||
on top of any paths set by `msvc-dev-cmd`, every time at the start of each new step.
|
||||
Hence, there aren't many non-destructive options here.
|
||||
|
||||
If you experience compilation errors where `link` complains about unreasonable command-line arguments,
|
||||
“extra operand *something-something*” – that's probably it.
|
||||
Recommended workaround is to remove `/usr/bin/link` if that interferes with your builds.
|
||||
If this is not acceptable, please file an issue, then we'll figure out something better.
|
||||
|
||||
### Reconfiguration
|
||||
|
||||
You can invoke `ilammy/msvc-dev-cmd` multiple times during your jobs with different inputs
|
||||
to reconfigure the environment for building with different settings
|
||||
(e.g., to target multiple architectures).
|
||||
## Example usage
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
release:
|
||||
steps:
|
||||
# ...
|
||||
- name: Configure build for amd64
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: amd64
|
||||
|
||||
- run: build # (for amd64)
|
||||
|
||||
- name: Configure build for x86
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: amd64_x86
|
||||
|
||||
- run: build # (for x86)
|
||||
|
||||
- name: Configure build for ARM64
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: amd64_arm64
|
||||
|
||||
- run: build # (for ARM64)
|
||||
|
||||
# ...
|
||||
test:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Build something requiring CL.EXE
|
||||
run: |
|
||||
cmake -G "NMake Makefiles" .
|
||||
nmake
|
||||
# ...
|
||||
```
|
||||
|
||||
This mostly works but it's not really recommended
|
||||
since Developer Command Prompt was not meant for recursive reconfiguration.
|
||||
That said, if it does not work for you, please file an issue.
|
||||
|
||||
Consider using [`strategy.matrix`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)
|
||||
to execute different build configuration in parallel, independent environments.
|
||||
|
||||
## License
|
||||
|
||||
MIT, see [LICENSE](LICENSE).
|
||||
|
||||
+1
-3
@@ -12,10 +12,8 @@ inputs:
|
||||
description: VC++ compiler toolset version
|
||||
uwp:
|
||||
description: Build for Universal Windows Platform
|
||||
vsversion:
|
||||
description: The Visual Studio version to use. This can be the version number (e.g. 16.0 for 2019) or the year (e.g. "2019").
|
||||
runs:
|
||||
using: node20
|
||||
using: node12
|
||||
main: index.js
|
||||
branding:
|
||||
icon: terminal
|
||||
|
||||
@@ -1,20 +1,111 @@
|
||||
const { setupMSVCDevCmd } = require('./lib')
|
||||
const core = require('@actions/core')
|
||||
const child_process = require('child_process')
|
||||
const exec = require('util').promisify(child_process.exec)
|
||||
const fs = require('fs')
|
||||
const process = require('process')
|
||||
|
||||
function main() {
|
||||
var arch = core.getInput('arch')
|
||||
const EDITIONS = ['Enterprise', 'Professional', 'Community']
|
||||
const VERSIONS = ['2019', '2017']
|
||||
|
||||
const InterestingVariables = [
|
||||
'INCLUDE',
|
||||
'LIB',
|
||||
'LIBPATH',
|
||||
'Path',
|
||||
'Platform',
|
||||
'VisualStudioVersion',
|
||||
/^VCTools/,
|
||||
/^VSCMD_/,
|
||||
/^WindowsSDK/i,
|
||||
]
|
||||
|
||||
function findWithVswhere(pattern) {
|
||||
let path = null;
|
||||
try {
|
||||
path = child_process.execSync(`vswhere -products * -latest -prerelease -find ${pattern}`).toString().trim()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
function findVcvarsall() {
|
||||
// use vswhere
|
||||
let path = findWithVswhere('**/Auxiliary/Build/vcvarsall.bat')
|
||||
if (path && fs.existsSync(path)) {
|
||||
return path
|
||||
}
|
||||
|
||||
const programFiles = process.env['ProgramFiles(x86)']
|
||||
// Given the order of each list it should check
|
||||
// for the more recent versions first and the
|
||||
// highest grade edition first.
|
||||
for (const ver of VERSIONS) {
|
||||
for (const ed of EDITIONS) {
|
||||
path = `${programFiles}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
|
||||
if (fs.existsSync(path)) {
|
||||
return path
|
||||
}
|
||||
}
|
||||
}
|
||||
// Special case for Visual Studio 2015 (and maybe earlier), try it out too.
|
||||
// us vswhere
|
||||
path = findWithVswhere('**/vcbuildtools.bat')
|
||||
if (path && fs.existsSync(path)) {
|
||||
return path
|
||||
}
|
||||
path = `${programFiles}\\Microsoft Visual C++ Build Tools\\vcbuildtools.bat`
|
||||
if (fs.existsSync(path)) {
|
||||
return path
|
||||
}
|
||||
throw new Error('Microsoft Visual Studio not found')
|
||||
}
|
||||
|
||||
async function main() {
|
||||
if (process.platform != 'win32') {
|
||||
core.info('This is not a Windows virtual environment, bye!')
|
||||
return
|
||||
}
|
||||
|
||||
const arch = core.getInput('arch')
|
||||
const sdk = core.getInput('sdk')
|
||||
const toolset = core.getInput('toolset')
|
||||
const uwp = core.getInput('uwp')
|
||||
const spectre = core.getInput('spectre')
|
||||
const vsversion = core.getInput('vsversion')
|
||||
|
||||
setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre, vsversion)
|
||||
// Due to the way Microsoft Visual C++ is configured, we have to resort to the following hack:
|
||||
// Call the configuration batch file and then output *all* the environment variables.
|
||||
|
||||
var args = [arch]
|
||||
if (uwp == 'true') {
|
||||
args.push('uwp')
|
||||
}
|
||||
if (sdk) {
|
||||
args.push(sdk)
|
||||
}
|
||||
if (toolset) {
|
||||
args.push(`-vcvars_ver=${toolset}`)
|
||||
}
|
||||
if (spectre == 'true') {
|
||||
args.push('-vcvars_spectre_libs=spectre')
|
||||
}
|
||||
|
||||
const command = `"${findVcvarsall()}" ${args.join(' ')} && set`
|
||||
core.debug(`Running: ${command}`)
|
||||
const { stdout } = await exec(command, {shell: "cmd"})
|
||||
const environment = stdout.split('\r\n')
|
||||
|
||||
for (let string of environment) {
|
||||
const [name, value] = string.split('=')
|
||||
for (let pattern of InterestingVariables) {
|
||||
if (name.match(pattern)) {
|
||||
core.exportVariable(name, value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.info(`Configured Developer Command Prompt`)
|
||||
}
|
||||
|
||||
try {
|
||||
main()
|
||||
}
|
||||
catch (e) {
|
||||
core.setFailed('Could not setup Developer Command Prompt: ' + e.message)
|
||||
}
|
||||
main().catch((e) => core.setFailed('Could not setup Developer Command Prompt: ' + e.message))
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
const core = require('@actions/core')
|
||||
const child_process = require('child_process')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const process = require('process')
|
||||
|
||||
const PROGRAM_FILES_X86 = process.env['ProgramFiles(x86)']
|
||||
const PROGRAM_FILES = [process.env['ProgramFiles(x86)'], process.env['ProgramFiles']]
|
||||
|
||||
|
||||
const EDITIONS = ['Enterprise', 'Professional', 'Community', 'BuildTools']
|
||||
const YEARS = ['2022', '2019', '2017']
|
||||
|
||||
const VsYearVersion = {
|
||||
'2022': '17.0',
|
||||
'2019': '16.0',
|
||||
'2017': '15.0',
|
||||
'2015': '14.0',
|
||||
'2013': '12.0',
|
||||
}
|
||||
|
||||
function vsversion_to_versionnumber(vsversion) {
|
||||
if (Object.values(VsYearVersion).includes(vsversion)) {
|
||||
return vsversion
|
||||
} else {
|
||||
if (vsversion in VsYearVersion) {
|
||||
return VsYearVersion[vsversion]
|
||||
}
|
||||
}
|
||||
return vsversion
|
||||
}
|
||||
exports.vsversion_to_versionnumber = vsversion_to_versionnumber
|
||||
|
||||
function vsversion_to_year(vsversion) {
|
||||
if (Object.keys(VsYearVersion).includes(vsversion)) {
|
||||
return vsversion
|
||||
} else {
|
||||
for (const [year, ver] of Object.entries(VsYearVersion)) {
|
||||
if (ver === vsversion) {
|
||||
return year
|
||||
}
|
||||
}
|
||||
}
|
||||
return vsversion
|
||||
}
|
||||
exports.vsversion_to_year = vsversion_to_year
|
||||
|
||||
const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
|
||||
|
||||
function findWithVswhere(pattern, version_pattern) {
|
||||
try {
|
||||
let installationPath = child_process.execSync(`vswhere -products * ${version_pattern} -prerelease -property installationPath`).toString().trim()
|
||||
return installationPath + '\\' + pattern
|
||||
} catch (e) {
|
||||
core.warning(`vswhere failed: ${e}`)
|
||||
}
|
||||
return null
|
||||
}
|
||||
exports.findWithVswhere = findWithVswhere
|
||||
|
||||
function findVcvarsall(vsversion) {
|
||||
const vsversion_number = vsversion_to_versionnumber(vsversion)
|
||||
let version_pattern
|
||||
if (vsversion_number) {
|
||||
const upper_bound = vsversion_number.split('.')[0] + '.9'
|
||||
version_pattern = `-version "${vsversion_number},${upper_bound}"`
|
||||
} else {
|
||||
version_pattern = "-latest"
|
||||
}
|
||||
|
||||
// If vswhere is available, ask it about the location of the latest Visual Studio.
|
||||
let path = findWithVswhere('VC\\Auxiliary\\Build\\vcvarsall.bat', version_pattern)
|
||||
if (path && fs.existsSync(path)) {
|
||||
core.info(`Found with vswhere: ${path}`)
|
||||
return path
|
||||
}
|
||||
core.info("Not found with vswhere")
|
||||
|
||||
// If that does not work, try the standard installation locations,
|
||||
// starting with the latest and moving to the oldest.
|
||||
const years = vsversion ? [vsversion_to_year(vsversion)] : YEARS
|
||||
for (const prog_files of PROGRAM_FILES) {
|
||||
for (const ver of years) {
|
||||
for (const ed of EDITIONS) {
|
||||
path = `${prog_files}\\Microsoft Visual Studio\\${ver}\\${ed}\\VC\\Auxiliary\\Build\\vcvarsall.bat`
|
||||
core.info(`Trying standard location: ${path}`)
|
||||
if (fs.existsSync(path)) {
|
||||
core.info(`Found standard location: ${path}`)
|
||||
return path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
core.info("Not found in standard locations")
|
||||
|
||||
// Special case for Visual Studio 2015 (and maybe earlier), try it out too.
|
||||
path = `${PROGRAM_FILES_X86}\\Microsoft Visual C++ Build Tools\\vcbuildtools.bat`
|
||||
if (fs.existsSync(path)) {
|
||||
core.info(`Found VS 2015: ${path}`)
|
||||
return path
|
||||
}
|
||||
core.info(`Not found in VS 2015 location: ${path}`)
|
||||
|
||||
throw new Error('Microsoft Visual Studio not found')
|
||||
}
|
||||
exports.findVcvarsall = findVcvarsall
|
||||
|
||||
function isPathVariable(name) {
|
||||
const pathLikeVariables = ['PATH', 'INCLUDE', 'LIB', 'LIBPATH']
|
||||
return pathLikeVariables.indexOf(name.toUpperCase()) != -1
|
||||
}
|
||||
|
||||
function filterPathValue(path) {
|
||||
let paths = path.split(';')
|
||||
// Remove duplicates by keeping the first occurance and preserving order.
|
||||
// This keeps path shadowing working as intended.
|
||||
function unique(value, index, self) {
|
||||
return self.indexOf(value) === index
|
||||
}
|
||||
return paths.filter(unique).join(';')
|
||||
}
|
||||
|
||||
/** See https://github.com/ilammy/msvc-dev-cmd#inputs */
|
||||
function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre, vsversion) {
|
||||
if (process.platform != 'win32') {
|
||||
core.info('This is not a Windows virtual environment, bye!')
|
||||
return
|
||||
}
|
||||
|
||||
// Add standard location of "vswhere" to PATH, in case it's not there.
|
||||
process.env.PATH += path.delimiter + VSWHERE_PATH
|
||||
|
||||
// There are all sorts of way the architectures are called. In addition to
|
||||
// values supported by Microsoft Visual C++, recognize some common aliases.
|
||||
let arch_aliases = {
|
||||
"win32": "x86",
|
||||
"win64": "x64",
|
||||
"x86_64": "x64",
|
||||
"x86-64": "x64",
|
||||
}
|
||||
// Ignore case when matching as that's what humans expect.
|
||||
if (arch.toLowerCase() in arch_aliases) {
|
||||
arch = arch_aliases[arch.toLowerCase()]
|
||||
}
|
||||
|
||||
// Due to the way Microsoft Visual C++ is configured, we have to resort to the following hack:
|
||||
// Call the configuration batch file and then output *all* the environment variables.
|
||||
|
||||
var args = [arch]
|
||||
if (uwp == 'true') {
|
||||
args.push('uwp')
|
||||
}
|
||||
if (sdk) {
|
||||
args.push(sdk)
|
||||
}
|
||||
if (toolset) {
|
||||
args.push(`-vcvars_ver=${toolset}`)
|
||||
}
|
||||
if (spectre == 'true') {
|
||||
args.push('-vcvars_spectre_libs=spectre')
|
||||
}
|
||||
|
||||
const vcvars = `"${findVcvarsall(vsversion)}" ${args.join(' ')}`
|
||||
core.debug(`vcvars command-line: ${vcvars}`)
|
||||
|
||||
const cmd_output_string = child_process.execSync(`set && cls && ${vcvars} && cls && set`, {shell: "cmd"}).toString()
|
||||
const cmd_output_parts = cmd_output_string.split('\f')
|
||||
|
||||
const old_environment = cmd_output_parts[0].split('\r\n')
|
||||
const vcvars_output = cmd_output_parts[1].split('\r\n')
|
||||
const new_environment = cmd_output_parts[2].split('\r\n')
|
||||
|
||||
// If vsvars.bat is given an incorrect command line, it will print out
|
||||
// an error and *still* exit successfully. Parse out errors from output
|
||||
// which don't look like environment variables, and fail if appropriate.
|
||||
const error_messages = vcvars_output.filter((line) => {
|
||||
if (line.match(/^\[ERROR.*\]/)) {
|
||||
// Don't print this particular line which will be confusing in output.
|
||||
if (!line.match(/Error in script usage. The correct usage is:$/)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
if (error_messages.length > 0) {
|
||||
throw new Error('invalid parameters' + '\r\n' + error_messages.join('\r\n'))
|
||||
}
|
||||
|
||||
// Convert old environment lines into a dictionary for easier lookup.
|
||||
let old_env_vars = {}
|
||||
for (let string of old_environment) {
|
||||
const [name, value] = string.split('=')
|
||||
old_env_vars[name] = value
|
||||
}
|
||||
|
||||
// Now look at the new environment and export everything that changed.
|
||||
// These are the variables set by vsvars.bat. Also export everything
|
||||
// that was not there during the first sweep: those are new variables.
|
||||
core.startGroup('Environment variables')
|
||||
for (let string of new_environment) {
|
||||
// vsvars.bat likes to print some fluff at the beginning.
|
||||
// Skip lines that don't look like environment variables.
|
||||
if (!string.includes('=')) {
|
||||
continue;
|
||||
}
|
||||
let [name, new_value] = string.split('=')
|
||||
let old_value = old_env_vars[name]
|
||||
// For new variables "old_value === undefined".
|
||||
if (new_value !== old_value) {
|
||||
core.info(`Setting ${name}`)
|
||||
// Special case for a bunch of PATH-like variables: vcvarsall.bat
|
||||
// just prepends its stuff without checking if its already there.
|
||||
// This makes repeated invocations of this action fail after some
|
||||
// point, when the environment variable overflows. Avoid that.
|
||||
if (isPathVariable(name)) {
|
||||
new_value = filterPathValue(new_value)
|
||||
}
|
||||
core.exportVariable(name, new_value)
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
|
||||
core.info(`Configured Developer Command Prompt`)
|
||||
}
|
||||
exports.setupMSVCDevCmd = setupMSVCDevCmd
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
# `@actions/core`
|
||||
|
||||
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
||||
|
||||
## Usage
|
||||
|
||||
### Import the package
|
||||
|
||||
```js
|
||||
// javascript
|
||||
const core = require('@actions/core');
|
||||
|
||||
// typescript
|
||||
import * as core from '@actions/core';
|
||||
```
|
||||
|
||||
#### Inputs/Outputs
|
||||
|
||||
Action inputs can be read with `getInput`. Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
|
||||
|
||||
```js
|
||||
const myInput = core.getInput('inputName', { required: true });
|
||||
|
||||
core.setOutput('outputKey', 'outputVal');
|
||||
```
|
||||
|
||||
#### Exporting variables
|
||||
|
||||
Since each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks.
|
||||
|
||||
```js
|
||||
core.exportVariable('envVar', 'Val');
|
||||
```
|
||||
|
||||
#### Setting a secret
|
||||
|
||||
Setting a secret registers the secret with the runner to ensure it is masked in logs.
|
||||
|
||||
```js
|
||||
core.setSecret('myPassword');
|
||||
```
|
||||
|
||||
#### PATH Manipulation
|
||||
|
||||
To make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `addPath`. The runner will prepend the path given to the jobs PATH.
|
||||
|
||||
```js
|
||||
core.addPath('/path/to/mytool');
|
||||
```
|
||||
|
||||
#### Exit codes
|
||||
|
||||
You should use this library to set the failing exit code for your action. If status is not set and the script runs to completion, that will lead to a success.
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
try {
|
||||
// Do stuff
|
||||
}
|
||||
catch (err) {
|
||||
// setFailed logs the message and sets a failing exit code
|
||||
core.setFailed(`Action failed with error ${err}`);
|
||||
}
|
||||
|
||||
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
|
||||
|
||||
```
|
||||
|
||||
#### Logging
|
||||
|
||||
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
const myInput = core.getInput('input');
|
||||
try {
|
||||
core.debug('Inside try block');
|
||||
|
||||
if (!myInput) {
|
||||
core.warning('myInput was not set');
|
||||
}
|
||||
|
||||
if (core.isDebug()) {
|
||||
// curl -v https://github.com
|
||||
} else {
|
||||
// curl https://github.com
|
||||
}
|
||||
|
||||
// Do stuff
|
||||
}
|
||||
catch (err) {
|
||||
core.error(`Error ${err}, action may still succeed though`);
|
||||
}
|
||||
```
|
||||
|
||||
This library can also wrap chunks of output in foldable groups.
|
||||
|
||||
```js
|
||||
const core = require('@actions/core')
|
||||
|
||||
// Manually wrap output
|
||||
core.startGroup('Do some function')
|
||||
doSomeFunction()
|
||||
core.endGroup()
|
||||
|
||||
// Wrap an asynchronous function call
|
||||
const result = await core.group('Do something async', async () => {
|
||||
const response = await doSomeHTTPRequest()
|
||||
return response
|
||||
})
|
||||
```
|
||||
|
||||
#### Action state
|
||||
|
||||
You can use this library to save state and get state for sharing information between a given wrapper action:
|
||||
|
||||
**action.yml**
|
||||
```yaml
|
||||
name: 'Wrapper action sample'
|
||||
inputs:
|
||||
name:
|
||||
default: 'GitHub'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'main.js'
|
||||
post: 'cleanup.js'
|
||||
```
|
||||
|
||||
In action's `main.js`:
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
core.saveState("pidToKill", 12345);
|
||||
```
|
||||
|
||||
In action's `cleanup.js`:
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
var pid = core.getState("pidToKill");
|
||||
|
||||
process.kill(pid);
|
||||
```
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
interface CommandProperties {
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
* Command Format:
|
||||
* ::name key=value,key=value::message
|
||||
*
|
||||
* Examples:
|
||||
* ::warning::This is the message
|
||||
* ::set-env name=MY_VAR::some value
|
||||
*/
|
||||
export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
|
||||
export declare function issue(name: string, message?: string): void;
|
||||
/**
|
||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||
* @param input input to sanitize into a string
|
||||
*/
|
||||
export declare function toCommandValue(input: any): string;
|
||||
export {};
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = __importStar(require("os"));
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
* Command Format:
|
||||
* ::name key=value,key=value::message
|
||||
*
|
||||
* Examples:
|
||||
* ::warning::This is the message
|
||||
* ::set-env name=MY_VAR::some value
|
||||
*/
|
||||
function issueCommand(command, properties, message) {
|
||||
const cmd = new Command(command, properties, message);
|
||||
process.stdout.write(cmd.toString() + os.EOL);
|
||||
}
|
||||
exports.issueCommand = issueCommand;
|
||||
function issue(name, message = '') {
|
||||
issueCommand(name, {}, message);
|
||||
}
|
||||
exports.issue = issue;
|
||||
const CMD_STRING = '::';
|
||||
class Command {
|
||||
constructor(command, properties, message) {
|
||||
if (!command) {
|
||||
command = 'missing.command';
|
||||
}
|
||||
this.command = command;
|
||||
this.properties = properties;
|
||||
this.message = message;
|
||||
}
|
||||
toString() {
|
||||
let cmdStr = CMD_STRING + this.command;
|
||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
||||
cmdStr += ' ';
|
||||
let first = true;
|
||||
for (const key in this.properties) {
|
||||
if (this.properties.hasOwnProperty(key)) {
|
||||
const val = this.properties[key];
|
||||
if (val) {
|
||||
if (first) {
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
cmdStr += ',';
|
||||
}
|
||||
cmdStr += `${key}=${escapeProperty(val)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
|
||||
return cmdStr;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||
* @param input input to sanitize into a string
|
||||
*/
|
||||
function toCommandValue(input) {
|
||||
if (input === null || input === undefined) {
|
||||
return '';
|
||||
}
|
||||
else if (typeof input === 'string' || input instanceof String) {
|
||||
return input;
|
||||
}
|
||||
return JSON.stringify(input);
|
||||
}
|
||||
exports.toCommandValue = toCommandValue;
|
||||
function escapeData(s) {
|
||||
return toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A');
|
||||
}
|
||||
function escapeProperty(s) {
|
||||
return toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A')
|
||||
.replace(/:/g, '%3A')
|
||||
.replace(/,/g, '%2C');
|
||||
}
|
||||
//# sourceMappingURL=command.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAwB;AAWxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAY;IAEZ,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,IAAI,K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ACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* Interface for getInput options
|
||||
*/
|
||||
export interface InputOptions {
|
||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||
required?: boolean;
|
||||
}
|
||||
/**
|
||||
* The code to exit an action
|
||||
*/
|
||||
export declare enum ExitCode {
|
||||
/**
|
||||
* A code indicating that the action was successful
|
||||
*/
|
||||
Success = 0,
|
||||
/**
|
||||
* A code indicating that the action was a failure
|
||||
*/
|
||||
Failure = 1
|
||||
}
|
||||
/**
|
||||
* Sets env variable for this action and future actions in the job
|
||||
* @param name the name of the variable to set
|
||||
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
export declare function exportVariable(name: string, val: any): void;
|
||||
/**
|
||||
* Registers a secret which will get masked from logs
|
||||
* @param secret value of the secret
|
||||
*/
|
||||
export declare function setSecret(secret: string): void;
|
||||
/**
|
||||
* Prepends inputPath to the PATH (for this action and future actions)
|
||||
* @param inputPath
|
||||
*/
|
||||
export declare function addPath(inputPath: string): void;
|
||||
/**
|
||||
* Gets the value of an input. The value is also trimmed.
|
||||
*
|
||||
* @param name name of the input to get
|
||||
* @param options optional. See InputOptions.
|
||||
* @returns string
|
||||
*/
|
||||
export declare function getInput(name: string, options?: InputOptions): string;
|
||||
/**
|
||||
* Sets the value of an output.
|
||||
*
|
||||
* @param name name of the output to set
|
||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
export declare function setOutput(name: string, value: any): void;
|
||||
/**
|
||||
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
||||
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
||||
*
|
||||
*/
|
||||
export declare function setCommandEcho(enabled: boolean): void;
|
||||
/**
|
||||
* Sets the action status to failed.
|
||||
* When the action exits it will be with an exit code of 1
|
||||
* @param message add error issue message
|
||||
*/
|
||||
export declare function setFailed(message: string | Error): void;
|
||||
/**
|
||||
* Gets whether Actions Step Debug is on or not
|
||||
*/
|
||||
export declare function isDebug(): boolean;
|
||||
/**
|
||||
* Writes debug message to user log
|
||||
* @param message debug message
|
||||
*/
|
||||
export declare function debug(message: string): void;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
export declare function error(message: string | Error): void;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* @param message warning issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
export declare function warning(message: string | Error): void;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
*/
|
||||
export declare function info(message: string): void;
|
||||
/**
|
||||
* Begin an output group.
|
||||
*
|
||||
* Output until the next `groupEnd` will be foldable in this group
|
||||
*
|
||||
* @param name The name of the output group
|
||||
*/
|
||||
export declare function startGroup(name: string): void;
|
||||
/**
|
||||
* End an output group.
|
||||
*/
|
||||
export declare function endGroup(): void;
|
||||
/**
|
||||
* Wrap an asynchronous function call in a group.
|
||||
*
|
||||
* Returns the same type as the function itself.
|
||||
*
|
||||
* @param name The name of the group
|
||||
* @param fn The function to wrap in the group
|
||||
*/
|
||||
export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
||||
*
|
||||
* @param name name of the state to store
|
||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
export declare function saveState(name: string, value: any): void;
|
||||
/**
|
||||
* Gets the value of an state set by this action's main execution.
|
||||
*
|
||||
* @param name name of the state to get
|
||||
* @returns string
|
||||
*/
|
||||
export declare function getState(name: string): string;
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const command_1 = require("./command");
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
/**
|
||||
* The code to exit an action
|
||||
*/
|
||||
var ExitCode;
|
||||
(function (ExitCode) {
|
||||
/**
|
||||
* A code indicating that the action was successful
|
||||
*/
|
||||
ExitCode[ExitCode["Success"] = 0] = "Success";
|
||||
/**
|
||||
* A code indicating that the action was a failure
|
||||
*/
|
||||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
||||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
||||
//-----------------------------------------------------------------------
|
||||
// Variables
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Sets env variable for this action and future actions in the job
|
||||
* @param name the name of the variable to set
|
||||
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function exportVariable(name, val) {
|
||||
const convertedVal = command_1.toCommandValue(val);
|
||||
process.env[name] = convertedVal;
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
}
|
||||
exports.exportVariable = exportVariable;
|
||||
/**
|
||||
* Registers a secret which will get masked from logs
|
||||
* @param secret value of the secret
|
||||
*/
|
||||
function setSecret(secret) {
|
||||
command_1.issueCommand('add-mask', {}, secret);
|
||||
}
|
||||
exports.setSecret = setSecret;
|
||||
/**
|
||||
* Prepends inputPath to the PATH (for this action and future actions)
|
||||
* @param inputPath
|
||||
*/
|
||||
function addPath(inputPath) {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||
}
|
||||
exports.addPath = addPath;
|
||||
/**
|
||||
* Gets the value of an input. The value is also trimmed.
|
||||
*
|
||||
* @param name name of the input to get
|
||||
* @param options optional. See InputOptions.
|
||||
* @returns string
|
||||
*/
|
||||
function getInput(name, options) {
|
||||
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
||||
if (options && options.required && !val) {
|
||||
throw new Error(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
return val.trim();
|
||||
}
|
||||
exports.getInput = getInput;
|
||||
/**
|
||||
* Sets the value of an output.
|
||||
*
|
||||
* @param name name of the output to set
|
||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function setOutput(name, value) {
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
}
|
||||
exports.setOutput = setOutput;
|
||||
/**
|
||||
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
||||
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
||||
*
|
||||
*/
|
||||
function setCommandEcho(enabled) {
|
||||
command_1.issue('echo', enabled ? 'on' : 'off');
|
||||
}
|
||||
exports.setCommandEcho = setCommandEcho;
|
||||
//-----------------------------------------------------------------------
|
||||
// Results
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Sets the action status to failed.
|
||||
* When the action exits it will be with an exit code of 1
|
||||
* @param message add error issue message
|
||||
*/
|
||||
function setFailed(message) {
|
||||
process.exitCode = ExitCode.Failure;
|
||||
error(message);
|
||||
}
|
||||
exports.setFailed = setFailed;
|
||||
//-----------------------------------------------------------------------
|
||||
// Logging Commands
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets whether Actions Step Debug is on or not
|
||||
*/
|
||||
function isDebug() {
|
||||
return process.env['RUNNER_DEBUG'] === '1';
|
||||
}
|
||||
exports.isDebug = isDebug;
|
||||
/**
|
||||
* Writes debug message to user log
|
||||
* @param message debug message
|
||||
*/
|
||||
function debug(message) {
|
||||
command_1.issueCommand('debug', {}, message);
|
||||
}
|
||||
exports.debug = debug;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
function error(message) {
|
||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.error = error;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* @param message warning issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
function warning(message) {
|
||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.warning = warning;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
*/
|
||||
function info(message) {
|
||||
process.stdout.write(message + os.EOL);
|
||||
}
|
||||
exports.info = info;
|
||||
/**
|
||||
* Begin an output group.
|
||||
*
|
||||
* Output until the next `groupEnd` will be foldable in this group
|
||||
*
|
||||
* @param name The name of the output group
|
||||
*/
|
||||
function startGroup(name) {
|
||||
command_1.issue('group', name);
|
||||
}
|
||||
exports.startGroup = startGroup;
|
||||
/**
|
||||
* End an output group.
|
||||
*/
|
||||
function endGroup() {
|
||||
command_1.issue('endgroup');
|
||||
}
|
||||
exports.endGroup = endGroup;
|
||||
/**
|
||||
* Wrap an asynchronous function call in a group.
|
||||
*
|
||||
* Returns the same type as the function itself.
|
||||
*
|
||||
* @param name The name of the group
|
||||
* @param fn The function to wrap in the group
|
||||
*/
|
||||
function group(name, fn) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
startGroup(name);
|
||||
let result;
|
||||
try {
|
||||
result = yield fn();
|
||||
}
|
||||
finally {
|
||||
endGroup();
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
exports.group = group;
|
||||
//-----------------------------------------------------------------------
|
||||
// Wrapper action state
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
||||
*
|
||||
* @param name name of the state to store
|
||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function saveState(name, value) {
|
||||
command_1.issueCommand('save-state', { name }, value);
|
||||
}
|
||||
exports.saveState = saveState;
|
||||
/**
|
||||
* Gets the value of an state set by this action's main execution.
|
||||
*
|
||||
* @param name name of the state to get
|
||||
* @returns string
|
||||
*/
|
||||
function getState(name) {
|
||||
return process.env[`STATE_${name}`] || '';
|
||||
}
|
||||
exports.getState = getState;
|
||||
//# sourceMappingURL=core.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAA6D;AAE7D,uCAAwB;AACxB,2CAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,8DAA8D;AAC9D,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAQ;IACnD,MAAM,YAAY,GAAG,wBAAc,CAAC,GAAG,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,CAAC,IAAI,C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G;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC;AAED,yEAAyE;AACzE,uBAAuB;AACvB,yEAAyE;AAEzE;;;;;GAKG;AACH,8DAA8D;AAC9D,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAU;IAChD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAFD,4BAEC"}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "@actions/core@^1.2",
|
||||
"_id": "@actions/core@1.2.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg==",
|
||||
"_location": "/@actions/core",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@actions/core@^1.2",
|
||||
"name": "@actions/core",
|
||||
"escapedName": "@actions%2fcore",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "^1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.4.tgz",
|
||||
"_shasum": "96179dbf9f8d951dd74b40a0dbd5c22555d186ab",
|
||||
"_spec": "@actions/core@^1.2",
|
||||
"_where": "/Users/ilammy/Documents/dev/ilammy/msvc-dev-cmd",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Actions core lib",
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.0.2"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||
"keywords": [
|
||||
"github",
|
||||
"actions",
|
||||
"core"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/core.js",
|
||||
"name": "@actions/core",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/toolkit.git",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"scripts": {
|
||||
"audit-moderate": "npm install && npm audit --audit-level=moderate",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"types": "lib/core.d.ts",
|
||||
"version": "1.2.4"
|
||||
}
|
||||
Generated
+582
-1738
File diff suppressed because it is too large
Load Diff
+5
-4
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "msvc-dev-cmd",
|
||||
"version": "1.13.0-dev",
|
||||
"version": "1.3.0",
|
||||
"description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint index.js"
|
||||
"lint": "eslint index.js",
|
||||
"test": "eslint index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -27,9 +28,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/ilammy/msvc-dev-cmd#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0"
|
||||
"@actions/core": "^1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7"
|
||||
"eslint": "^6.8.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user