Skip to content

Commit 7dc792f

Browse files
blunteshwarcursoragentgithub-actions[bot]
authored
ci: create a release pipeline to release 1st gen and 2nd gen (#5978)
* refactor: refactored release strategy * chore: update publish workflows for 1st-gen and 2nd-gen * chore: change default NPM dist-tag to 'snapshot-test' in publish workflows * chore: refine changeset backup logic in publish workflows for 1st-gen and 2nd-gen * chore: minor fix * chore: enable publishing in workflows and add changeset for @adobe/spectrum-wc * chore: remove private flag from swc package.json * chore: migrated to trusted release for gen1 * chore: update Node.js version to 20.17.0 * chore: update publish workflows for 1st-gen and 2nd-gen * chore: add push trigger for SWC-1405 branch in publish workflows * chore: update CODEOWNERS to specify file protections and maintainers for workflows * chore: replace 2nd-gen publish workflow with a unified publish workflow * chore: remove deprecated publish workflow for packages * chore: simplify CODEOWNERS by removing specific protections for workflows * chore: added "1st-gen/projects/*" to root package.json * chore: add repository information to package.json in cem-plugin-react-wrapper * chore: update Node.js setup to use version from .nvmrc and refine package.json structure * chore: add "types" field to package.json for postcss-token * chore: enhance publish workflow to check for 1st-gen changesets * chore: minor test * chore: removed linting errors * chore: mark css-custom-vars-viewer package as private * chore: update GitHub Actions workflow for NPM publishing and modify .gitignore * chore: minor fix * chore: refactor GitHub Actions workflow to separate changeset checks and publishing logic * chore: add publish summary to GitHub Actions workflow for better visibility of publish events * chore: add support for SWC-1405 branch in GitHub Actions workflow * chore: adderessed feedback * chore: minor fix Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: minor fix Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: minor fix * chore: adderesed feedback * chore: added processing of stylesheets * feat: add comprehensive publishing workflow documentation for Spectrum Web Components * chore: fixed linting errors * chore: fixed linting errors * chore: fixed linting errors * feat: enhance publishing workflow to capture and display released package versions * chore: remove outdated publishing workflow documentation * chore: update package references in configuration and changelog * fix: correct package name for tag content color update * refactor: simplify prettier configuration loading in cem-plugin-react-wrapper.js * refactor: update genWrappers function signature * chore: update ESLint configuration to use dynamic path resolution for template file * chore: update ESLint rules for React wrappers to relax restrictions on generated files * chore: remove current branch from publishing workflow * chore: add concurrency settings to the publish workflow * chore: update .gitignore to include skills directory * chore: remove skills directory from .gitignore --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 90fb81f commit 7dc792f

37 files changed

Lines changed: 606 additions & 286 deletions

File tree

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@spectrum-web-components/1st-gen",
2222
"@spectrum-web-components/2nd-gen"
2323
],
24-
"linked": [["@adobe/swc", "@spectrum-web-components/core"]],
24+
"linked": [["@adobe/spectrum-wc", "@spectrum-web-components/core"]],
2525
"snapshot": {
2626
"prereleaseTemplate": "{tag}.{datetime}",
2727
"useCalculatedVersion": true

.changeset/tag-content-color-fix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'@spectrum-web-components/tag': patch
2+
'@spectrum-web-components/tags': patch
33
'@spectrum-web-components/styles': patch
44
---
55

.github/actions/setup-job/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ runs:
77
shell: bash
88
run: corepack enable
99

10-
- name: Setup Node 20
10+
- name: Setup Node from .nvmrc
1111
uses: actions/setup-node@v4
1212
with:
13-
node-version: '20'
13+
node-version-file: '.nvmrc'
1414
cache: 'yarn'
1515
registry-url: 'https://registry.npmjs.org'
1616

.github/workflows/preview-release.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
name: Publish Packages
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'NPM dist-tag (e.g., latest, beta, snapshot)'
8+
required: false
9+
default: 'next'
10+
pull_request:
11+
types: [labeled, synchronize]
12+
push:
13+
branches:
14+
- main
15+
16+
concurrency:
17+
group: publish-${{ github.ref }}
18+
cancel-in-progress: false
19+
20+
jobs:
21+
check-changesets:
22+
runs-on: ubuntu-latest
23+
if: >-
24+
github.event_name == 'workflow_dispatch' ||
25+
github.event_name == 'push' ||
26+
(github.event_name == 'pull_request' &&
27+
contains(github.event.pull_request.labels.*.name, 'snapshot-release'))
28+
outputs:
29+
has_changesets: ${{ steps.check.outputs.has_changesets }}
30+
has_1st_gen_changesets: ${{ steps.check.outputs.has_1st_gen_changesets }}
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Check for changesets
36+
id: check
37+
run: |
38+
if [ -z "$(ls -A .changeset/*.md 2>/dev/null | grep -v README)" ]; then
39+
echo "has_changesets=false" >> $GITHUB_OUTPUT
40+
echo "has_1st_gen_changesets=false" >> $GITHUB_OUTPUT
41+
echo "No changesets found - skipping publish"
42+
else
43+
echo "has_changesets=true" >> $GITHUB_OUTPUT
44+
CHANGESET_COUNT=$(ls -1 .changeset/*.md 2>/dev/null | grep -v README | wc -l | tr -d ' ')
45+
echo "Found $CHANGESET_COUNT changesets"
46+
47+
# Check if any changeset mentions 1st-gen packages
48+
# 1st-gen packages are @spectrum-web-components/* except core
49+
HAS_1ST_GEN=false
50+
for file in .changeset/*.md; do
51+
if [ "$(basename "$file")" != "README.md" ]; then
52+
PACKAGES=$(grep -oP "@spectrum-web-components/[a-z-]+" "$file")
53+
NON_CORE=$(echo "$PACKAGES" | grep -v "^@spectrum-web-components/core$")
54+
if [ -n "$NON_CORE" ]; then
55+
HAS_1ST_GEN=true
56+
break
57+
fi
58+
fi
59+
done
60+
61+
echo "has_1st_gen_changesets=$HAS_1ST_GEN" >> $GITHUB_OUTPUT
62+
if [ "$HAS_1ST_GEN" = "true" ]; then
63+
echo "Found 1st-gen changesets - React wrappers will be built and published"
64+
else
65+
echo "No 1st-gen changesets found - React wrappers will be skipped"
66+
fi
67+
fi
68+
69+
publish:
70+
needs: check-changesets
71+
if: needs.check-changesets.outputs.has_changesets == 'true'
72+
runs-on: ubuntu-latest
73+
environment: npm-publish
74+
permissions:
75+
id-token: write # Required for OIDC trusted publishing (1st-gen )
76+
contents: write # Required for git push
77+
env:
78+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v4
82+
with:
83+
fetch-depth: 0
84+
85+
- name: Setup job and install dependencies
86+
uses: ./.github/actions/setup-job
87+
88+
- name: Verify npm CLI version for trusted publishing
89+
run: |
90+
echo "Current npm version: $(npm --version)"
91+
npx semver -r ">=11.5.1" "$(npm --version)" || {
92+
echo "Upgrading npm for trusted publishing support (requires 11.5.1+)"
93+
npm install -g npm@latest
94+
echo "Upgraded to npm version: $(npm --version)"
95+
}
96+
97+
- name: Set Git identity
98+
run: |
99+
git config --global user.email "support+actions@github.com"
100+
git config --global user.name "github-actions-bot"
101+
102+
- name: Determine release tag
103+
id: extract-tag
104+
env:
105+
EVENT_NAME: ${{ github.event_name }}
106+
INPUT_TAG: ${{ github.event.inputs.tag }}
107+
run: |
108+
if [ "$EVENT_NAME" == "pull_request" ]; then
109+
# PRs with the snapshot-release label always use snapshot-test
110+
WORKFLOW_TAG="snapshot-test"
111+
elif [ -n "$INPUT_TAG" ]; then
112+
# Use the tag provided via workflow_dispatch input
113+
WORKFLOW_TAG="$INPUT_TAG"
114+
else
115+
# Default tag for push-triggered runs
116+
WORKFLOW_TAG="next"
117+
fi
118+
119+
echo "tag=$WORKFLOW_TAG" >> $GITHUB_OUTPUT
120+
echo "Using npm tag: $WORKFLOW_TAG"
121+
122+
- name: Validate release tag
123+
env:
124+
TAG: ${{ steps.extract-tag.outputs.tag }}
125+
GIT_REF: ${{ github.ref }}
126+
run: |
127+
if [ "$TAG" == "latest" ] && [ "$GIT_REF" != "refs/heads/main" ]; then
128+
echo "ERROR: Cannot publish 'latest' from non-main branch"
129+
exit 1
130+
fi
131+
132+
- name: Verify OIDC token and configure NPM authentication
133+
id: npm-auth
134+
env:
135+
NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
136+
run: |
137+
if [ -n "$ACTIONS_ID_TOKEN_REQUEST_URL" ]; then
138+
echo "✓ OIDC token is available for 1st-gen trusted publishing"
139+
else
140+
echo "✗ OIDC token NOT available - trusted publishing will fail"
141+
exit 1
142+
fi
143+
144+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
145+
echo "✓ NPM authentication configured for 2nd-gen (Adobe namespace)"
146+
147+
- name: Build all packages
148+
run: yarn build
149+
150+
- name: Generate custom elements manifests
151+
run: yarn workspace @spectrum-web-components/1st-gen custom-element-json
152+
153+
- name: Confirm build artifacts
154+
run: yarn workspace @spectrum-web-components/1st-gen build:confirm
155+
156+
- name: Version packages
157+
env:
158+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
TAG: ${{ steps.extract-tag.outputs.tag }}
160+
run: |
161+
if [ "$TAG" == "latest" ]; then
162+
yarn workspace @spectrum-web-components/1st-gen changelog:global
163+
yarn changeset version
164+
else
165+
yarn changeset version --snapshot $TAG
166+
fi
167+
168+
- name: Capture released versions
169+
id: versions
170+
run: |
171+
CORE_VERSION=$(node -p "require('./2nd-gen/packages/core/package.json').version")
172+
BUNDLE_VERSION=$(node -p "require('./1st-gen/tools/bundle/package.json').version")
173+
SWC_VERSION=$(node -p "require('./2nd-gen/packages/swc/package.json').version")
174+
echo "core=$CORE_VERSION" >> $GITHUB_OUTPUT
175+
echo "bundle=$BUNDLE_VERSION" >> $GITHUB_OUTPUT
176+
echo "swc=$SWC_VERSION" >> $GITHUB_OUTPUT
177+
178+
- name: Refresh lockfile and rebuild
179+
run: |
180+
yarn install --refresh-lockfile
181+
yarn build
182+
183+
- name: Publish all packages
184+
if: steps.npm-auth.outcome == 'success'
185+
env:
186+
NODE_AUTH_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
187+
TAG: ${{ steps.extract-tag.outputs.tag }}
188+
run: |
189+
# Changeset publishes all packages (1st-gen, core, and 2nd-gen)
190+
# npm CLI automatically uses:
191+
# - OIDC trusted publishing for 1st-gen packages (configured on npmjs.com)
192+
# - Token authentication for 2nd-gen (from .npmrc)
193+
if [ "$TAG" == "latest" ]; then
194+
yarn changeset publish --no-git-tag
195+
else
196+
yarn changeset publish --no-git-tag --tag $TAG
197+
fi
198+
199+
- name: Build React wrappers
200+
if: needs.check-changesets.outputs.has_1st_gen_changesets == 'true'
201+
run: yarn workspace @spectrum-web-components/1st-gen build:react
202+
203+
- name: Publish React wrappers
204+
if: needs.check-changesets.outputs.has_1st_gen_changesets == 'true'
205+
env:
206+
TAG: ${{ steps.extract-tag.outputs.tag }}
207+
run: |
208+
if [ "$TAG" == "latest" ]; then
209+
PUBLISH_CMD="npm publish --access public"
210+
else
211+
PUBLISH_CMD="npm publish --tag $TAG --access public"
212+
fi
213+
214+
# Retry function with exponential backoff
215+
retry_publish() {
216+
local dir=$1
217+
local max_attempts=3
218+
local attempt=1
219+
220+
while [ $attempt -le $max_attempts ]; do
221+
echo "Publishing $dir (attempt $attempt/$max_attempts)..."
222+
if (cd "$dir" && $PUBLISH_CMD); then
223+
echo "✓ Successfully published $dir"
224+
return 0
225+
else
226+
if [ $attempt -lt $max_attempts ]; then
227+
local wait_time=$((2 ** attempt))
228+
echo "✗ Publish failed, retrying in ${wait_time}s..."
229+
sleep $wait_time
230+
else
231+
echo "✗ Failed to publish $dir after $max_attempts attempts"
232+
return 1
233+
fi
234+
fi
235+
attempt=$((attempt + 1))
236+
done
237+
}
238+
239+
cd 1st-gen/react
240+
for dir in */; do
241+
retry_publish "$dir" || exit 1
242+
done
243+
244+
- name: Publish summary
245+
if: always()
246+
env:
247+
TAG: ${{ steps.extract-tag.outputs.tag }}
248+
EVENT_NAME: ${{ github.event_name }}
249+
PR_NUMBER: ${{ github.event.pull_request.number }}
250+
PR_TITLE: ${{ github.event.pull_request.title }}
251+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
252+
HEAD_REF: ${{ github.head_ref }}
253+
BASE_REF: ${{ github.base_ref }}
254+
REF_NAME: ${{ github.ref_name }}
255+
ACTOR: ${{ github.actor }}
256+
COMMIT_SHA: ${{ github.sha }}
257+
AUTH_OUTCOME: ${{ steps.npm-auth.outcome }}
258+
CORE_VERSION: ${{ steps.versions.outputs.core }}
259+
BUNDLE_VERSION: ${{ steps.versions.outputs.bundle }}
260+
SWC_VERSION: ${{ steps.versions.outputs.swc }}
261+
run: |
262+
echo "## Publish summary" >> $GITHUB_STEP_SUMMARY
263+
echo "" >> $GITHUB_STEP_SUMMARY
264+
265+
if [ "$EVENT_NAME" == "pull_request" ]; then
266+
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
267+
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
268+
echo "| **Trigger** | Pull request |" >> $GITHUB_STEP_SUMMARY
269+
echo "| **PR** | #${PR_NUMBER} — ${PR_TITLE} |" >> $GITHUB_STEP_SUMMARY
270+
echo "| **Branch** | \`${HEAD_REF}\` → \`${BASE_REF}\` |" >> $GITHUB_STEP_SUMMARY
271+
echo "| **NPM tag** | \`${TAG}\` |" >> $GITHUB_STEP_SUMMARY
272+
echo "| **Author** | @${PR_AUTHOR} |" >> $GITHUB_STEP_SUMMARY
273+
elif [ "$EVENT_NAME" == "workflow_dispatch" ]; then
274+
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
275+
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
276+
echo "| **Trigger** | Manual dispatch |" >> $GITHUB_STEP_SUMMARY
277+
echo "| **Branch** | \`${REF_NAME}\` |" >> $GITHUB_STEP_SUMMARY
278+
echo "| **NPM tag** | \`${TAG}\` |" >> $GITHUB_STEP_SUMMARY
279+
echo "| **Actor** | @${ACTOR} |" >> $GITHUB_STEP_SUMMARY
280+
else
281+
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
282+
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
283+
echo "| **Trigger** | Push |" >> $GITHUB_STEP_SUMMARY
284+
echo "| **Branch** | \`${REF_NAME}\` |" >> $GITHUB_STEP_SUMMARY
285+
echo "| **NPM tag** | \`${TAG}\` |" >> $GITHUB_STEP_SUMMARY
286+
echo "| **Commit** | \`${COMMIT_SHA}\` |" >> $GITHUB_STEP_SUMMARY
287+
fi
288+
289+
if [ -n "$CORE_VERSION" ] || [ -n "$BUNDLE_VERSION" ] || [ -n "$SWC_VERSION" ]; then
290+
echo "## Versions released" >> $GITHUB_STEP_SUMMARY
291+
echo "" >> $GITHUB_STEP_SUMMARY
292+
echo "| Generation | Package | Version |" >> $GITHUB_STEP_SUMMARY
293+
echo "|------------|---------|---------|" >> $GITHUB_STEP_SUMMARY
294+
[ -n "$CORE_VERSION" ] && echo "| Core | \`@spectrum-web-components/core\` | \`${CORE_VERSION}\` |" >> $GITHUB_STEP_SUMMARY
295+
[ -n "$BUNDLE_VERSION" ] && echo "| 1st gen | \`@spectrum-web-components/bundle\` | \`${BUNDLE_VERSION}\` |" >> $GITHUB_STEP_SUMMARY
296+
[ -n "$SWC_VERSION" ] && echo "| 2nd gen | \`@adobe/spectrum-wc\` | \`${SWC_VERSION}\` |" >> $GITHUB_STEP_SUMMARY
297+
echo "" >> $GITHUB_STEP_SUMMARY
298+
fi
299+
300+
if [ "$AUTH_OUTCOME" == "success" ]; then
301+
echo "✅ Publish completed with tag \`${TAG}\`" >> $GITHUB_STEP_SUMMARY
302+
else
303+
echo "❌ Publish failed — NPM authentication did not succeed" >> $GITHUB_STEP_SUMMARY
304+
fi
305+
306+
- name: Commit and push changes
307+
if: steps.extract-tag.outputs.tag == 'latest'
308+
run: |
309+
git add .
310+
git commit -m "chore: release packages #publish" || echo "No changes to commit"
311+
git push
312+
313+
- name: Create git tag
314+
if: steps.extract-tag.outputs.tag == 'latest'
315+
run: node ./1st-gen/scripts/create-git-tag.js

0 commit comments

Comments
 (0)