Skip to content

Commit d920f8f

Browse files
committed
feat(package)!: skip archiving packaged tarball
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
1 parent edadd27 commit d920f8f

File tree

3 files changed

+73
-21
lines changed

3 files changed

+73
-21
lines changed

.github/workflows/__test-action-package.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ jobs:
1616
include:
1717
- working-directory: tests/npm
1818
artifact-suffix: npm
19+
install-command: npm install
1920
- working-directory: tests/pnpm
2021
artifact-suffix: pnpm
22+
install-command: pnpm install
2123
- working-directory: tests/pnpm-package-manager
2224
artifact-suffix: pnpm-package-manager
25+
install-command: pnpm install
2326
- working-directory: tests/yarn
2427
artifact-suffix: yarn
28+
install-command: yarn install
2529
steps:
2630
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2731

@@ -47,3 +51,26 @@ jobs:
4751
echo "package-tarball-artifact-id output is empty"
4852
exit 1
4953
fi
54+
55+
- name: Download package tarball artifact by ID
56+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
57+
with:
58+
artifact-ids: ${{ steps.package.outputs.package-tarball-artifact-id }}
59+
path: ${{ runner.temp }}
60+
skip-decompress: true
61+
62+
- name: Check downloaded package tarball artifact
63+
env:
64+
TARBALL_PATH: ${{ steps.package.outputs.package-tarball-path }}
65+
INSTALL_COMMAND: ${{ matrix.install-command }}
66+
working-directory: ${{ runner.temp }}
67+
run: |
68+
tarball_name="$(basename "$TARBALL_PATH")"
69+
70+
if [ ! -f "./$tarball_name" ]; then
71+
echo "Downloaded package tarball artifact does not exist"
72+
exit 1
73+
fi
74+
75+
# Install the tarball to verify it's a valid npm package
76+
$INSTALL_COMMAND "./$tarball_name"

actions/package/README.md

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ![Icon](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItcGFja2FnZSIgY29sb3I9ImJsdWUiPjxsaW5lIHgxPSIxNi41IiB5MT0iOS40IiB4Mj0iNy41IiB5Mj0iNC4yMSI+PC9saW5lPjxwYXRoIGQ9Ik0yMSAxNlY4YTIgMiAwIDAgMC0xLTEuNzNsLTctNGEyIDIgMCAwIDAtMiAwbC03IDRBMiAyIDAgMCAwIDMgOHY4YTIgMiAwIDAgMCAxIDEuNzNsNyA0YTIgMiAwIDAgMCAyIDBsNy00QTIgMiAwIDAgMCAyMSAxNnoiPjwvcGF0aD48cG9seWxpbmUgcG9pbnRzPSIzLjI3IDYuOTYgMTIgMTIuMDEgMjAuNzMgNi45NiI+PC9wb2x5bGluZT48bGluZSB4MT0iMTIiIHkxPSIyMi4wOCIgeDI9IjEyIiB5Mj0iMTIiPjwvbGluZT48L3N2Zz4=) GitHub Action: Package
44

55
<div align="center">
6-
<img src="https://opengraph.githubassets.com/4052526c45e95c104077b40385d28d5c7be5f34d02087973f4ecfd286ed257a5/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Package" />
6+
<img src="https://opengraph.githubassets.com/d1a1e1a571ea2f219133f714e773a06b07d3efc23fa42a8746c3f02c80af02cf/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Package" />
77
</div>
88

99
---
@@ -30,7 +30,7 @@ Action to create and upload an npm package tarball from a Node.js project
3030
## Usage
3131

