Skip to content

Commit e1e6d99

Browse files
committed
chore(repo): ensure first release gets set for changelog creation
1 parent 8e2a44a commit e1e6d99

File tree

4 files changed

+59
-17
lines changed

4 files changed

+59
-17
lines changed

.github/workflows/release.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ jobs:
4040
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4141
NPM_CONFIG_PROVENANCE: true
4242
GH_TOKEN: ${{ github.token }}
43-
4443
steps:
4544
- name: Checkout
4645
uses: actions/checkout@v4
4746
with:
4847
fetch-depth: 0
48+
fetch-tags: 'true'
49+
50+
- name: Configure Git User
51+
run: |
52+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
53+
git config --global user.name "github-actions[bot]"
4954
5055
- name: Setup pnpm
5156
uses: pnpm/action-setup@v4
@@ -55,10 +60,20 @@ jobs:
5560
uses: actions/setup-node@v4
5661
with:
5762
node-version: 20.12
63+
registry-url: 'https://registry.npmjs.org'
5864
cache: 'pnpm'
5965

66+
# Ensure that the NPM_TOKEN secret is still valid before wasting any time deriving data or building projects
67+
- name: Check NPM Credentials
68+
run: npm whoami && echo "NPM credentials are valid" || (echo "NPM credentials are invalid or have expired." && exit 1)
69+
70+
6071
- name: Install dependencies
6172
run: pnpm install --frozen-lockfile
6273

6374
- name: Release packages
6475
run: pnpm release --version ${{ github.event.inputs.specifier }} --dist-tag ${{ github.event.inputs.dist-tag }} --dry-run=${{ github.event.inputs.dry-run }} --first-release=${{ github.event.inputs.first-release }}
76+
env:
77+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
NPM_CONFIG_PROVENANCE: true
79+
GH_TOKEN: ${{ github.token }}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"sass": "^1.79.3",
7676
"sass-embedded": "^1.79.3",
7777
"sass-loader": "^16.0.2",
78+
"semver": "^7.5.3",
7879
"tcp-port-used": "^1.0.2",
7980
"ts-morph": "^24.0.0",
8081
"ts-node": "10.9.1",

pnpm-lock.yaml

+14-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/scripts/release.ts

+28-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ import {
44
releasePublish,
55
} from 'nx/src/command-line/release';
66
import yargs from 'yargs';
7+
import { parse } from 'semver';
8+
9+
export function deriveDistTagFromSpecifier(distTag: string, specifier: string) {
10+
// dist-tag was explicitly set
11+
if (distTag && distTag !== 'infer-from-specifier') {
12+
return distTag;
13+
}
14+
15+
// Derive dist-tag from specifier
16+
if (
17+
specifier.startsWith('pre') ||
18+
specifier.includes('-alpha') ||
19+
specifier.includes('-beta')
20+
) {
21+
return 'next';
22+
}
23+
24+
if (parse(specifier)?.prerelease.length) {
25+
return 'next';
26+
}
27+
28+
return 'latest';
29+
}
730

831
(async () => {
932
try {
@@ -46,7 +69,7 @@ import yargs from 'yargs';
4669
specifier: options.version,
4770
// stage package.json updates to be committed later by the changelog command
4871
stageChanges: true,
49-
dryRun: true,
72+
dryRun: options.dryRun,
5073
verbose: options.verbose,
5174
});
5275

@@ -56,15 +79,15 @@ import yargs from 'yargs';
5679
gitTag: true,
5780
versionData: projectsVersionData,
5881
version: workspaceVersion,
59-
interactive: 'workspace',
60-
dryRun: true,
82+
dryRun: options.dryRun,
6183
verbose: options.verbose,
84+
firstRelease: options.firstRelease,
6285
});
6386

6487
await releasePublish({
6588
firstRelease: options.firstRelease,
66-
tag: options.distTag,
67-
dryRun: true,
89+
tag: deriveDistTagFromSpecifier(options.distTag, options.version),
90+
dryRun: options.dryRun,
6891
verbose: options.verbose,
6992
});
7093

0 commit comments

Comments
 (0)