Skip to content

Commit edb5946

Browse files
committed
feat(release): support workspace releases and package validation
Add workspace discovery, Lerna version planning, isolated package validation, and artifact-based publication with recovery. Reuse shared quality and release verification actions and document the supported workflows. BREAKING CHANGE: Use the string package configuration instead of separate package inputs. Use ci-github-common/actions/quality/codecov for standalone coverage uploads.
1 parent aaab44d commit edb5946

67 files changed

Lines changed: 9369 additions & 957 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/__greetings.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions: {}
1010

1111
jobs:
1212
greetings:
13-
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@44f6108cef0e9884ea7735f3d62932c2310745d4 # 0.39.1
13+
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0
1414
permissions:
1515
contents: read
1616
issues: write

‎.github/workflows/__main-ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
release:
3636
needs: ci
3737
if: github.event_name != 'schedule'
38-
uses: hoverkraft-tech/ci-github-publish/.github/workflows/release-actions.yml@ea6682de88070c254dac619a6623a242a6d57cd3 # 1.0.3
38+
uses: hoverkraft-tech/ci-github-publish/.github/workflows/release-actions.yml@f06e0e72a76bfca57c34d08d03e5c1914275fd4c # 2.0.0
3939
permissions:
4040
contents: read
4141
with:

‎.github/workflows/__need-fix-to-issue.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ permissions: {}
1818

1919
jobs:
2020
main:
21-
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@44f6108cef0e9884ea7735f3d62932c2310745d4 # 0.39.1
21+
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0
2222
permissions:
2323
contents: read
2424
issues: write

‎.github/workflows/__prepare-release.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions: {}
1010

1111
jobs:
1212
release:
13-
uses: hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml@ea6682de88070c254dac619a6623a242a6d57cd3 # 1.0.3
13+
uses: hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml@f06e0e72a76bfca57c34d08d03e5c1914275fd4c # 2.0.0
1414
permissions:
1515
contents: read
1616
pull-requests: write

‎.github/workflows/__release.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ jobs:
5353

5454
- name: Plan release
5555
id: plan-release
56-
uses: hoverkraft-tech/ci-github-publish/actions/release/plan@ea6682de88070c254dac619a6623a242a6d57cd3 # 1.0.3
56+
uses: hoverkraft-tech/ci-github-publish/actions/release/plan@f06e0e72a76bfca57c34d08d03e5c1914275fd4c # 2.0.0
5757
with:
5858
target-sha: ${{ github.sha }}
5959
github-token: ${{ steps.generate-token.outputs.token }}
6060

6161
- name: Create and publish release
6262
if: (steps.plan-release.outputs.has-changes == 'true' || (github.event_name == 'workflow_dispatch' && inputs.force)) && steps.plan-release.outputs.tag != ''
63-
uses: hoverkraft-tech/ci-github-publish/actions/release/create@ea6682de88070c254dac619a6623a242a6d57cd3 # 1.0.3
63+
uses: hoverkraft-tech/ci-github-publish/actions/release/create@f06e0e72a76bfca57c34d08d03e5c1914275fd4c # 2.0.0
6464
env:
6565
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} # zizmor: ignore[secrets-outside-env] repository secret is scoped to the release summary step
6666
with:

‎.github/workflows/__semantic-pull-request.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions: {}
1212

1313
jobs:
1414
main:
15-
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@44f6108cef0e9884ea7735f3d62932c2310745d4 # 0.39.1
15+
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0
1616
permissions:
1717
contents: write
1818
pull-requests: write

‎.github/workflows/__shared-ci.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions: {}
77

88
jobs:
99
linter:
10-
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@44f6108cef0e9884ea7735f3d62932c2310745d4 # 0.39.1
10+
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0
1111
permissions:
1212
actions: read
1313
contents: read
@@ -56,6 +56,20 @@ jobs:
5656
permissions:
5757
contents: read
5858

59+
test-action-package-test:
60+
name: Test action "package/test"
61+
needs: linter
62+
uses: $/.github/workflows/__test-action-package-test.yml
63+
permissions:
64+
contents: read
65+
66+
test-action-package-discover:
67+
name: Test action "package/discover"
68+
needs: linter
69+
uses: $/.github/workflows/__test-action-package-discover.yml
70+
permissions:
71+
contents: read
72+
5973
test-action-setup-node:
6074
name: Test action "setup-node"
6175
needs: linter

‎.github/workflows/__stale.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ permissions: {}
88

