Skip to content

Commit c498ecc

Browse files
Copilotneilime
andcommitted
refactor(release): remove build functionality, build is done in CI workflow
Co-authored-by: neilime <[email protected]>
1 parent e711e67 commit c498ecc

File tree

2 files changed

+5
-177
lines changed

2 files changed

+5
-177
lines changed

.github/workflows/release.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
Workflow to release Node.js packages with support for:
2727

28-
- Building the package before publishing
2928
- Generating documentation (optional)
3029
- Publishing to various registries (npm, GitHub Packages)
3130
- Provenance attestation for npm packages
@@ -64,18 +63,11 @@ jobs:
6463
# For npm: Use an npm access token with publish permissions.
6564
# For GitHub Packages: Use `GITHUB_TOKEN` or a PAT with `packages:write` permission.
6665
registry-token: ${{ secrets.NPM_TOKEN }}
67-
68-
# Secrets to be used during the build step (optional).
69-
build-secrets: ""
7066
with:
7167
# JSON array of runner(s) to use.
7268
# Default: `["ubuntu-latest"]`
7369
runs-on: '["ubuntu-latest"]'
7470

75-
# Build parameters. Set to empty string to disable.
76-
# Default: `build`
77-
build: build
78-
7971
# Documentation generation parameters.
8072
# Set to empty string or `false` to disable.
8173
docs: ""
@@ -120,10 +112,6 @@ jobs:
120112
| ----------------------- | ---------------------------------------------------------------------------------- | ------------ | ----------- | ------------------- |
121113
| **`runs-on`** | JSON array of runner(s) to use. | **false** | **string** | `["ubuntu-latest"]` |
122114
| | See <https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job>. | | | |
123-
| **`build`** | Build parameters. Must be a string or a JSON object. | **false** | **string** | `build` |
124-
| | Set to empty string to disable build step. | | | |
125-
| | For string, provide a list of commands to run during the build step, one per line. | | | |
126-
| | For JSON object, provide `commands` array, optional `env` object, and `artifact`. | | | |
127115
| **`docs`** | Documentation generation parameters. | **false** | **string** | - |
128116
| | Set to empty string or `false` to disable. | | | |
129117
| | Set to `true` for default command (`docs`). | | | |
@@ -152,21 +140,18 @@ jobs:
152140
| **`registry-token`** | Authentication token for the registry. | **true** |
153141
| | For npm: Use an npm access token with publish permissions. | |
154142
| | For GitHub Packages: Use `GITHUB_TOKEN` or a PAT with `packages:write` permission. | |
155-
| **`build-secrets`** | Secrets to be used during the build step. | **false** |
156-
| | Must be a multi-line env formatted string. | |
157143

158144
<!-- secrets:end -->
159145

160146
<!-- outputs:start -->
161147

162148
## Outputs
163149

164-
| **Output** | **Description** |
165-
| ----------------------- | ----------------------------------------------- |
166-
| **`version`** | The version of the published package. |
167-
| **`package-name`** | The name of the published package. |
168-
| **`build-artifact-id`** | ID of the build artifact (if uploaded). |
169-
| **`docs-artifact-id`** | ID of the documentation artifact (if uploaded). |
150+
| **Output** | **Description** |
151+
| ---------------------- | ----------------------------------------------- |
152+
| **`version`** | The version of the published package. |
153+
| **`package-name`** | The name of the published package. |
154+
| **`docs-artifact-id`** | ID of the documentation artifact (if uploaded). |
170155

171156
<!-- outputs:end -->
172157

