Repository navigation
168 lines (149 loc) · 5.44 KB
/
Copy pathpublish.yml
File metadata and controls
168 lines (149 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Publish
permissions:
contents: read
pull-requests: write
on:
# Trigger for canary and stable releases:
# - Stable prod release: When PR from changeset-release/* branch is merged with [release] prefix
# - Canary release: Push to dev or release/* branches (not from changeset-release merge)
push:
branches:
- dev
- 'release/**'
paths:
- '**'
# changesets/action runs csdk:prep-release which consumes .changeset/*.md in that runner.
# Canary snapshot must run in a separate job with its own checkout so changesets still exist.
jobs:
stable-release-prep:
permissions:
id-token: write
runs-on: ubuntu-latest
if: ${{ !startsWith(github.ref_name, 'release/betas') }}
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
steps:
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.ref }}
fetch-depth: 0
persist-credentials: false
token: ${{ steps.generate-token.outputs.token }}
- name: Set git configuration
run: |
git config --global user.email builds@sitecore.com
git config --global user.name "content-sdk-bot"
git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }}
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: 24
registry-url: ${{ secrets.NPM_REGISTRY }}
- name: Install dependencies
run: |
yarn cache clean --all
yarn install --immutable
- name: Build packages
run: npm run build
- name: Generate API docs
run: |
yarn generate-docs
if [ -n "$(git status --porcelain)" ]; then
git add ./ref-docs/**/*
git commit -m "Update API docs [skip ci]" || echo "⚠️ Failed to commit API docs (may already be committed)"
git push origin HEAD:${{ github.ref_name }} || echo "⚠️ Failed to push API docs (may already be pushed or no changes)"
else
echo "No API doc changes to commit"
fi
- name: NPM tags and version
id: npm-tags
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
if [[ "$BRANCH_NAME" == release/* ]]; then
BRANCH_END="${BRANCH_NAME#release/}"
if [[ "$BRANCH_END" == 1.x.x ]]; then
RELEASE="NextJS v1.x hotfix"
NPM_TAG="ver1"
else
RELEASE="legacy version hotfix"
NPM_TAG="legacy"
fi
else
NPM_TAG="latest"
RELEASE="latest release"
fi
echo "release_text=$RELEASE" >> "$GITHUB_OUTPUT"
echo "npm_tag=$NPM_TAG" >> "$GITHUB_OUTPUT"
- name: Prepare and Process Changesets Release
id: changesets
uses: changesets/action@v1
with:
version: yarn csdk:prep-release
publish: yarn changeset:publish --tag ${{ steps.npm-tags.outputs.npm_tag }}
commit: '[release][ci] Version bump and changelog'
title: ${{ format('[csdk] {0}', steps.npm-tags.outputs.release_text) }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
npm_config_ignore_scripts: true # skip lifecycle scripts to avoid running build again during changeset:publish
canary-snapshot:
permissions:
id-token: write
runs-on: ubuntu-latest
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Use Node.js 24
uses: actions/setup-node@v7
with:
node-version: 24
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: |
yarn cache clean --all
yarn install --immutable
- name: Set canary prefix
id: canary-prefix
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
if [[ "$BRANCH_NAME" == release/betas/* ]]; then
BRANCH_END="${BRANCH_NAME#release/betas/}"
PREFIX="beta.${BRANCH_END//\//-}"
elif [[ "$BRANCH_NAME" == release/* ]]; then
PREFIX="canary-hotfix"
else
PREFIX="canary"
fi
echo "prefix=$PREFIX" >> "$GITHUB_OUTPUT"
- name: Build packages
run: npm run build
- name: Pre-release canary version bump and snapshot cascade
id: canary_snapshot
run: yarn changeset:cascade-snapshot-version
env:
CANARY_PREFIX: ${{ steps.canary-prefix.outputs.prefix }}
- name: Re-Install dependencies
run: |
yarn install
- name: Publish canary snapshot packages to npm
if: steps.canary_snapshot.outputs.snapshot_publish == 'true'
env:
CANARY_PREFIX: ${{ steps.canary-prefix.outputs.prefix }}
npm_config_ignore_scripts: true # skip lifecycle scripts to avoid running build again during changeset:publish
run: |
yarn build
yarn changeset:publish --tag $CANARY_PREFIX --no-git-tag