Skip to content

Commit c40c16d

Browse files
committed
add new artifact-digest output
Signed-off-by: Brian DeHamer <[email protected]>
1 parent 735efb4 commit c40c16d

File tree

10 files changed

+21
-6
lines changed

10 files changed

+21
-6
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
122122
| - | - | - |
123123
| `artifact-id` | GitHub ID of an Artifact, can be used by the REST API | `1234` |
124124
| `artifact-url` | URL to download an Artifact. Can be used in many scenarios such as linking to artifacts in issues or pull requests. Users must be logged-in in order for this URL to work. This URL is valid as long as the artifact has not expired or the artifact, run or repository have not been deleted | `https://github.com/example-org/example-repo/actions/runs/1/artifacts/1234` |
125+
| `artifact-digest` | SHA-256 digest of an Artifact | 0fde654d4c6e659b45783a725dc92f1bfb0baa6c2de64b34e814dc206ff4aaaf |
125126

126127
## Examples
127128

__tests__/upload.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ describe('upload', () => {
6060

6161
jest.spyOn(artifact, 'uploadArtifact').mockResolvedValue({
6262
size: 123,
63-
id: 1337
63+
id: 1337,
64+
digest: 'facefeed'
6465
})
6566
})
6667

@@ -95,6 +96,7 @@ describe('upload', () => {
9596
await run()
9697

9798
expect(core.setOutput).toHaveBeenCalledWith('artifact-id', 1337)
99+
expect(core.setOutput).toHaveBeenCalledWith('artifact-digest', 'facefeed')
98100
expect(core.setOutput).toHaveBeenCalledWith(
99101
'artifact-url',
100102
`${github.context.serverUrl}/${github.context.repo.owner}/${

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ outputs:
6161
6262
This URL will be valid for as long as the artifact exists and the workflow run and repository exists. Once an artifact has expired this URL will no longer work.
6363
Common uses cases for such a download URL can be adding download links to artifacts in descriptions or comments on pull requests or issues.
64+
artifact-digest:
65+
description: >
66+
SHA-256 digest for the artifact that was just uploaded. Empty if the artifact upload failed.
6467
runs:
6568
using: 'node20'
6669
main: 'dist/upload/index.js'

dist/merge/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3606,6 +3606,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
36063606
core.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`);
36073607
return {
36083608
size: uploadResult.uploadSize,
3609+
digest: uploadResult.sha256Hash,
36093610
id: Number(artifactId)
36103611
};
36113612
});
@@ -127615,6 +127616,7 @@ function uploadArtifact(artifactName, filesToUpload, rootDirectory, options) {
127615127616
const uploadResponse = yield artifact_1.default.uploadArtifact(artifactName, filesToUpload, rootDirectory, options);
127616127617
core.info(`Artifact ${artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`);
127617127618
core.setOutput('artifact-id', uploadResponse.id);
127619+
core.setOutput('artifact-digest', uploadResponse.digest);
127618127620
const repository = github.context.repo;
127619127621
const artifactURL = `${github.context.serverUrl}/${repository.owner}/${repository.repo}/actions/runs/${github.context.runId}/artifacts/${uploadResponse.id}`;
127620127622
core.info(`Artifact download URL: ${artifactURL}`);
@@ -137604,7 +137606,7 @@ module.exports = index;
137604137606
/***/ ((module) => {
137605137607

137606137608
"use strict";
137607-
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.11","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137609+
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.2.0","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137608137610

137609137611
/***/ }),
137610137612

dist/upload/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3606,6 +3606,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
36063606
core.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`);
36073607
return {
36083608
size: uploadResult.uploadSize,
3609+
digest: uploadResult.sha256Hash,
36093610
id: Number(artifactId)
36103611
};
36113612
});
@@ -127370,6 +127371,7 @@ function uploadArtifact(artifactName, filesToUpload, rootDirectory, options) {
127370127371
const uploadResponse = yield artifact_1.default.uploadArtifact(artifactName, filesToUpload, rootDirectory, options);
127371127372
core.info(`Artifact ${artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`);
127372127373
core.setOutput('artifact-id', uploadResponse.id);
127374+
core.setOutput('artifact-digest', uploadResponse.digest);
127373127375
const repository = github.context.repo;
127374127376
const artifactURL = `${github.context.serverUrl}/${repository.owner}/${repository.repo}/actions/runs/${github.context.runId}/artifacts/${uploadResponse.id}`;
127375127377
core.info(`Artifact download URL: ${artifactURL}`);
@@ -137614,7 +137616,7 @@ module.exports = index;
137614137616
/***/ ((module) => {
137615137617

137616137618
"use strict";
137617-
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.11","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137619+
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.2.0","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
137618137620

137619137621
/***/ }),
137620137622

merge/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ For most cases, this may not be the most efficient solution. See [the migration
6565
| - | - | - |
6666
| `artifact-id` | GitHub ID of an Artifact, can be used by the REST API | `1234` |
6767
| `artifact-url` | URL to download an Artifact. Can be used in many scenarios such as linking to artifacts in issues or pull requests. Users must be logged-in in order for this URL to work. This URL is valid as long as the artifact has not expired or the artifact, run or repository have not been deleted | `https://github.com/example-org/example-repo/actions/runs/1/artifacts/1234` |
68+
| `artifact-digest` | SHA-256 digest of an Artifact | 0fde654d4c6e659b45783a725dc92f1bfb0baa6c2de64b34e814dc206ff4aaaf |
6869

6970
## Examples
7071

merge/action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ outputs:
5757
5858
This URL will be valid for as long as the artifact exists and the workflow run and repository exists. Once an artifact has expired this URL will no longer work.
5959
Common uses cases for such a download URL can be adding download links to artifacts in descriptions or comments on pull requests or issues.
60+
artifact-digest:
61+
description: >
62+
SHA-256 digest for the artifact that was just uploaded. Empty if the artifact upload failed.
6063
runs:
6164
using: 'node20'
6265
main: '../dist/merge/index.js'

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "upload-artifact",
3-
"version": "4.4.3",
3+
"version": "4.5.0",
44
"description": "Upload an Actions Artifact in a workflow run",
55
"main": "dist/upload/index.js",
66
"scripts": {

src/shared/upload-artifact.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export async function uploadArtifact(
1919
`Artifact ${artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`
2020
)
2121
core.setOutput('artifact-id', uploadResponse.id)
22+
core.setOutput('artifact-digest', uploadResponse.digest)
2223

2324
const repository = github.context.repo
2425
const artifactURL = `${github.context.serverUrl}/${repository.owner}/${repository.repo}/actions/runs/${github.context.runId}/artifacts/${uploadResponse.id}`

0 commit comments

Comments
 (0)