@@ -348,13 +333,6 @@ jobs:
348333
registry-token: ${{ secrets.NPM_TOKEN }}
349334
with:
350335
working-directory: packages/my-package
351-
build: |
352-
{
353-
"commands": ["build"],
354-
"env": {
355-
"NODE_ENV": "production"
356-
}
357-
}
358336
```
359337

360338
<!-- examples:end -->

.github/workflows/release.yml

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Workflow to release Node.js packages:
22
#
3-
# - Build (optional)
43
# - Generate documentation (optional)
54
# - Publish to registry (npm, GitHub Packages)
65

@@ -16,36 +15,6 @@ on:
1615
type: string
1716
default: '["ubuntu-latest"]'
1817
required: false
19-
build:
20-
description: |
21-
Build parameters. Must be a string or a JSON object.
22-
Set to empty string to disable build step.
23-
For string, provide a list of commands to run during the build step, one per line.
24-
For JSON object, provide the following properties:
25-
26-
- `commands`: Array of commands to run during the build step.
27-
- `env`: Object of environment variables to set during the build step.
28-
- `artifact`: String or array of strings specifying paths to artifacts to upload after the build.
29-
30-
Example:
31-
```json
32-
{
33-
"commands": [
34-
"build",
35-
"generate-artifacts"
36-
],
37-
"env": {
38-
"NODE_ENV": "production"
39-
},
40-
"artifact": [
41-
"dist/",
42-
"packages/package-a/build/"
43-
]
44-
}
45-
```
46-
type: string
47-
required: false
48-
default: "build"
4918
docs:
5019
description: |
5120
Documentation generation parameters.
@@ -143,25 +112,13 @@ on:
143112
For npm: Use an npm access token with publish permissions.
144113
For GitHub Packages: Use `GITHUB_TOKEN` or a PAT with `packages:write` permission.
145114
required: true
146-
build-secrets:
147-
description: |
148-
Secrets to be used during the build step.
149-
Must be a multi-line env formatted string.
150-
Example:
151-
```txt
152-
SECRET_EXAMPLE=$\{{ secrets.SECRET_EXAMPLE }}
153-
```
154-
required: false
155115
outputs:
156116
version:
157117
description: "The version of the published package."
158118
value: ${{ jobs.release.outputs.version }}
159119
package-name:
160120
description: "The name of the published package."
161121
value: ${{ jobs.release.outputs.package-name }}
162-
build-artifact-id:
163-
description: "ID of the build artifact (if uploaded)."
164-
value: ${{ jobs.release.outputs.build-artifact-id }}
165122
docs-artifact-id:
166123
description: "ID of the documentation artifact (if uploaded)."
167124
value: ${{ jobs.release.outputs.docs-artifact-id }}
@@ -176,9 +133,6 @@ jobs:
176133
outputs:
177134
registry-url: ${{ steps.parse-registry.outputs.registry-url }}
178135
registry-scope: ${{ steps.parse-registry.outputs.registry-scope }}
179-
build-commands: ${{ steps.parse-build.outputs.commands }}
180-
build-env: ${{ steps.parse-build.outputs.env }}
181-
build-artifact: ${{ steps.parse-build.outputs.artifact }}
182136
docs-command: ${{ steps.parse-docs.outputs.command }}
183137
docs-output: ${{ steps.parse-docs.outputs.output }}
184138
docs-artifact: ${{ steps.parse-docs.outputs.artifact }}
@@ -231,98 +185,6 @@ jobs:
231185
core.setOutput('registry-url', registryUrl);
232186
core.setOutput('registry-scope', registryScope);
233187
234-
- id: parse-build
235-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
236-
env:
237-
BUILD_INPUT: ${{ inputs.build }}
238-
WORKING_DIRECTORY: ${{ inputs.working-directory }}
239-
with:
240-
script: |
241-
const path = require('node:path');
242-
243-
const buildInput = process.env.BUILD_INPUT.trim();
244-
const workingDirectory = process.env.WORKING_DIRECTORY || '.';
245-
246-
if (!buildInput) {
247-
core.info('Build step disabled');
248-
return;
249-
}
250-
251-
let commands = [];
252-
let env = {};
253-
254-
// Build commands is a list of command(s), one per line
255-
const buildCommandsIsList = !buildInput.startsWith('{') && !buildInput.startsWith('[');
256-
if (buildCommandsIsList) {
257-
commands = buildInput.split('\n').map(command => command.trim()).filter(Boolean);
258-
} else {
259-
let build;
260-
try {
261-
build = JSON.parse(buildInput);
262-
} catch (error) {
263-
return core.setFailed(`Failed to parse build input as JSON: ${error.message}`);
264-
}
265-
266-
// Build commands is a JSON array of commands
267-
if (Array.isArray(build)) {
268-
commands = build;
269-
}
270-
// Build commands is a JSON object
271-
else {
272-
commands = build.commands ?? ['build'];
273-
env = build.env ?? {};
274-
275-
if (build.artifact) {
276-
let buildArtifact = build.artifact;
277-
278-
if (typeof buildArtifact === 'string' || Array.isArray(buildArtifact)) {
279-
buildArtifact = {
280-
paths: buildArtifact
281-
};
282-
}
283-
284-
if (typeof buildArtifact.paths === 'string') {
285-
buildArtifact.paths = buildArtifact.paths.split('\n');
286-
} else if (!Array.isArray(buildArtifact.paths)) {
287-
return core.setFailed('Build artifact paths must be a string or an array of strings');
288-
}
289-
290-
buildArtifact.paths = buildArtifact.paths
291-
.map(artifact => artifact.trim())
292-
.filter(Boolean)
293-
.map(artifact => {
294-
// FIXME: Workaround to preserve full path to artifact
295-
const fullpath = artifact.startsWith('/') ? artifact : path.join(workingDirectory, artifact);
296-
297-
// Add a wildcard to the first folder of the path
298-
return fullpath.replace(/\/([^/]+)/, '/*$1');
299-
}).join('\n');
300-
301-
if (!buildArtifact.paths) {
302-
return core.setFailed('No valid build artifact paths found');
303-
}
304-
305-
// Generate a unique name for the artifact
306-
buildArtifact.name = `${process.env.GITHUB_JOB}-build-${process.env.GITHUB_RUN_ID}-${Math.random().toString(36).substring(2, 8)}`;
307-
308-
core.setOutput('artifact', JSON.stringify(buildArtifact));
309-
}
310-
}
311-
}
312-
313-
if (commands.some(command => typeof command !== 'string')) {
314-
return core.setFailed('Build commands array must only contain strings');
315-
}
316-
317-
const sanitizedCommands = commands.map(command => command.trim()).filter(Boolean);
318-
if (!sanitizedCommands.length) {
319-
core.info('No build commands specified');
320-
return;
321-
}
322-
323-
core.setOutput('commands', sanitizedCommands.join('\n'));
324-
core.setOutput('env', JSON.stringify(env));
325-
326188
- id: parse-docs
327189
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
328190
env:
@@ -376,7 +238,6 @@ jobs:
376238
outputs:
377239
version: ${{ steps.package-info.outputs.version }}
378240
package-name: ${{ steps.package-info.outputs.name }}
379-
build-artifact-id: ${{ steps.build.outputs.artifact-id }}
380241
docs-artifact-id: ${{ steps.upload-docs.outputs.artifact-id }}
381242
steps:
382243
- uses: hoverkraft-tech/ci-github-common/actions/checkout@5ac504609f6ef35c5ac94bd8199063aa32104721 # 0.31.3
@@ -432,17 +293,6 @@ jobs:
432293
core.setOutput('name', name);
433294
core.setOutput('version', version);
434295
435-
- name: Build
436-
id: build
437-
if: needs.prepare.outputs.build-commands != ''
438-
uses: ./self-workflow/actions/build
439-
with:
440-
working-directory: ${{ inputs.working-directory }}
441-
build-commands: ${{ needs.prepare.outputs.build-commands }}
442-
build-env: ${{ needs.prepare.outputs.build-env || '{}' }}
443-
build-secrets: ${{ secrets.build-secrets }}
444-
build-artifact: ${{ needs.prepare.outputs.build-artifact }}
445-
446296
- name: Generate documentation
447297
if: needs.prepare.outputs.docs-command != ''
448298
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0

0 commit comments

Comments
 (0)