3232
```yaml
33-
- uses: hoverkraft-tech/ci-github-nodejs/actions/package@775ce0902c528062cc94141dd7d13261083b752a # 0.22.0
33+
- uses: hoverkraft-tech/ci-github-nodejs/actions/package@edadd27d0f6a1b2dd558aec095acb6496aa1916b # main
3434
with:
3535
# Working directory where dependencies are installed for packaging.
3636
# Can be absolute or relative to the repository root.
@@ -67,20 +67,20 @@ Action to create and upload an npm package tarball from a Node.js project
6767
6868
## Inputs
6969
70-
| **Input** | **Description** | **Required** | **Default** |
71-
| ------------------------- | ------------------------------------------------------------------------------------------- | ------------ | ------------------------- |
72-
| **`working-directory`** | Working directory where dependencies are installed for packaging. | **false** | `.` |
73-
| | Can be absolute or relative to the repository root. | | |
74-
| **`package-directory`** | Optional package directory to version and pack. | **false** | - |
75-
| | Can be absolute or relative to `working-directory`. | | |
76-
| | Useful for monorepos where dependencies are installed at the root. | | |
77-
| **`build-artifact-id`** | Optional build artifact ID to download before packaging. | **false** | - |
78-
| | When provided, the artifact will be downloaded to the workspace. | | |
79-
| **`build-artifact-path`** | Optional path to the build artifact contents relative to the workspace root. | **false** | `${{ github.workspace }}` |
80-
| | Used to locate the files to be included in the package when a build artifact is downloaded. | | |
81-
| **`version`** | Optional version to apply with `npm version` before packaging. | **false** | - |
82-
| | The version is applied without creating a Git tag. | | |
83-
| **`artifact-name`** | Name of the uploaded package tarball artifact | **false** | `package-tarball` |
70+
| **Input** | **Description** | **Required** | **Default** |
71+
| ------------------------- | ------------------------------------------------------------------------------------------- | ------------ | --------------------------- |
72+
| **`working-directory`** | Working directory where dependencies are installed for packaging. | **false** | `.` |
73+
| | Can be absolute or relative to the repository root. | | |
74+
| **`package-directory`** | Optional package directory to version and pack. | **false** | - |
75+
| | Can be absolute or relative to `working-directory`. | | |
76+
| | Useful for monorepos where dependencies are installed at the root. | | |
77+
| **`build-artifact-id`** | Optional build artifact ID to download before packaging. | **false** | - |
78+
| | When provided, the artifact will be downloaded to the workspace. | | |
79+
| **`build-artifact-path`** | Optional path to the build artifact contents relative to the workspace root. | **false** | `$\{\{ github.workspace }}` |
80+
| | Used to locate the files to be included in the package when a build artifact is downloaded. | | |
81+
| **`version`** | Optional version to apply with `npm version` before packaging. | **false** | - |
82+
| | The version is applied without creating a Git tag. | | |
83+
| **`artifact-name`** | Name of the uploaded package tarball artifact | **false** | `package-tarball` |
8484

8585
<!-- inputs:end -->
8686
<!-- secrets:start -->
@@ -89,13 +89,37 @@ Action to create and upload an npm package tarball from a Node.js project
8989

9090
## Outputs
9191

92-
| **Output** | **Description** |
93-
| --------------------------------- | ---------------------------------------------- |
94-
| **`package-tarball-path`** | Absolute path to the generated package tarball |
95-
| **`package-tarball-artifact-id`** | Artifact ID of the uploaded package tarball |
92+
| **Output** | **Description** |
93+
| --------------------------------- | --------------------------------------------------------------------------------- |
94+
| **`package-tarball-path`** | Absolute path to the generated package tarball |
95+
| **`package-tarball-artifact-id`** | Artifact ID of the uploaded package tarball (download with skip-decompress: true) |
9696

9797
<!-- outputs:end -->
9898
<!-- examples:start -->
99+
100+
## Examples
101+
102+
```yaml
103+
jobs:
104+
package:
105+
runs-on: ubuntu-latest
106+
outputs:
107+
package-tarball-artifact-id: ${{ steps.package.outputs.package-tarball-artifact-id }}
108+
steps:
109+
- id: package
110+
uses: hoverkraft-tech/ci-github-nodejs/actions/package@edadd27d0f6a1b2dd558aec095acb6496aa1916b # main
111+
112+
consume:
113+
needs: package
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Download package tarball by artifact ID
117+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
118+
with:
119+
artifact-ids: ${{ needs.package.outputs.package-tarball-artifact-id }}
120+
skip-decompress: true
121+
```
122+
99123
<!-- examples:end -->
100124
<!-- contributing:start -->
101125

actions/package/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ outputs:
4747
description: "Absolute path to the generated package tarball"
4848
value: ${{ steps.package.outputs.package-tarball-path }}
4949
package-tarball-artifact-id:
50-
description: "Artifact ID of the uploaded package tarball"
50+
description: "Artifact ID of the uploaded package tarball (download with skip-decompress: true)"
5151
value: ${{ steps.upload-package-tarball.outputs.artifact-id }}
5252

5353
runs:
@@ -169,6 +169,7 @@ runs:
169169
with:
170170
name: ${{ inputs.artifact-name }}
171171
path: ${{ steps.package.outputs.package-tarball-path }}
172+
archive: false
172173
if-no-files-found: error
173174

174175
# FIXME: workaround until will be merged: https://github.com/actions/runner/pull/1684

0 commit comments

Comments
 (0)