Skip to content

Commit 190ea51

Browse files
committed
Add nightly and pre-release support to publish workflow
1 parent b770609 commit 190ea51

2 files changed

Lines changed: 105 additions & 7 deletions

File tree

.github/workflows/publish.yml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ on:
55
tags:
66
- 'v[0-9]+.[0-9]+.[0-9]+' # Stable releases: v1.0.0, v2.1.3
77
- 'v[0-9]+.[0-9]+.[0-9]+-*' # Pre-releases: v1.0.0-beta.1, v1.0.0-rc.1
8+
schedule:
9+
- cron: '0 2 * * 1-5' # Weekdays at 2 AM UTC (Mon-Fri)
10+
workflow_dispatch:
11+
inputs:
12+
release_type:
13+
description: 'Release type'
14+
required: true
15+
default: 'nightly'
16+
type: choice
17+
options:
18+
- nightly
819

920
jobs:
1021
publish:
@@ -17,7 +28,27 @@ jobs:
1728
- name: Checkout
1829
uses: actions/checkout@v4
1930

31+
- name: Determine release type
32+
id: release-type
33+
run: |
34+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
35+
echo "type=stable" >> $GITHUB_OUTPUT
36+
# Pre-release versions (v1.0.0-beta.1) publish to @next, stable to @latest
37+
if [[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-.+ ]]; then
38+
echo "tag=next" >> $GITHUB_OUTPUT
39+
echo "prerelease=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "tag=latest" >> $GITHUB_OUTPUT
42+
echo "prerelease=false" >> $GITHUB_OUTPUT
43+
fi
44+
else
45+
echo "type=nightly" >> $GITHUB_OUTPUT
46+
echo "tag=nightly" >> $GITHUB_OUTPUT
47+
echo "prerelease=false" >> $GITHUB_OUTPUT
48+
fi
49+
2050
- name: Validate tag matches package version
51+
if: steps.release-type.outputs.type == 'stable'
2152
run: |
2253
TAG_VERSION="${GITHUB_REF_NAME#v}"
2354
PKG_VERSION=$(node -p "require('./packages/b2c-tooling-sdk/package.json').version")
@@ -39,6 +70,10 @@ jobs:
3970
- name: Install dependencies
4071
run: pnpm install --frozen-lockfile
4172

73+
- name: Create snapshot versions
74+
if: steps.release-type.outputs.type == 'nightly'
75+
run: pnpm changeset version --snapshot nightly
76+
4277
- name: Build packages
4378
run: pnpm run build
4479

@@ -47,11 +82,12 @@ jobs:
4782

4883
- name: Publish to npm
4984
run: |
50-
pnpm --filter @salesforce/b2c-tooling-sdk publish --access public --no-git-checks
51-
pnpm --filter @salesforce/b2c-cli publish --access public --no-git-checks
52-
pnpm --filter @salesforce/b2c-dx-mcp publish --access public --no-git-checks
85+
pnpm --filter @salesforce/b2c-tooling-sdk publish --access public --no-git-checks --tag ${{ steps.release-type.outputs.tag }}
86+
pnpm --filter @salesforce/b2c-cli publish --access public --no-git-checks --tag ${{ steps.release-type.outputs.tag }}
87+
pnpm --filter @salesforce/b2c-dx-mcp publish --access public --no-git-checks --tag ${{ steps.release-type.outputs.tag }}
5388
5489
- name: Extract changelog for release
90+
if: steps.release-type.outputs.type == 'stable'
5591
run: |
5692
VERSION="${GITHUB_REF_NAME#v}"
5793
@@ -79,6 +115,12 @@ jobs:
79115
} > /tmp/release-notes.md
80116
81117
- name: Create GitHub Release
82-
run: gh release create "$GITHUB_REF_NAME" --notes-file /tmp/release-notes.md
118+
if: steps.release-type.outputs.type == 'stable'
119+
run: |
120+
PRERELEASE_FLAG=""
121+
if [[ "${{ steps.release-type.outputs.prerelease }}" == "true" ]]; then
122+
PRERELEASE_FLAG="--prerelease"
123+
fi
124+
gh release create "$GITHUB_REF_NAME" --notes-file /tmp/release-notes.md $PRERELEASE_FLAG
83125
env:
84126
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

