Skip to content

Commit 4277afd

Browse files
committed
Merge branch 'main' into ts-fixes-npmlog
2 parents 7b7e76f + 5646a45 commit 4277afd

12 files changed

Lines changed: 1064 additions & 234 deletions

File tree

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030

3131
- uses: nrwl/nx-set-shas@v4
3232

33+
- name: Start Nx Cloud CI Run - Linux
34+
run: npx nx-cloud start-ci-run --stop-agents-after="e2e"
35+
3336
- name: Install primary node version (see volta config in package.json) and dependencies
3437
uses: ./.github/actions/install-node-and-dependencies
3538

@@ -66,6 +69,35 @@ jobs:
6669
git config --global user.email test@example.com
6770
git config --global user.name "Tester McPerson"
6871
72+
- name: Generate and configure GPG for signing commits and tags in E2E tests
73+
run: |
74+
# Generate a GPG key for test@example.com and store the output from stderr
75+
GPG_OUTPUT=$(echo "Key-Type: default
76+
Key-Length: 2048
77+
Subkey-Type: default
78+
Subkey-Length: 2048
79+
Name-Real: Tester McPerson
80+
Name-Email: test@example.com
81+
Expire-Date: 0
82+
%no-protection" | gpg --pinentry-mode loopback --batch --generate-key 2>&1)
83+
84+
# Find and extract the revocation file path from sdterr
85+
REVOCATION_FILE=$(echo "$GPG_OUTPUT" | grep '.rev' | tr '\n' ' ' | awk -F "'" '{print $4}')
86+
87+
# Get the GPG key ID and the full fingerprint
88+
export GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)
89+
export GPG_FULL_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep "$GPG_KEY_ID" | grep -v "sec" | awk '{print $1}' | cut -d'/' -f2)
90+
91+
# Export fingerprint and the path to the revocation file to GITHUB_ENV
92+
# This allows the last step in this job to revoke and delete the key
93+
echo "GPG_FULL_KEY_ID=$GPG_FULL_KEY_ID" >> $GITHUB_ENV
94+
echo "REVOCATION_FILE=$REVOCATION_FILE" >> $GITHUB_ENV
95+
96+
# Setup git signing for commits and tags
97+
git config commit.gpgsign true
98+
git config tag.gpgsign true
99+
git config --global user.signingkey $GPG_KEY_ID
100+
69101
- name: Install primary node version (see volta config in package.json) and dependencies
70102
uses: ./.github/actions/install-node-and-dependencies
71103

@@ -74,6 +106,17 @@ jobs:
74106
env:
75107
NX_AGENT_NAME: ${{ matrix.agent }}
76108

109+
- name: Revoke and delete GPG key
110+
# It's important that we always run this step, otherwise the key will remain active if any of the steps above fail
111+
if: ${{ always() }}
112+
run: |
113+
# As instructed in the text of revocation file, there is a colon that needs to be removed manually
114+
sed -i "s/:-----BEGIN PGP PUBLIC KEY BLOCK-----/-----BEGIN PGP PUBLIC KEY BLOCK-----/" $REVOCATION_FILE
115+
116+
# Revoke the key and delete it
117+
gpg --yes --import $REVOCATION_FILE
118+
gpg --batch --yes --delete-secret-and-public-key $GPG_FULL_KEY_ID
119+
77120
windows-main:
78121
name: Nx Cloud - Windows Main Job
79122
runs-on: windows-latest
@@ -86,6 +129,9 @@ jobs:
86129
steps:
87130
- uses: actions/checkout@v4
88131

