@mnci/cli 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -291,7 +291,16 @@ lint,test,build`. Pushes to `main` then:
291
291
  the raw token twine needs for the Python publish. Skipped cleanly when there
292
292
  is nothing to release. A guarded step installs the fixed Python toolchain
293
293
  (`ruff`/`pytest`/`build`/`twine`/`pip-audit`) before any Python target runs,
294
- skipped cleanly on a workspace with no Python projects.
294
+ skipped cleanly on a workspace with no Python projects. On a `--ci=github`
295
+ workspace this same step also creates a **GitHub Release per project**, with
296
+ a changelog Nx generates from conventional commits — `nx release` pushes the
297
+ tag itself here (needs `GITHUB_TOKEN`, which GitHub Actions provides for
298
+ free under the workflow's own `contents: write` permission), so there's no
299
+ separate explicit `git push origin --tags` step on this provider. `--ci=azure`
300
+ and `--ci=both` keep today's behaviour (no GitHub Release, explicit tag
301
+ push) — GitHub Release creation only turns on when GitHub Actions is the
302
+ *only* configured provider, since that's the one case a `GITHUB_TOKEN` is
303
+ guaranteed to exist.
295
304
 
296
305
  **npm auth** is the base64 `PAT`, read the same way on both providers but from
297
306
  a different place: on Azure Pipelines, a **variable group**
@@ -400,8 +409,13 @@ than a surprise:
400
409
  inside the published `drop` artifact is the deploy input. Deploying it means
401
410
  Azure's Oryx build installing real dependencies (`npm install`/`pip install`)
402
411
  from the zipped manifest — no `node_modules`/venv is bundled.
403
- - Changelog files are off (unpushable under the tag-only model); the git tag
404
- history is the changelog for now.
412
+ - Changelog **files** are off everywhere (unpushable under the tag-only
413
+ model — `git.commit` stays `false`, so a written `CHANGELOG.md` would just
414
+ be discarded at the end of every CI run). On a `--ci=github` workspace (and
415
+ only that one — see below) each release still gets a real changelog: Nx
416
+ generates it from conventional commits and posts it straight to a GitHub
417
+ Release, with no file ever touched. `--ci=azure` and `--ci=both` fall back
418
+ to the git tag history as the changelog, same as before.
405
419
  - **No lock file for Python** — plain pip has none, matching the company
406
420
  standard this migration was for. A published wheel's `Requires-Dist` mirrors
407
421
  whatever specifier the `pyproject.toml` declares (e.g. `tomli>=2.0.0`)
package/dist/cli.js CHANGED
@@ -1034,27 +1034,33 @@ function npmrcContent(registry, scope) {
1034
1034
  lines.push("");
1035
1035
  return lines.join("\n");
1036
1036
  }
1037
- var RELEASE_CONFIG = {
1038
- projectsRelationship: "independent",
1039
- projects: ["packages/*", "python-packages/*"],
1040
- releaseTag: { pattern: "{projectName}@{version}" },
1041
- git: { commit: false, tag: true, push: false },
1042
- version: {
1043
- conventionalCommits: true,
1044
- fallbackCurrentVersionResolver: "disk",
1045
- // Build only what is being released. Without this, @nx/js:lib's generator
1046
- // defaults the pre-version command to building EVERY project, so a broken
1047
- // (or merely slow) app build would block releasing unrelated packages.
1048
- // Set here at `new` time it wins: the generator only fills this in when
1049
- // absent (it spreads the existing release.version over its default). Both
1050
- // globs are listed; `nx run-many` no-ops cleanly when one matches nothing.
1051
- preVersionCommand: "npx nx run-many -t build --projects=packages/*,python-packages/*"
1052
- },
1053
- changelog: { workspaceChangelog: false }
1054
- };
1037
+ function releaseConfig(ci) {
1038
+ const githubReleases = ci === "github";
1039
+ return {
1040
+ projectsRelationship: "independent",
1041
+ projects: ["packages/*", "python-packages/*"],
1042
+ releaseTag: { pattern: "{projectName}@{version}" },
1043
+ git: { commit: false, tag: true, push: githubReleases },
1044
+ version: {
1045
+ conventionalCommits: true,
1046
+ fallbackCurrentVersionResolver: "disk",
1047
+ // Build only what is being released. Without this, @nx/js:lib's generator
1048
+ // defaults the pre-version command to building EVERY project, so a broken
1049
+ // (or merely slow) app build would block releasing unrelated packages.
1050
+ // Set here at `new` time it wins: the generator only fills this in when
1051
+ // absent (it spreads the existing release.version over its default). Both
1052
+ // globs are listed; `nx run-many` no-ops cleanly when one matches nothing.
1053
+ preVersionCommand: "npx nx run-many -t build --projects=packages/*,python-packages/*"
1054
+ },
1055
+ changelog: githubReleases ? {
1056
+ workspaceChangelog: false,
1057
+ projectChangelogs: { createRelease: "github", file: false }
1058
+ } : { workspaceChangelog: false }
1059
+ };
1060
+ }
1055
1061
  var SYNC_CONFIG = { applyChanges: true };
1056
- function withReleaseConfig(nxJson) {
1057
- return { ...nxJson, defaultBase: "main", release: RELEASE_CONFIG };
1062
+ function withReleaseConfig(nxJson, ci) {
1063
+ return { ...nxJson, defaultBase: "main", release: releaseConfig(ci) };
1058
1064
  }
1059
1065
  var COMMITLINT_CONFIG = `export default { extends: ['@commitlint/config-conventional'] }