PUBLISHING.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ The project uses:
99
- **[npm Trusted Publishers](https://docs.npmjs.com/trusted-publishers)** with OIDC for secure, tokenless publishing
1010
- **Two-workflow architecture** separating version management from publishing
1111

12+
## Release Types
13+
14+
| Type | npm Tag | Trigger | GitHub Release |
15+
|------|---------|---------|----------------|
16+
| **Stable** (`1.0.0`) | `@latest` | Git tag `v1.0.0` | Release |
17+
| **Pre-release** (`1.0.0-beta.1`) | `@next` | Git tag `v1.0.0-beta.1` | Pre-release |
18+
| **Nightly** (`0.0.1-nightly-20250113`) | `@nightly` | Scheduled (weekdays) or manual | None |
19+
20+
### Installing Different Versions
21+
22+
```bash
23+
# Stable release (default)
24+
npm install @salesforce/b2c-cli
25+
26+
# Pre-release (beta, preview, rc)
27+
npm install @salesforce/b2c-cli@next
28+
29+
# Nightly snapshot
30+
npm install @salesforce/b2c-cli@nightly
31+
```
32+
1233
## Published Packages
1334

1435
Only these three packages are published to npm:
@@ -38,8 +59,11 @@ The publish workflow explicitly filters to only these three packages using `--fi
3859

3960
### Workflow 2: `publish.yml` - npm Publishing
4061

41-
- **Trigger**: Push of version tags (`v1.0.0`, `v1.0.0-beta.1`, etc.)
42-
- **Purpose**: Publishes packages to npm and creates GitHub Release
62+
- **Triggers**:
63+
- Push of version tags (`v1.0.0`, `v1.0.0-beta.1`, etc.) - stable/pre-releases
64+
- Schedule (weekdays at 2 AM UTC) - nightly snapshots
65+
- Manual `workflow_dispatch` - on-demand nightly
66+
- **Purpose**: Publishes packages to npm and creates GitHub Releases (for tag-based releases)
4367
- **Permissions**: `contents: write`, `id-token: write` (for OIDC)
4468
- **Security**: Uses npm OIDC trusted publishers - no npm token required
4569

@@ -94,7 +118,39 @@ When ready to release:
94118
- Validate the tag matches package versions
95119
- Build and test all packages
96120
- Publish to npm via OIDC
97-
- Create a GitHub Release with auto-generated notes
121+
- Create a GitHub Release with aggregated changelogs
122+
123+
### Pre-releases (Beta, Preview, RC)
124+
125+
For pre-release versions, use changesets pre-release mode:
126+
127+
```bash
128+
# Enter pre-release mode
129+
pnpm changeset pre enter beta
130+
131+
# Continue normal workflow: create changesets, merge version PR
132+
# Versions will be like 1.0.0-beta.0, 1.0.0-beta.1, etc.
133+
134+
# Exit pre-release mode when ready for stable
135+
pnpm changeset pre exit
136+
```
137+
138+
Pre-release tags (`v1.0.0-beta.1`) publish to `@next` and create GitHub Pre-releases.
139+
140+
### Nightly Releases
141+
142+
Nightly releases run automatically on weekdays at 2 AM UTC. They can also be triggered manually:
143+
144+
1. Go to **Actions****Publish to npm** workflow
145+
2. Click **Run workflow**
146+
3. Select `nightly` and click **Run workflow**
147+
148+
Nightly versions use changesets snapshot format: `0.0.1-nightly-20250113`
149+
150+
**Notes:**
151+
- Nightly releases do NOT create GitHub releases
152+
- They publish to the `@nightly` npm tag
153+
- Each nightly overwrites the previous `@nightly` tag
98154

99155
## Changeset Configuration
100156

0 commit comments

Comments
 (0)