132+
- name: Start Nx Cloud CI Run - Windows
133+
run: npx nx-cloud start-ci-run --stop-agents-after="test"
134+
89135
- name: Install primary node version (see volta config in package.json) and dependencies
90136
uses: ./.github/actions/install-node-and-dependencies
91137

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [8.0.1](https://github.com/lerna/lerna/compare/v8.0.0...v8.0.1) (2023-12-15)
7+
8+
### Bug Fixes
9+
10+
- update node-gyp usage to v10 to resolve npm warning ([#3919](https://github.com/lerna/lerna/issues/3919)) ([f5fdcba](https://github.com/lerna/lerna/commit/f5fdcba1ef53fa8d779dcaf6c617cba3461f343c))
11+
- **version:** create correct independent tags when using --sign-git-tag ([#3917](https://github.com/lerna/lerna/issues/3917)) ([8f7a32b](https://github.com/lerna/lerna/commit/8f7a32b519ba64fd3d608c6211d0e74d651f2e13))
12+
613
## BREAKING CHANGES
714

815
> After updating we strongly recommend running `lerna repair` in your project. This will migrate your `lerna.json` to the latest and greatest and remove any outdated options.
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
import { Fixture, normalizeCommitSHAs, normalizeEnvironment } from "@lerna/e2e-utils";
2+
3+
expect.addSnapshotSerializer({
4+
serialize(str: string) {
5+
return normalizeCommitSHAs(normalizeEnvironment(str));
6+
},
7+
test(val: string) {
8+
return val != null && typeof val === "string";
9+
},
10+
});
11+
12+
/**
13+
* NOTE: This test suite should only execute in CI/CD.
14+
* The reason is that using the `--sign-git-tag` flag requires a GPG key to be present on the machine,
15+
* which is not a guarantee in a local development environment.
16+
*/
17+
const describeFunc = process.env.CI === "true" ? describe : describe.skip;
18+
19+
describeFunc("lerna-version-sign-git-tag", () => {
20+
describe("single package", () => {
21+
let fixture: Fixture;
22+
23+
beforeEach(async () => {
24+
fixture = await Fixture.create({
25+
e2eRoot: process.env.E2E_ROOT,
26+
name: "lerna-version-sign-git-tag",
27+
packageManager: "npm",
28+
initializeGit: true,
29+
lernaInit: { args: [`--packages="packages/*"`] },
30+
installDependencies: true,
31+
});
32+
await fixture.lerna("create package-a -y");
33+
await fixture.createInitialGitCommit();
34+
await fixture.exec("git push origin test-main");
35+
});
36+
afterEach(() => fixture.destroy());
37+
38+
it("should create tags that match version when not using --sign-git-tag", async () => {
39+
const output = await fixture.lerna("version 3.3.3 -y");
40+
41+
expect(output.combinedOutput).toMatchInlineSnapshot(`
42+
lerna notice cli v999.9.9-e2e.0
43+
lerna info current version 0.0.0
44+
lerna info Assuming all packages changed
45+
46+
Changes:
47+
- package-a: 0.0.0 => 3.3.3
48+
49+
lerna info auto-confirmed
50+
lerna info execute Skipping releases
51+
lerna info git Pushing tags...
52+
lerna success version finished
53+
54+
`);
55+
56+
const checkTagIsPresentLocally = await fixture.exec("git describe --abbrev=0");
57+
58+
expect(checkTagIsPresentLocally.combinedOutput).toMatchInlineSnapshot(`
59+
v3.3.3
60+
61+
`);
62+
63+
const checkTagIsPresentOnRemote = await fixture.exec("git ls-remote origin refs/tags/v3.3.3");
64+
65+
expect(checkTagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
66+
{FULL_COMMIT_SHA} refs/tags/v3.3.3
67+
68+
`);
69+
});
70+
71+
it("should create tags that match version when using --sign-git-tag", async () => {
72+
const output = await fixture.lerna("version 3.4.5 --sign-git-tag -y");
73+
expect(output.combinedOutput).toMatchInlineSnapshot(`
74+
lerna notice cli v999.9.9-e2e.0
75+
lerna info current version 0.0.0
76+
lerna info Assuming all packages changed
77+
78+
Changes:
79+
- package-a: 0.0.0 => 3.4.5
80+
81+
lerna info auto-confirmed
82+
lerna info execute Skipping releases
83+
lerna info git Pushing tags...
84+
lerna success version finished
85+
86+
`);
87+
88+
const checkTagIsPresentLocally = await fixture.exec("git describe --abbrev=0");
89+
expect(checkTagIsPresentLocally.combinedOutput).toMatchInlineSnapshot(`
90+
v3.4.5
91+
92+
`);
93+
94+
const checkTagIsPresentOnRemote = await fixture.exec("git ls-remote origin refs/tags/v3.4.5");
95+
expect(checkTagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
96+
{FULL_COMMIT_SHA} refs/tags/v3.4.5
97+
98+
`);
99+
});
100+
});
101+
102+
describe("multiple packages", () => {
103+
let fixture: Fixture;
104+
105+
beforeEach(async () => {
106+
fixture = await Fixture.create({
107+
e2eRoot: process.env.E2E_ROOT,
108+
name: "lerna-version-sign-git-tag-multiple-packages",
109+
packageManager: "npm",
110+
initializeGit: true,
111+
lernaInit: { args: [`--packages="packages/*"`] },
112+
installDependencies: true,
113+
});
114+
await fixture.lerna("create package-a -y");
115+
await fixture.lerna("create package-b -y");
116+
await fixture.createInitialGitCommit();
117+
await fixture.exec("git push origin test-main");
118+
});
119+
afterEach(() => fixture.destroy());
120+
121+
it("should create tags that match version when not using --sign-git-tag", async () => {
122+
const output = await fixture.lerna("version 3.3.3 -y");
123+
124+
expect(output.combinedOutput).toMatchInlineSnapshot(`
125+
lerna notice cli v999.9.9-e2e.0
126+
lerna info current version 0.0.0
127+
lerna info Assuming all packages changed
128+
129+
Changes:
130+
- package-a: 0.0.0 => 3.3.3
131+
- package-b: 0.0.0 => 3.3.3
132+
133+
lerna info auto-confirmed
134+
lerna info execute Skipping releases
135+
lerna info git Pushing tags...
136+
lerna success version finished
137+
138+
`);
139+
140+
const checkTagIsPresentLocally = await fixture.exec("git describe --abbrev=0");
141+
142+
expect(checkTagIsPresentLocally.combinedOutput).toMatchInlineSnapshot(`
143+
v3.3.3
144+
145+
`);
146+
147+
const checkTagIsPresentOnRemote = await fixture.exec("git ls-remote origin refs/tags/v3.3.3");
148+
149+
expect(checkTagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
150+
{FULL_COMMIT_SHA} refs/tags/v3.3.3
151+
152+
`);
153+
});
154+
155+
it("should create tags that match version when using --sign-git-tag", async () => {
156+
const output = await fixture.lerna("version 3.4.5 --sign-git-tag -y");
157+
expect(output.combinedOutput).toMatchInlineSnapshot(`
158+
lerna notice cli v999.9.9-e2e.0
159+
lerna info current version 0.0.0
160+
lerna info Assuming all packages changed
161+
162+
Changes:
163+
- package-a: 0.0.0 => 3.4.5
164+
- package-b: 0.0.0 => 3.4.5
165+
166+
lerna info auto-confirmed
167+
lerna info execute Skipping releases
168+
lerna info git Pushing tags...
169+
lerna success version finished
170+
171+
`);
172+
173+
const checkTagIsPresentLocally = await fixture.exec("git describe --abbrev=0");
174+
expect(checkTagIsPresentLocally.combinedOutput).toMatchInlineSnapshot(`
175+
v3.4.5
176+
177+
`);
178+
179+
const checkTagIsPresentOnRemote = await fixture.exec("git ls-remote origin refs/tags/v3.4.5");
180+
expect(checkTagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
181+
{FULL_COMMIT_SHA} refs/tags/v3.4.5
182+
183+
`);
184+
});
185+
});
186+
187+
describe("independent packages", () => {
188+
let fixture: Fixture;
189+
190+
beforeEach(async () => {
191+
fixture = await Fixture.create({
192+
e2eRoot: process.env.E2E_ROOT,
193+
name: "lerna-version-sign-git-tag-multiple-packages",
194+
packageManager: "npm",
195+
initializeGit: true,
196+
lernaInit: { args: [`--packages="packages/*" --independent`] },
197+
installDependencies: true,
198+
});
199+
await fixture.lerna("create package-a -y");
200+
await fixture.lerna("create package-b -y");
201+
await fixture.createInitialGitCommit();
202+
await fixture.exec("git push origin test-main");
203+
});
204+
afterEach(() => fixture.destroy());
205+
206+
it("should create tags that match version when not using --sign-git-tag", async () => {
207+
const output = await fixture.lerna("version 3.3.3 -y");
208+
209+
// NOTE: In the independent case, lerna started with version 1.0.0 as its assumed baseline (not 0.0.0 as in the fixed mode case)
210+
expect(output.combinedOutput).toMatchInlineSnapshot(`
211+
lerna notice cli v999.9.9-e2e.0
212+
lerna info versioning independent
213+
lerna info Assuming all packages changed
214+
215+
Changes:
216+
- package-a: 1.0.0 => 3.3.3
217+
- package-b: 1.0.0 => 3.3.3
218+
219+
lerna info auto-confirmed
220+
lerna info execute Skipping releases
221+
lerna info git Pushing tags...
222+
lerna success version finished
223+
224+
`);
225+
226+
// It should create one tag for each independently versioned package
227+
const checkPackageTagsArePresentLocally = await fixture.exec("git describe --abbrev=0");
228+
expect(checkPackageTagsArePresentLocally.combinedOutput).toMatchInlineSnapshot(`
229+
package-a@3.3.3
230+
231+
`);
232+
233+
const checkPackageATagIsPresentOnRemote = await fixture.exec(
234+
"git ls-remote origin refs/tags/package-a@3.3.3"
235+
);
236+
expect(checkPackageATagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
237+
{FULL_COMMIT_SHA} refs/tags/package-a@3.3.3
238+
239+
`);
240+
const checkPackageBTagIsPresentOnRemote = await fixture.exec(
241+
"git ls-remote origin refs/tags/package-b@3.3.3"
242+
);
243+
expect(checkPackageBTagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
244+
{FULL_COMMIT_SHA} refs/tags/package-b@3.3.3
245+
246+
`);
247+
});
248+
249+
it("should create tags that match version when using --sign-git-tag", async () => {
250+
const output = await fixture.lerna("version 3.4.5 --sign-git-tag -y");
251+
252+
// NOTE: In the independent case, lerna started with version 1.0.0 as its assumed baseline (not 0.0.0 as in the fixed mode case)
253+
expect(output.combinedOutput).toMatchInlineSnapshot(`
254+
lerna notice cli v999.9.9-e2e.0
255+
lerna info versioning independent
256+
lerna info Assuming all packages changed
257+
258+
Changes:
259+
- package-a: 1.0.0 => 3.4.5
260+
- package-b: 1.0.0 => 3.4.5
261+
262+
lerna info auto-confirmed
263+
lerna info execute Skipping releases
264+
lerna info git Pushing tags...
265+
lerna success version finished
266+
267+
`);
268+
269+
// It should create one tag for each independently versioned package
270+
const checkPackageTagsArePresentLocally = await fixture.exec("git describe --abbrev=0");
271+
expect(checkPackageTagsArePresentLocally.combinedOutput).toMatchInlineSnapshot(`
272+
package-a@3.4.5
273+
274+
`);
275+
276+
const checkPackageATagIsPresentOnRemote = await fixture.exec(
277+
"git ls-remote origin refs/tags/package-a@3.4.5"
278+
);
279+
expect(checkPackageATagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
280+
{FULL_COMMIT_SHA} refs/tags/package-a@3.4.5
281+
282+
`);
283+
const checkPackageBTagIsPresentOnRemote = await fixture.exec(
284+
"git ls-remote origin refs/tags/package-b@3.4.5"
285+
);
286+
expect(checkPackageBTagIsPresentOnRemote.combinedOutput).toMatchInlineSnapshot(`
287+
{FULL_COMMIT_SHA} refs/tags/package-b@3.4.5
288+
289+
`);
290+
});
291+
});
292+
});

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
}
1717
},
1818
"ignoreChanges": ["**/__fixtures__/**", "**/__tests__/**", "**/*.md"],
19-
"version": "8.0.0"
19+
"version": "8.0.1"
2020
}

libs/commands/version/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ class VersionCommand extends Command {
875875
await gitCommit(message, this.gitOpts, this.execOpts);
876876
}
877877
if (this.gitOpts.signGitTag) {
878-
for (const tag in tags) await gitTag(tag, this.gitOpts, this.execOpts, this.options.gitTagCommand);
878+
for (const tag of tags) await gitTag(tag, this.gitOpts, this.execOpts, this.options.gitTagCommand);
879879
} else {
880880
await Promise.all(
881881
tags.map((tag) => gitTag(tag, this.gitOpts, this.execOpts, this.options.gitTagCommand))

0 commit comments

Comments
 (0)