-
Notifications
You must be signed in to change notification settings - Fork 55
256 lines (228 loc) · 9.57 KB
/
release.yaml
File metadata and controls
256 lines (228 loc) · 9.57 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Publish packages and create tags
on:
workflow_dispatch:
inputs:
release_type:
description: "Type of release (auto, prerelease, patch, minor, major)"
required: true
default: "auto"
type: choice
options:
- auto
- prerelease
- patch
- minor
- major
prerelease_tag:
description: "Prerelease tag (e.g., rc, beta, alpha) - only used for prerelease"
required: false
default: "rc"
dry_run:
description: "Dry run (no actual publishing or commits)"
required: false
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- uses: arduino/setup-protoc@v3
- name: Cache Bun modules
uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
node_modules
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Cache turbo
uses: actions/cache@v4
with:
path: |
.turbo
**/.turbo
key: ${{ runner.os }}-turbo-${{ hashFiles('**/turbo.json') }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Cache build output
uses: actions/cache@v4
with:
path: |
packages/*/dist
examples/*/dist
key: ${{ runner.os }}-build-${{ hashFiles('**/src/**') }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-
- uses: ./.github/actions/setup-dojo
with:
dojo-version: v1.5.0-alpha.2
scarb-version: 2.10.1
- name: Configure Git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Determine release strategy
id: release-strategy
run: |
CURRENT_BRANCH="${GITHUB_REF_NAME}"
echo "Current branch: $CURRENT_BRANCH"
# Determine if we should use prerelease mode
if [[ "$CURRENT_BRANCH" != "main" && "${{ github.event.inputs.release_type }}" == "auto" ]]; then
echo "Non-main branch detected, will use prerelease mode"
echo "use_prerelease=true" >> $GITHUB_OUTPUT
# Extract version from branch name if it's a release branch
if [[ "$CURRENT_BRANCH" =~ ^release/([0-9]+\.[0-9]+) ]]; then
echo "prerelease_tag=${BASH_REMATCH[1]}-rc" >> $GITHUB_OUTPUT
else
# Use branch name as prerelease tag (sanitized)
SANITIZED_BRANCH=$(echo "$CURRENT_BRANCH" | sed 's/[^a-zA-Z0-9-]/-/g')
echo "prerelease_tag=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.event.inputs.release_type }}" == "prerelease" ]]; then
echo "Manual prerelease requested"
echo "use_prerelease=true" >> $GITHUB_OUTPUT
echo "prerelease_tag=${{ github.event.inputs.prerelease_tag }}" >> $GITHUB_OUTPUT
else
echo "Standard release mode"
echo "use_prerelease=false" >> $GITHUB_OUTPUT
fi
- name: "Setup npm authentication"
run: |
npm config set registry https://registry.npmjs.org/
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Install dependencies
run: bun install
- name: Enter prerelease mode if needed
if: steps.release-strategy.outputs.use_prerelease == 'true'
run: |
PRERELEASE_TAG="${{ steps.release-strategy.outputs.prerelease_tag }}"
echo "Entering prerelease mode with tag: $PRERELEASE_TAG"
if [ "${{ github.event.inputs.dry_run }}" != "true" ]; then
bun changeset pre enter "$PRERELEASE_TAG"
else
echo "DRY RUN: Would enter prerelease mode with tag $PRERELEASE_TAG"
fi
- name: Check for changesets
id: check-changesets
run: |
# Check if there are any changesets
if [ -z "$(ls -A .changeset/*.md 2>/dev/null | grep -v README.md)" ]; then
echo "No changesets found. Nothing to release."
echo "has_changesets=false" >> $GITHUB_OUTPUT
exit 0
else
echo "Found changesets to process."
echo "has_changesets=true" >> $GITHUB_OUTPUT
fi
- name: Version packages
if: steps.check-changesets.outputs.has_changesets == 'true'
id: changesets-version
run: |
echo "Running changeset version..."
if [ "${{ github.event.inputs.dry_run }}" != "true" ]; then
bun changeset version
# If we're in prerelease mode and on a non-main branch, we might need to force version bumps
if [ "${{ steps.release-strategy.outputs.use_prerelease }}" == "true" ]; then
echo "Prerelease versioning completed"
fi
else
echo "DRY RUN: Would run changeset version"
# Show what would be versioned
bun changeset status --verbose
fi
- name: Publish to npm
if: ${{ github.event.inputs.dry_run != 'true' && steps.check-changesets.outputs.has_changesets == 'true' }}
run: |
echo "Publishing packages..."
# Ensure torii-wasm pkg directory exists (turbo cache might only replay logs)
if [ -d "packages/torii-wasm" ] && [ ! -d "packages/torii-wasm/pkg" ]; then
echo "Building torii-wasm to ensure pkg directory exists..."
cd packages/torii-wasm && bun run build:wasm
cd ../..
fi
# Changesets will only publish packages that are not ignored in config
bun run release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Commit changes
if: ${{ github.event.inputs.dry_run != 'true' && steps.check-changesets.outputs.has_changesets == 'true' }}
run: |
if git diff --quiet && git diff --staged --quiet; then
echo "No changes to commit"
else
git add -A .changeset packages
git commit -m "chore: release"
git push origin "refs/heads/${GITHUB_REF_NAME}:refs/heads/${GITHUB_REF_NAME}"
fi
- name: Dry run - Show npm publish
if: ${{ github.event.inputs.dry_run == 'true' && steps.check-changesets.outputs.has_changesets == 'true' }}
run: |
echo "DRY RUN: Would publish the following packages to npm:"
# Show what changesets would publish
bun changeset publish --dry-run
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create and push tags
if: ${{ github.event.inputs.dry_run != 'true' && steps.check-changesets.outputs.has_changesets == 'true' }}
run: |
echo "Creating tags..."
bun changeset tag
git push --tags
- name: Exit prerelease mode if needed
if: steps.release-strategy.outputs.use_prerelease == 'true' && github.event.inputs.dry_run != 'true' && steps.check-changesets.outputs.has_changesets == 'true'
run: |
echo "Exiting prerelease mode"
bun changeset pre exit || true
# Commit the pre.json removal if it exists
if [ -f .changeset/pre.json ]; then
git add .changeset/pre.json
git commit -m "chore: exit prerelease mode" || true
git push origin "refs/heads/${GITHUB_REF_NAME}:refs/heads/${GITHUB_REF_NAME}" || true
fi
- name: Trigger release creation
if: ${{ github.event.inputs.dry_run != 'true' && steps.check-changesets.outputs.has_changesets == 'true' }}
run: |
# Get all tags that were just created
TAGS=$(git tag --points-at HEAD | grep '@dojoengine/' || true)
# For each tag, trigger the release workflow
for TAG in $TAGS; do
echo "Triggering release for tag: $TAG"
gh workflow run create_release.yaml \
--ref "${GITHUB_REF_NAME}" \
-f tag="$TAG"
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Dry run - Summary
if: ${{ github.event.inputs.dry_run == 'true' && steps.check-changesets.outputs.has_changesets == 'true' }}
run: |
echo "DRY RUN SUMMARY:"
echo "================"
if [ "${{ steps.release-strategy.outputs.use_prerelease }}" == "true" ]; then
echo "Would enter prerelease mode: ${{ steps.release-strategy.outputs.prerelease_tag }}"
fi
echo "Would version packages according to changesets"
echo "Would publish packages to npm"
echo "Would commit with message: chore: release"
echo "Would create and push tags"
if [ "${{ steps.release-strategy.outputs.use_prerelease }}" == "true" ]; then
echo "Would exit prerelease mode after publishing"
fi
echo ""
echo "Current git status:"
git status