1060
1066
  `;
@@ -1363,12 +1369,13 @@ steps:
1363
1369
  condition: ${onMain}
1364
1370
  `;
1365
1371
  }
1366
- function githubActionsYaml(agent, pythonPublishUrl2, registryKind = "azure-artifacts") {
1372
+ function githubActionsYaml(agent, pythonPublishUrl2, registryKind = "azure-artifacts", ci = "github") {
1367
1373
  const onMain = `github.event_name != 'pull_request' && github.ref_name == 'main'`;
1368
1374
  const [npmAuthName, npmAuthValue] = npmAuthEnvVariable(
1369
1375
  registryKind,
1370
1376
  (name) => `\${{ secrets.${name} }}`
1371
1377
  );
1378
+ const githubReleases = ci === "github";
1372
1379
  return `name: CI
1373
1380
 
1374
1381
  # Generated by MoNecromanCI. Deliberately thin: Nx builds, 'nx release'
@@ -1384,7 +1391,8 @@ on:
1384
1391
  branches: [main]
1385
1392
 
1386
1393
  permissions:
1387
- # Lets the release step push the version tag nx release creates back to main.
1394
+ # Lets the release step push the version tag nx release creates back to main,
1395
+ # and (github-only provider) create the GitHub Release itself.
1388
1396
  contents: write
1389
1397
 
1390
1398
  jobs:
@@ -1491,13 +1499,19 @@ jobs:
1491
1499
  # (python-packages/*) \u2014 conventional commits, tag-only push. Portable guard:
1492
1500
  # nx release errors on an empty scope, so skip cleanly when there is nothing
1493
1501
  # to release. When there are Python packages and an Azure feed, twine
1494
- # publish credentials are exported (raw PAT, decoded from the base64 secret).
1502
+ # publish credentials are exported (raw PAT, decoded from the base64 secret).${githubReleases ? `
1503
+ # This provider also creates a per-project GitHub Release (changelog
1504
+ # generated from conventional commits since that project's last tag),
1505
+ # which is why 'nx release' pushes the tag itself here \u2014 see
1506
+ # releaseConfig's remarks for why that is safe on this Nx version and
1507
+ # why every other provider combination keeps the explicit push step below.` : ""}
1495
1508
  - run: ${releaseGuard(pythonPublishEnvFragment(pythonPublishUrl2))}
1496
- name: Release \u2014 version, tag and publish (npm + Python)
1509
+ name: Release \u2014 version, tag${githubReleases ? ", publish and GitHub Release" : " and publish"} (npm + Python)
1497
1510
  if: \${{ ${onMain} }}
1498
1511
  env:
1499
- ${npmAuthName}: ${npmAuthValue}
1500
-
1512
+ ${npmAuthName}: ${npmAuthValue}${githubReleases ? `
1513
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}` : ""}
1514
+ ${githubReleases ? "" : `
1501
1515
  # nx release's own git push (release.git.push) is deliberately left off: it
1502
1516
  # only runs when a remote GitHub/GitLab Release is configured, which this
1503
1517
  # workflow never does, so it would never push the tag the step above just
@@ -1506,7 +1520,7 @@ jobs:
1506
1520
  - run: git push origin --tags
1507
1521
  name: Push release tags (nx release's own push never runs without a remote Release configured)
1508
1522
  if: \${{ ${onMain} }}
1509
- `;
1523
+ `}`;
1510
1524
  }
1511
1525
  var DEPENDABOT_CONFIG = `# Generated by MoNecromanCI. Weekly dependency-update PRs so vulnerable or
1512
1526
  # stale dependencies surface as a reviewable PR instead of only a push-time
@@ -1543,7 +1557,10 @@ function applyOverlay(workspaceRoot, options) {
1543
1557
  };
1544
1558
  const sync = { ...nxJson.sync, ...SYNC_CONFIG };
1545
1559
  const mnci = { ...nxJson.mnci, ...mnciConfig(options) };
1546
- writeFileEnsured(nxJsonPath, toJson({ ...withReleaseConfig(nxJson), generators, sync, mnci }));
1560
+ writeFileEnsured(
1561
+ nxJsonPath,
1562
+ toJson({ ...withReleaseConfig(nxJson, options.ci), generators, sync, mnci })
1563
+ );
1547
1564
  const manifestPath = (0, import_node_path9.join)(workspaceRoot, "package.json");
1548
1565
  const manifest = readJson(manifestPath);
1549
1566
  const scripts = {
@@ -1580,7 +1597,7 @@ function applyOverlay(workspaceRoot, options) {
1580
1597
  if (options.ci === "github" || options.ci === "both") {
1581
1598
  writeFileEnsured(
1582
1599
  (0, import_node_path9.join)(workspaceRoot, ".github/workflows/ci.yml"),
1583
- githubActionsYaml(options.agent, publishUrl, options.registry.kind)
1600
+ githubActionsYaml(options.agent, publishUrl, options.registry.kind, options.ci)
1584
1601
  );
1585
1602
  writeFileEnsured((0, import_node_path9.join)(workspaceRoot, ".github/dependabot.yml"), DEPENDABOT_CONFIG);
1586
1603
  }