=> {
+ const retries = options.retry ?? DEFAULT_RETRY_COUNT
+ const octokit = github.getOctokit(token, {retry: {retries}}, retry)
+
+ try {
+ const response = await octokit.request(CREATE_ATTESTATION_REQUEST, {
+ owner: github.context.repo.owner,
+ repo: github.context.repo.repo,
+ data: {bundle: attestation}
+ })
+
+ const data =
+ typeof response.data == 'string'
+ ? JSON.parse(response.data)
+ : response.data
+ return data?.id
+ } catch (err) {
+ const message = err instanceof Error ? err.message : err
+ throw new Error(`Failed to persist attestation: ${message}`)
+ }
+}
diff --git a/packages/attest/tsconfig.json b/packages/attest/tsconfig.json
new file mode 100644
index 00000000..993eab1d
--- /dev/null
+++ b/packages/attest/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "baseUrl": "./",
+ "outDir": "./lib",
+ "declaration": true,
+ "rootDir": "./src"
+ },
+ "include": [
+ "./src"
+ ]
+}
diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md
index eb86a8b0..43566ef1 100644
--- a/packages/cache/RELEASES.md
+++ b/packages/cache/RELEASES.md
@@ -1,16 +1,154 @@
# @actions/cache Releases
-### 0.1.0
+### 3.2.4
-- Initial release
+- Updated `isGhes` check to include `.ghe.com` and `.ghe.localhost` as accepted hosts
+
+### 3.2.3
-### 0.2.0
+- Fixed a bug that mutated path arguments to `getCacheVersion` [#1378](https://github.com/actions/toolkit/pull/1378)
-- Fixes issues with the zstd compression algorithm on Windows and Ubuntu 16.04 [#469](https://github.com/actions/toolkit/pull/469)
+### 3.2.2
-### 0.2.1
+- Add new default cache download method to improve performance and reduce hangs [#1484](https://github.com/actions/toolkit/pull/1484)
-- Fix to await async function getCompressionMethod
+### 3.2.1
+
+- Updated @azure/storage-blob to `v12.13.0`
+
+### 3.2.0
+
+- Add `lookupOnly` to cache restore `DownloadOptions`.
+
+### 3.1.4
+
+- Fix zstd not being used due to `zstd --version` output change in zstd 1.5.4 release. See [#1353](https://github.com/actions/toolkit/pull/1353).
+
+### 3.1.3
+
+- Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329).
+
+### 3.1.2
+
+- Fix issue with symlink restoration on windows.
+
+### 3.1.1
+
+- Reverted changes in 3.1.0 to fix issue with symlink restoration on windows.
+- Added support for verbose logging about cache version during cache miss.
+
+### 3.1.0
+
+- Update actions/cache on windows to use gnu tar and zstd by default
+- Update actions/cache on windows to fallback to bsdtar and zstd if gnu tar is not available.
+- Added support for fallback to gzip to restore old caches on windows.
+
+### 3.1.0-beta.3
+
+- Bug Fixes for fallback to gzip to restore old caches on windows and bsdtar if gnutar is not available.
+
+### 3.1.0-beta.2
+
+- Added support for fallback to gzip to restore old caches on windows.
+
+### 3.0.6
+
+- Added `@azure/abort-controller` to dependencies to fix compatibility issue with ESM [#1208](https://github.com/actions/toolkit/issues/1208)
+
+### 3.0.5
+
+- Update `@actions/cache` to use `@actions/core@^1.10.0`
+
+### 3.0.4
+
+- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891).
+- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
+
+### 3.0.3
+
+- Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810).
+
+### 3.0.2
+
+- Added 1 hour timeout for the download stuck issue [#810](https://github.com/actions/cache/issues/810).
+
+### 3.0.1
+
+- Fix [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory.
+- Fix [#809](https://github.com/actions/cache/issues/809) `zstd -d: no such file or directory` error on AWS self-hosted runners.
+
+### 3.0.0
+
+- Updated actions/cache to suppress Actions cache server error and log warning for those error [#1122](https://github.com/actions/toolkit/pull/1122)
+
+### 2.0.6
+
+- Fix `Tar failed with error: The process '/usr/bin/tar' failed with exit code 1` issue when temp directory where tar is getting created is actually the subdirectory of the path mentioned by the user for caching. ([issue](https://github.com/actions/cache/issues/689))
+
+### 2.0.5
+
+- Fix to avoid saving empty cache when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624))
+
+### 2.0.4
+
+- Update to v2.0.1 of `@actions/http-client` [#1087](https://github.com/actions/toolkit/pull/1087)
+
+### 2.0.3
+
+- Update to v2.0.0 of `@actions/http-client`
+
+### 2.0.0
+
+- Added support to check if Actions cache service feature is available or not [#1028](https://github.com/actions/toolkit/pull/1028)
+
+### 1.0.11
+
+- Fix file downloads > 2GB([issue](https://github.com/actions/cache/issues/773))
+
+### 1.0.10
+
+- Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022)
+
+### 1.0.9
+
+- Use @azure/ms-rest-js v2.6.0
+- Use @azure/storage-blob v12.8.0
+
+### 1.0.8
+
+- Increase the allowed artifact cache size from 5GB to 10GB ([issue](https://github.com/actions/cache/discussions/497))
+
+### 1.0.7
+
+- Fixes permissions issue extracting archives with GNU tar on macOS ([issue](https://github.com/actions/cache/issues/527))
+
+### 1.0.6
+
+- Make caching more verbose [#650](https://github.com/actions/toolkit/pull/650)
+- Use GNU tar on macOS if available [#701](https://github.com/actions/toolkit/pull/701)
+
+### 1.0.5
+
+- Fix to ensure Windows cache paths get resolved correctly
+
+### 1.0.4
+
+- Use @actions/core v1.2.6
+- Fixes uploadChunk to throw an error if any unsuccessful response code is received
+
+### 1.0.3
+
+- Use http-client v1.0.9
+- Fixes error handling so retries are not attempted on non-retryable errors (409 Conflict, for example)
+- Adds 5 second delay between retry attempts
+
+### 1.0.2
+
+- Use posix archive format to add support for some tools
+
+### 1.0.1
+
+- Fix bug in downloading large files (> 2 GBs) with the Azure SDK
### 1.0.0
@@ -19,148 +157,14 @@
- Includes changes that break compatibility with earlier versions, including:
- `retry`, `retryTypedResponse`, and `retryHttpClientResponse` moved from `cacheHttpClient` to `requestUtils`
-### 1.0.1
+### 0.2.1
-- Fix bug in downloading large files (> 2 GBs) with the Azure SDK
+- Fix to await async function getCompressionMethod
+
+### 0.2.0
-### 1.0.2
+- Fixes issues with the zstd compression algorithm on Windows and Ubuntu 16.04 [#469](https://github.com/actions/toolkit/pull/469)
+
+### 0.1.0
-- Use posix archive format to add support for some tools
-
-### 1.0.3
-
-- Use http-client v1.0.9
-- Fixes error handling so retries are not attempted on non-retryable errors (409 Conflict, for example)
-- Adds 5 second delay between retry attempts
-
-### 1.0.4
-
-- Use @actions/core v1.2.6
-- Fixes uploadChunk to throw an error if any unsuccessful response code is received
-
-### 1.0.5
-
-- Fix to ensure Windows cache paths get resolved correctly
-
-### 1.0.6
-
-- Make caching more verbose [#650](https://github.com/actions/toolkit/pull/650)
-- Use GNU tar on macOS if available [#701](https://github.com/actions/toolkit/pull/701)
-
-### 1.0.7
-
-- Fixes permissions issue extracting archives with GNU tar on macOS ([issue](https://github.com/actions/cache/issues/527))
-
-### 1.0.8
-
-- Increase the allowed artifact cache size from 5GB to 10GB ([issue](https://github.com/actions/cache/discussions/497))
-
-### 1.0.9
-
-- Use @azure/ms-rest-js v2.6.0
-- Use @azure/storage-blob v12.8.0
-
-### 1.0.10
-
-- Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022)
-
-### 1.0.11
-
-- Fix file downloads > 2GB([issue](https://github.com/actions/cache/issues/773))
-
-### 2.0.0
-
-- Added support to check if Actions cache service feature is available or not [#1028](https://github.com/actions/toolkit/pull/1028)
-
-### 2.0.3
-
-- Update to v2.0.0 of `@actions/http-client`
-
-### 2.0.4
-
-- Update to v2.0.1 of `@actions/http-client` [#1087](https://github.com/actions/toolkit/pull/1087)
-
-### 2.0.5
-
-- Fix to avoid saving empty cache when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624))
-
-### 2.0.6
-
-- Fix `Tar failed with error: The process '/usr/bin/tar' failed with exit code 1` issue when temp directory where tar is getting created is actually the subdirectory of the path mentioned by the user for caching. ([issue](https://github.com/actions/cache/issues/689))
-
-### 3.0.0
-
-- Updated actions/cache to suppress Actions cache server error and log warning for those error [#1122](https://github.com/actions/toolkit/pull/1122)
-
-### 3.0.1
-
-- Fix [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory.
-- Fix [#809](https://github.com/actions/cache/issues/809) `zstd -d: no such file or directory` error on AWS self-hosted runners.
-
-### 3.0.2
-
-- Added 1 hour timeout for the download stuck issue [#810](https://github.com/actions/cache/issues/810).
-
-### 3.0.3
-
-- Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810).
-
-### 3.0.4
-
-- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891).
-- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
-
-### 3.0.5
-
-- Update `@actions/cache` to use `@actions/core@^1.10.0`
-
-### 3.0.6
-
-- Added `@azure/abort-controller` to dependencies to fix compatibility issue with ESM [#1208](https://github.com/actions/toolkit/issues/1208)
-
-### 3.1.0-beta.1
-
-- Update actions/cache on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
-
-### 3.1.0-beta.2
-
-- Added support for fallback to gzip to restore old caches on windows.
-
-### 3.1.0-beta.3
-
-- Bug Fixes for fallback to gzip to restore old caches on windows and bsdtar if gnutar is not available.
-
-### 3.1.0
-
-- Update actions/cache on windows to use gnu tar and zstd by default
-- Update actions/cache on windows to fallback to bsdtar and zstd if gnu tar is not available.
-- Added support for fallback to gzip to restore old caches on windows.
-
-### 3.1.1
-
-- Reverted changes in 3.1.0 to fix issue with symlink restoration on windows.
-- Added support for verbose logging about cache version during cache miss.
-
-### 3.1.2
-
-- Fix issue with symlink restoration on windows.
-
-### 3.1.3
-
-- Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329).
-
-### 3.1.4
-
-- Fix zstd not being used due to `zstd --version` output change in zstd 1.5.4 release. See [#1353](https://github.com/actions/toolkit/pull/1353).
-
-### 3.2.0
-
-- Add `lookupOnly` to cache restore `DownloadOptions`.
-
-### 3.2.1
-
-- Updated @azure/storage-blob to `v12.13.0`
-
-### 3.2.2
-
-- Add new default cache download method to improve performance and reduce hangs [#1484](https://github.com/actions/toolkit/pull/1484)
+- Initial release
diff --git a/packages/cache/__tests__/cacheHttpClient.test.ts b/packages/cache/__tests__/cacheHttpClient.test.ts
index 02dd91c1..21c5ae86 100644
--- a/packages/cache/__tests__/cacheHttpClient.test.ts
+++ b/packages/cache/__tests__/cacheHttpClient.test.ts
@@ -5,6 +5,12 @@ import {DownloadOptions, getDownloadOptions} from '../src/options'
jest.mock('../src/internal/downloadUtils')
+test('getCacheVersion does not mutate arguments', async () => {
+ const paths = ['node_modules']
+ getCacheVersion(paths, undefined, true)
+ expect(paths).toEqual(['node_modules'])
+})
+
test('getCacheVersion with one path returns version', async () => {
const paths = ['node_modules']
const result = getCacheVersion(paths, undefined, true)
diff --git a/packages/cache/__tests__/cacheUtils.test.ts b/packages/cache/__tests__/cacheUtils.test.ts
index 25124b46..4388026a 100644
--- a/packages/cache/__tests__/cacheUtils.test.ts
+++ b/packages/cache/__tests__/cacheUtils.test.ts
@@ -2,6 +2,10 @@ import {promises as fs} from 'fs'
import * as path from 'path'
import * as cacheUtils from '../src/internal/cacheUtils'
+beforeEach(() => {
+ jest.resetModules()
+})
+
test('getArchiveFileSizeInBytes returns file size', () => {
const filePath = path.join(__dirname, '__fixtures__', 'helloWorld.txt')
@@ -38,3 +42,23 @@ test('resolvePaths works on github workspace directory', async () => {
const paths = await cacheUtils.resolvePaths([workspace])
expect(paths.length).toBeGreaterThan(0)
})
+
+test('isGhes returns false for github.com', async () => {
+ process.env.GITHUB_SERVER_URL = 'https://github.com'
+ expect(cacheUtils.isGhes()).toBe(false)
+})
+
+test('isGhes returns false for ghe.com', async () => {
+ process.env.GITHUB_SERVER_URL = 'https://somedomain.ghe.com'
+ expect(cacheUtils.isGhes()).toBe(false)
+})
+
+test('isGhes returns true for enterprise URL', async () => {
+ process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
+ expect(cacheUtils.isGhes()).toBe(true)
+})
+
+test('isGhes returns false for ghe.localhost', () => {
+ process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
+ expect(cacheUtils.isGhes()).toBe(false)
+})
diff --git a/packages/cache/package-lock.json b/packages/cache/package-lock.json
index 31a81013..422f2264 100644
--- a/packages/cache/package-lock.json
+++ b/packages/cache/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@actions/cache",
- "version": "3.2.2",
+ "version": "3.2.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@actions/cache",
- "version": "3.2.2",
+ "version": "3.2.4",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
diff --git a/packages/cache/package.json b/packages/cache/package.json
index b742c525..d3251083 100644
--- a/packages/cache/package.json
+++ b/packages/cache/package.json
@@ -1,6 +1,6 @@
{
"name": "@actions/cache",
- "version": "3.2.2",
+ "version": "3.2.4",
"preview": true,
"description": "Actions cache lib",
"keywords": [
diff --git a/packages/cache/src/internal/cacheHttpClient.ts b/packages/cache/src/internal/cacheHttpClient.ts
index 880ebff2..f96ca381 100644
--- a/packages/cache/src/internal/cacheHttpClient.ts
+++ b/packages/cache/src/internal/cacheHttpClient.ts
@@ -80,7 +80,8 @@ export function getCacheVersion(
compressionMethod?: CompressionMethod,
enableCrossOsArchive = false
): string {
- const components = paths
+ // don't pass changes upstream
+ const components = paths.slice()
// Add compression method to cache version to restore
// compressed cache as per compression method
diff --git a/packages/cache/src/internal/cacheUtils.ts b/packages/cache/src/internal/cacheUtils.ts
index 650653ad..91bae9a8 100644
--- a/packages/cache/src/internal/cacheUtils.ts
+++ b/packages/cache/src/internal/cacheUtils.ts
@@ -135,5 +135,11 @@ export function isGhes(): boolean {
const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
)
- return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
+
+ const hostname = ghUrl.hostname.trimEnd().toUpperCase()
+ const isGitHubHost = hostname === 'GITHUB.COM'
+ const isGheHost =
+ hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST')
+
+ return !isGitHubHost && !isGheHost
}
diff --git a/packages/core/README.md b/packages/core/README.md
index 8a471430..ac8ced92 100644
--- a/packages/core/README.md
+++ b/packages/core/README.md
@@ -333,3 +333,154 @@ toPlatformPath('/foo/bar') // => \foo\bar
// On a Linux runner.
toPlatformPath('\\foo\\bar') // => /foo/bar
```
+
+#### Platform helper
+
+Provides shorthands for getting information about platform action is running on.
+
+```js
+import { platform } from '@actions/core'
+
+/* equals to a call of os.platform() */
+platform.platform // 'win32' | 'darwin' | 'linux' | 'freebsd' | 'openbsd' | 'android' | 'cygwin' | 'sunos'
+
+/* equals to a call of os.arch() */
+platform.arch // 'x64' | 'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x'
+
+/* common shorthands for platform-specific logic */
+platform.isWindows // true
+platform.isMacOS // false
+platform.isLinux // false
+
+/* run platform-specific script to get more details about the exact platform, works on Windows, MacOS and Linux */
+const {
+ name, // Microsoft Windows 11 Enterprise
+ version, // 10.0.22621
+} = await platform.getDetails()
+```
+
+#### Populating job summary
+
+These methods can be used to populate a [job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary). A job summary is a buffer that can be added to throughout your job via `core.summary` methods.
+
+Job summaries when complete must be written to the summary buffer file via the `core.summary.write()` method.
+
+All methods except `addRaw()` utilize the `addRaw()` method to append to the buffer, followed by an EOL using the `addEOL()` method.
+
+```typescript
+
+// Write raw text, optionally add an EOL after the content, defaults to false
+core.summary.addRaw('Some content here :speech_balloon:', true)
+// Output: Some content here :speech_balloon:\n
+
+// Add an operating system-specific end-of-line marker
+core.summary.addEOL()
+// Output (POSIX): \n
+// Output (Windows): \r\n
+
+// Add a codeblock with an optional language for syntax highlighting
+core.summary.addCodeBlock('console.log(\'hello world\')', 'javascript')
+// Output: console.log('hello world')
+
+// Add a list, second parameter indicates if list is ordered, defaults to false
+core.summary.addList(['item1','item2','item3'], true)
+// Output: - item1
- item2
- item3
+
+// Add a collapsible HTML details element
+core.summary.addDetails('Label', 'Some detail that will be collapsed')
+// Output: Label
Some detail that will be collapsed
+
+// Add an image, image options parameter is optional, you can supply one of or both width and height in pixels
+core.summary.addImage('example.png', 'alt description of img', {width: '100', height: '100'})
+// Output:
+
+// Add an HTML section heading element, optionally pass a level that translates to 'hX' ie. h2. Defaults to h1
+core.summary.addHeading('My Heading', '2')
+// Output: My Heading
+
+// Add an HTML thematic break
+core.summary.addSeparator()
+// Output:
+
+// Add an HTML line break
+core.summary.addBreak()
+// Output:
+
+// Add an HTML blockquote with an optional citation
+core.summary.addQuote('To be or not to be', 'Shakespeare')
+// Output: To be or not to be
+
+// Add an HTML anchor tag
+core.summary.addLink('click here', 'https://github.com')
+// Output: click here
+
+```
+
+Tables are added using the `addTable()` method, and an array of `SummaryTableRow`.
+
+```typescript
+
+export type SummaryTableRow = (SummaryTableCell | string)[]
+
+export interface SummaryTableCell {
+ /**
+ * Cell content
+ */
+ data: string
+ /**
+ * Render cell as header
+ * (optional) default: false
+ */
+ header?: boolean
+ /**
+ * Number of columns the cell extends
+ * (optional) default: '1'
+ */
+ colspan?: string
+ /**
+ * Number of rows the cell extends
+ * (optional) default: '1'
+ */
+ rowspan?: string
+}
+
+```
+
+For example
+
+```typescript
+
+const tableData = [
+ {data: 'Header1', header: true},
+ {data: 'Header2', header: true},
+ {data: 'Header3', header: true},
+ {data: 'MyData1'},
+ {data: 'MyData2'},
+ {data: 'MyData3'}
+]
+
+// Add an HTML table
+core.summary.addTable([tableData])
+// Output: Header1 | Header2 | Header3 |
---|
|
MyData1 | MyData2 | MyData3 |
+
+```
+
+In addition to job summary content, there are utility functions for interfacing with the buffer.
+
+```typescript
+
+// Empties the summary buffer AND wipes the summary file on disk
+core.summary.clear()
+
+// Returns the current summary buffer as a string
+core.summary.stringify()
+
+// If the summary buffer is empty
+core.summary.isEmptyBuffer()
+
+// Resets the summary buffer without writing to the summary file on disk
+core.summary.emptyBuffer()
+
+// Writes text in the buffer to the summary buffer file and empties the buffer, optionally overwriting all existing content in the summary file with buffer contents. Defaults to false.
+core.summary.write({overwrite: true})
+```
\ No newline at end of file
diff --git a/packages/core/__tests__/platform.test.ts b/packages/core/__tests__/platform.test.ts
new file mode 100644
index 00000000..c80be330
--- /dev/null
+++ b/packages/core/__tests__/platform.test.ts
@@ -0,0 +1,29 @@
+import os from 'os'
+import {platform} from '../src/core'
+
+describe('getInfo', () => {
+ it('returns the platform info', async () => {
+ const info = await platform.getDetails()
+ expect(info).toEqual({
+ name: expect.any(String),
+ platform: expect.any(String),
+ arch: expect.any(String),
+ version: expect.any(String),
+ isWindows: expect.any(Boolean),
+ isMacOS: expect.any(Boolean),
+ isLinux: expect.any(Boolean)
+ })
+ })
+
+ it('returns the platform info with the correct name', async () => {
+ const isWindows = os.platform() === 'win32'
+ const isMacOS = os.platform() === 'darwin'
+ const isLinux = os.platform() === 'linux'
+
+ const info = await platform.getDetails()
+ expect(info.platform).toEqual(os.platform())
+ expect(info.isWindows).toEqual(isWindows)
+ expect(info.isMacOS).toEqual(isMacOS)
+ expect(info.isLinux).toEqual(isLinux)
+ })
+})
diff --git a/packages/core/package-lock.json b/packages/core/package-lock.json
index d86f7ef0..7b1cf7bb 100644
--- a/packages/core/package-lock.json
+++ b/packages/core/package-lock.json
@@ -9,6 +9,7 @@
"version": "1.10.1",
"license": "MIT",
"dependencies": {
+ "@actions/exec": "^1.1.1",
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
},
@@ -17,6 +18,14 @@
"@types/uuid": "^8.3.4"
}
},
+ "node_modules/@actions/exec": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
+ "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
+ "dependencies": {
+ "@actions/io": "^1.0.1"
+ }
+ },
"node_modules/@actions/http-client": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
@@ -25,6 +34,11 @@
"tunnel": "^0.0.6"
}
},
+ "node_modules/@actions/io": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
+ "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
+ },
"node_modules/@types/node": {
"version": "12.0.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz",
@@ -55,6 +69,14 @@
}
},
"dependencies": {
+ "@actions/exec": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
+ "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
+ "requires": {
+ "@actions/io": "^1.0.1"
+ }
+ },
"@actions/http-client": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
@@ -63,6 +85,11 @@
"tunnel": "^0.0.6"
}
},
+ "@actions/io": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
+ "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
+ },
"@types/node": {
"version": "12.0.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz",
diff --git a/packages/core/package.json b/packages/core/package.json
index 1558268c..2eda27b5 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -36,6 +36,7 @@
"url": "https://github.com/actions/toolkit/issues"
},
"dependencies": {
+ "@actions/exec": "^1.1.1",
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
},
diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts
index 1e8d940a..0a141693 100644
--- a/packages/core/src/core.ts
+++ b/packages/core/src/core.ts
@@ -386,3 +386,8 @@ export {markdownSummary} from './summary'
* Path exports
*/
export {toPosixPath, toWin32Path, toPlatformPath} from './path-utils'
+
+/**
+ * Platform utilities exports
+ */
+export * as platform from './platform'
diff --git a/packages/core/src/platform.ts b/packages/core/src/platform.ts
new file mode 100644
index 00000000..55fdee64
--- /dev/null
+++ b/packages/core/src/platform.ts
@@ -0,0 +1,87 @@
+import os from 'os'
+import * as exec from '@actions/exec'
+
+const getWindowsInfo = async (): Promise<{name: string; version: string}> => {
+ const {stdout: version} = await exec.getExecOutput(
+ 'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"',
+ undefined,
+ {
+ silent: true
+ }
+ )
+
+ const {stdout: name} = await exec.getExecOutput(
+ 'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"',
+ undefined,
+ {
+ silent: true
+ }
+ )
+
+ return {
+ name: name.trim(),
+ version: version.trim()
+ }
+}
+
+const getMacOsInfo = async (): Promise<{
+ name: string
+ version: string
+}> => {
+ const {stdout} = await exec.getExecOutput('sw_vers', undefined, {
+ silent: true
+ })
+
+ const version = stdout.match(/ProductVersion:\s*(.+)/)?.[1] ?? ''
+ const name = stdout.match(/ProductName:\s*(.+)/)?.[1] ?? ''
+
+ return {
+ name,
+ version
+ }
+}
+
+const getLinuxInfo = async (): Promise<{
+ name: string
+ version: string
+}> => {
+ const {stdout} = await exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], {
+ silent: true
+ })
+
+ const [name, version] = stdout.trim().split('\n')
+
+ return {
+ name,
+ version
+ }
+}
+
+export const platform = os.platform()
+export const arch = os.arch()
+export const isWindows = platform === 'win32'
+export const isMacOS = platform === 'darwin'
+export const isLinux = platform === 'linux'
+
+export async function getDetails(): Promise<{
+ name: string
+ platform: string
+ arch: string
+ version: string
+ isWindows: boolean
+ isMacOS: boolean
+ isLinux: boolean
+}> {
+ return {
+ ...(await (isWindows
+ ? getWindowsInfo()
+ : isMacOS
+ ? getMacOsInfo()
+ : getLinuxInfo())),
+ platform,
+ arch,
+ isWindows,
+ isMacOS,
+ isLinux
+ }
+}
diff --git a/packages/github/src/context.ts b/packages/github/src/context.ts
index d3f65f7a..691c9690 100644
--- a/packages/github/src/context.ts
+++ b/packages/github/src/context.ts
@@ -16,6 +16,7 @@ export class Context {
action: string
actor: string
job: string
+ runAttempt: number
runNumber: number
runId: number
apiUrl: string
@@ -44,6 +45,7 @@ export class Context {
this.action = process.env.GITHUB_ACTION as string
this.actor = process.env.GITHUB_ACTOR as string
this.job = process.env.GITHUB_JOB as string
+ this.runAttempt = parseInt(process.env.GITHUB_RUN_ATTEMPT as string, 10)
this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER as string, 10)
this.runId = parseInt(process.env.GITHUB_RUN_ID as string, 10)
this.apiUrl = process.env.GITHUB_API_URL ?? `https://api.github.com`
diff --git a/packages/http-client/__tests__/keepalive.test.ts b/packages/http-client/__tests__/keepalive.test.ts
index 98180cdf..20f2865e 100644
--- a/packages/http-client/__tests__/keepalive.test.ts
+++ b/packages/http-client/__tests__/keepalive.test.ts
@@ -11,6 +11,12 @@ describe('basics', () => {
_http.dispose()
})
+ it.each([true, false])('creates Agent with keepAlive %s', keepAlive => {
+ const http = new httpm.HttpClient('http-client-tests', [], {keepAlive})
+ const agent = http.getAgent('http://postman-echo.com')
+ expect(agent).toHaveProperty('keepAlive', keepAlive)
+ })
+
it('does basic http get request with keepAlive true', async () => {
const res: httpm.HttpClientResponse = await _http.get(
'http://postman-echo.com/get'
diff --git a/packages/http-client/package-lock.json b/packages/http-client/package-lock.json
index dc7a9bd8..52038ad3 100644
--- a/packages/http-client/package-lock.json
+++ b/packages/http-client/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@actions/http-client",
- "version": "2.2.0",
+ "version": "2.2.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@actions/http-client",
- "version": "2.2.0",
+ "version": "2.2.1",
"license": "MIT",
"dependencies": {
"tunnel": "^0.0.6",
diff --git a/packages/http-client/package.json b/packages/http-client/package.json
index ed134372..0ae89c34 100644
--- a/packages/http-client/package.json
+++ b/packages/http-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@actions/http-client",
- "version": "2.2.0",
+ "version": "2.2.1",
"description": "Actions Http Client",
"keywords": [
"github",
@@ -48,4 +48,4 @@
"tunnel": "^0.0.6",
"undici": "^5.25.4"
}
-}
+}
\ No newline at end of file
diff --git a/packages/http-client/src/index.ts b/packages/http-client/src/index.ts
index cd82c76d..bff4a03a 100644
--- a/packages/http-client/src/index.ts
+++ b/packages/http-client/src/index.ts
@@ -663,7 +663,7 @@ export class HttpClient {
agent = this._proxyAgent
}
- if (this._keepAlive && !useProxy) {
+ if (!useProxy) {
agent = this._agent
}
@@ -704,18 +704,13 @@ export class HttpClient {
this._proxyAgent = agent
}
- // if reusing agent across request and tunneling agent isn't assigned create a new agent
- if (this._keepAlive && !agent) {
+ // if tunneling agent isn't assigned create a new agent
+ if (!agent) {
const options = {keepAlive: this._keepAlive, maxSockets}
agent = usingSsl ? new https.Agent(options) : new http.Agent(options)
this._agent = agent
}
- // if not using private agent and tunnel agent isn't setup then use global agent
- if (!agent) {
- agent = usingSsl ? https.globalAgent : http.globalAgent
- }
-
if (usingSsl && this._ignoreSslError) {
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options