99
jobs:
1010
main:
11-
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@44f6108cef0e9884ea7735f3d62932c2310745d4 # 0.39.1
11+
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0
1212
permissions:
1313
issues: write
1414
pull-requests: write
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Internal - Tests for "package/discover" action
2+
3+
on:
4+
workflow_call:
5+
6+
permissions: {}
7+
8+
jobs:
9+
discover:
10+
name: Package discovery (${{ matrix.fixture.name }})
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
fixture:
18+
- name: standalone npm
19+
root: { private: false }
20+
expected: ["."]
21+
- name: npm workspaces and exclusions
22+
root:
23+
private: true
24+
workspaces: [packages/*, "!packages/excluded"]
25+
expected: [packages/cli, packages/core]
26+
- name: workspace root is not implicitly packaged
27+
root:
28+
private: false
29+
workspaces: [packages/core]
30+
expected: [packages/core]
31+
- name: Yarn workspace object
32+
manager: yarn
33+
root:
34+
workspaces: { packages: [packages/*, "!packages/excluded"] }
35+
expected: [packages/cli, packages/core]
36+
- name: pnpm workspaces
37+
manager: pnpm
38+
files:
39+
pnpm-workspace.yaml: |
40+
packages:
41+
- 'packages/*'
42+
- '!packages/excluded'
43+
expected: [packages/cli, packages/core]
44+
- name: pnpm 10 workspaces
45+
manager: pnpm10
46+
files:
47+
pnpm-workspace.yaml: |
48+
packages:
49+
- 'packages/*'
50+
- '!packages/excluded'
51+
expected: [packages/cli, packages/core]
52+
- name: standalone pnpm with settings
53+
manager: pnpm
54+
root: { private: false }
55+
files:
56+
pnpm-workspace.yaml: "packages: []"
57+
expected: ["."]
58+
- name: Lerna package patterns take precedence
59+
root: { workspaces: [packages/excluded] }
60+
files:
61+
lerna.json: '{"version":"independent","packages":["packages/*","!packages/excluded"]}'
62+
expected: [packages/cli, packages/core]
63+
- name: explicit subset
64+
root: { workspaces: [packages/*] }
65+
directories: '["packages/core"]'
66+
expected: [packages/core]
67+
- name: explicit root
68+
root: { private: false, workspaces: [packages/*] }
69+
directories: '["."]'
70+
expected: ["."]
71+
- name: private standalone
72+
expected: failure
73+
- name: private workspaces only
74+
root: { workspaces: [packages/private] }
75+
expected: failure
76+
- name: unmatched workspaces
77+
root: { workspaces: [missing/*] }
78+
expected: failure
79+
- name: explicit private package
80+
directories: '["packages/private"]'
81+
expected: failure
82+
- name: empty override
83+
directories: "[]"
84+
expected: failure
85+
- name: invalid override
86+
directories: '{"directory":"packages/core"}'
87+
expected: failure
88+
- name: escaping directory
89+
directories: '["../outside"]'
90+
expected: failure
91+
- name: duplicate normalized directories
92+
directories: '["packages/core", "./packages/core/"]'
93+
expected: failure
94+
- name: symlink outside the project
95+
directories: '["linked"]'
96+
expected: failure
97+
steps:
98+
- name: Arrange - Checkout
99+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
100+
with:
101+
persist-credentials: false
102+
- name: Arrange - Create uninstalled project fixtures
103+
id: fixture
104+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
105+
env:
106+
FIXTURE: ${{ toJSON(matrix.fixture) }}
107+
with:
108+
script: |
109+
const fs = require('node:fs');
110+
const path = require('node:path');
111+
const fixture = JSON.parse(process.env.FIXTURE);
112+
const temporary = fs.mkdtempSync(path.join(process.env.RUNNER_TEMP, 'package-discovery-'));
113+
const directory = path.join(temporary, 'project');
114+
const write = async (file, content) => {
115+
const target = path.join(directory, file);
116+
await io.mkdirP(path.dirname(target));
117+
fs.writeFileSync(target, typeof content === 'string' ? content : JSON.stringify(content));
118+
};
119+
const manifest = { name: 'discovery-root', version: '1.0.0', private: true, ...fixture.root,
120+
scripts: { preinstall: 'exit 91', postinstall: 'exit 91', prepare: 'exit 91' } };
121+
if (fixture.manager?.startsWith('pnpm')) {
122+
const lock = JSON.parse(fs.readFileSync('actions/release/prepare/package-lock.json', 'utf8'));
123+
manifest.packageManager = `pnpm@${lock.packages[`node_modules/${fixture.manager}`].version}`;
124+
await write('pnpm-lock.yaml', "lockfileVersion: '9.0'\n");
125+
} else if (fixture.manager === 'yarn') {
126+
await write('yarn.lock', '# yarn lockfile v1\n');
127+
} else {
128+
await write('package-lock.json', { name: manifest.name, version: manifest.version, lockfileVersion: 3, packages: { '': manifest } });
129+
}
130+
await write('package.json', manifest);
131+
await write('.node-version', fs.readFileSync('.node-version', 'utf8'));
132+
for (const name of ['core', 'cli', 'private', 'excluded']) {
133+
await write(`packages/${name}/package.json`, { name: `@example/${name}`, version: '1.0.0', private: name === 'private', scripts: manifest.scripts });
134+
}
135+
await write('examples/unconfigured/package.json', { name: 'unconfigured', version: '1.0.0' });
136+
for (const [file, content] of Object.entries(fixture.files || {})) await write(file, content);
137+
await io.mkdirP(path.join(temporary, 'outside'));
138+
fs.writeFileSync(path.join(temporary, 'outside/package.json'), JSON.stringify({ name: 'outside', version: '1.0.0' }));
139+
fs.symlinkSync(path.join(temporary, 'outside'), path.join(directory, 'linked'), 'dir');
140+
core.setOutput('directory', directory);
141+
const lockfile = fixture.manager?.startsWith('pnpm') ? 'pnpm-lock.yaml' : fixture.manager === 'yarn' ? 'yarn.lock' : 'package-lock.json';
142+
core.setOutput('lockfile', path.join(directory, lockfile));
143+
core.setOutput('lock-content', fs.readFileSync(path.join(directory, lockfile), 'utf8'));
144+
- name: Act - Discover packages without installing dependencies
145+
id: discover
146+
continue-on-error: true
147+
uses: $/actions/package/discover
148+
with:
149+
working-directory: ${{ steps.fixture.outputs.directory }}
150+
directories: ${{ matrix.fixture.directories || '' }}
151+
- name: Assert - Selection and dependency installation
152+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
153+
env:
154+
EXPECTED: ${{ toJSON(matrix.fixture.expected) }}
155+
OUTCOME: ${{ steps.discover.outcome }}
156+
DIRECTORIES: ${{ steps.discover.outputs.directories }}
157+
PROJECT: ${{ steps.fixture.outputs.directory }}
158+
LOCKFILE: ${{ steps.fixture.outputs.lockfile }}
159+
LOCK_CONTENT: ${{ steps.fixture.outputs.lock-content }}
160+
with:
161+
script: |
162+
const assert = require('node:assert/strict');
163+
const fs = require('node:fs');
164+
const path = require('node:path');
165+
const expected = JSON.parse(process.env.EXPECTED);
166+
assert.equal(process.env.OUTCOME, expected === 'failure' ? 'failure' : 'success');
167+
if (expected !== 'failure') assert.deepEqual(JSON.parse(process.env.DIRECTORIES), expected);
168+
const installed = await (await glob.create(`${process.env.PROJECT}/**/node_modules`, { followSymbolicLinks: false })).glob();
169+
assert.deepEqual(installed, []);
170+
assert.equal(fs.existsSync(path.join(process.env.PROJECT, 'package.tgz')), false);
171+
assert.equal(fs.readFileSync(process.env.LOCKFILE, 'utf8'), process.env.LOCK_CONTENT);

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
contents: read
1414
outputs:
1515
package-tarball-artifact-id: ${{ steps.package.outputs.package-tarball-artifact-id }}
16+
published-version-artifact-id: ${{ steps.published-version.outputs.package-tarball-artifact-id }}
1617
steps:
1718
- name: Arrange - Checkout sources
1819
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -31,6 +32,24 @@ jobs:
3132
with:
3233
working-directory: tests/npm
3334

35+
- id: published-fixture
36+
name: Arrange - Use an existing npm name and version
37+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
38+
with:
39+
script: |
40+
const fs = require('node:fs');
41+
const path = require('node:path');
42+
const { stdout } = await exec.getExecOutput('npm', ['--version'], { silent: true });
43+
const version = stdout.trim();
44+
const directory = fs.mkdtempSync(path.join(process.env.RUNNER_TEMP, 'published-version-'));
45+
fs.writeFileSync(path.join(directory, 'package.json'), JSON.stringify({ name: 'npm', version, packageManager: `npm@${version}` }));
46+
core.setOutput('directory', directory);
47+
- id: published-version
48+
name: Arrange - Pack the existing-version fixture
49+
uses: $/actions/package/create
50+
with:
51+
working-directory: ${{ steps.published-fixture.outputs.directory }}
52+
3453
publish:
3554
name: Publish dry run (${{ matrix.os }}, ${{ matrix.tag || 'default tag' }})
3655
needs: package
@@ -57,6 +76,13 @@ jobs:
5776
dry-run: "true"
5877
provenance: "false"
5978

79+
- name: Act - Validate an already-published version without publishing
80+
uses: $/actions/package/publish
81+
with:
82+
package-tarball-artifact-id: ${{ needs.package.outputs.published-version-artifact-id }}
83+
dry-run: "true"
84+
provenance: "false"
85+
6086
- id: invalid-artifact
6187
name: Act - Reject multiple artifact IDs
6288
continue-on-error: true

0 commit comments

Comments
 (0)