@actions/attest 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package-version.cjs +7 -0
- package/lib/store.js +14 -1
- package/lib/store.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// This file exists as a CommonJS module to read the version from package.json.
|
|
2
|
+
// In an ESM package, using `require()` directly in .ts files requires disabling
|
|
3
|
+
// ESLint rules and doesn't work reliably across all Node.js versions.
|
|
4
|
+
// By keeping this as a .cjs file, we can use require() naturally and export
|
|
5
|
+
// the version for the ESM modules to import.
|
|
6
|
+
const packageJson = require('../package.json')
|
|
7
|
+
module.exports = {version: packageJson.version}
|
package/lib/store.js
CHANGED
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import * as github from '@actions/github';
|
|
11
11
|
import { retry } from '@octokit/plugin-retry';
|
|
12
|
+
import { version } from './package-version.cjs';
|
|
12
13
|
const CREATE_ATTESTATION_REQUEST = 'POST /repos/{owner}/{repo}/attestations';
|
|
13
14
|
const DEFAULT_RETRY_COUNT = 5;
|
|
14
15
|
/**
|
|
@@ -22,11 +23,12 @@ export const writeAttestation = (attestation_1, token_1, ...args_1) => __awaiter
|
|
|
22
23
|
var _a;
|
|
23
24
|
const retries = (_a = options.retry) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_COUNT;
|
|
24
25
|
const octokit = github.getOctokit(token, { retry: { retries } }, retry);
|
|
26
|
+
const headers = Object.assign({ 'User-Agent': getUserAgent() }, options.headers);
|
|
25
27
|
try {
|
|
26
28
|
const response = yield octokit.request(CREATE_ATTESTATION_REQUEST, {
|
|
27
29
|
owner: github.context.repo.owner,
|
|
28
30
|
repo: github.context.repo.repo,
|
|
29
|
-
headers
|
|
31
|
+
headers,
|
|
30
32
|
bundle: attestation
|
|
31
33
|
});
|
|
32
34
|
const data = typeof response.data == 'string'
|
|
@@ -39,4 +41,15 @@ export const writeAttestation = (attestation_1, token_1, ...args_1) => __awaiter
|
|
|
39
41
|
throw new Error(`Failed to persist attestation: ${message}`);
|
|
40
42
|
}
|
|
41
43
|
});
|
|
44
|
+
const getUserAgent = () => {
|
|
45
|
+
const baseUserAgent = `@actions/attest-${version}`;
|
|
46
|
+
const orchId = process.env['ACTIONS_ORCHESTRATION_ID'];
|
|
47
|
+
if (orchId) {
|
|
48
|
+
// Sanitize the orchestration ID to ensure it contains only valid characters
|
|
49
|
+
// Valid characters: 0-9, a-z, _, -, .
|
|
50
|
+
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
|
|
51
|
+
return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`;
|
|
52
|
+
}
|
|
53
|
+
return baseUserAgent;
|
|
54
|
+
};
|
|
42
55
|
//# sourceMappingURL=store.js.map
|
package/lib/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAC,KAAK,EAAC,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAC,KAAK,EAAC,MAAM,uBAAuB,CAAA;AAE3C,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAA;AAE7C,MAAM,0BAA0B,GAAG,yCAAyC,CAAA;AAC5E,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAM7B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,oCAIb,EAAE,2EAHnB,WAAoB,EACpB,KAAa,EACb,UAAwB,EAAE;;IAE1B,MAAM,OAAO,GA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AAW,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;QACzD,OAAO,GAAG,aAAa,6BAA6B,WAAW,EAAE,CAAA;IACnE,CAAC;IAED,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actions/attest",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Actions attestation lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
39
|
-
"tsc": "tsc"
|
|
39
|
+
"tsc": "tsc && cp src/package-version.cjs lib/"
|
|
40
40
|
},
|
|
41
41
|
"bugs": {
|
|
42
42
|
"url": "https://github.com/actions/toolkit/issues"
|