-
Notifications
You must be signed in to change notification settings - Fork 71
209 lines (178 loc) · 6.06 KB
/
release.yml
File metadata and controls
209 lines (178 loc) · 6.06 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
name: Release Packages
on:
workflow_dispatch:
inputs:
dry_run:
description: "Dry run (no actual release)"
required: true
default: false
type: boolean
# Ensure only one release can run at a time
concurrency:
group: release
cancel-in-progress: false
# Minimal permissions for security
permissions:
contents: write
pull-requests: write
issues: write
jobs:
quality:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Enable Corepack
run: corepack enable
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Run format check
run: pnpm format
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 45
needs: quality
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Enable Corepack
run: corepack enable
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Cache Firebase emulators
uses: actions/cache@v4
with:
path: ~/.cache/firebase/emulators
key: ${{ runner.os }}-firebase-emulators-${{ hashFiles('.github/workflows/release.yml') }}
restore-keys: |
${{ runner.os }}-firebase-emulators-
- name: Install Firebase CLI
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
retry_wait_seconds: 60
max_attempts: 3
command: npm i -g firebase-tools@latest
# ✅ Ensure Data Connect SDKs are generated before emulator tests
- name: Generate Data Connect SDKs
run: firebase dataconnect:sdk:generate
- name: Run tests with emulator
run: pnpm test:emulator
- name: Build packages
run: pnpm turbo build
- name: Verify build outputs
run: |
echo "Checking build outputs..."
MISSING_BUILDS=""
for PKG_DIR in packages/*; do
if [ -d "$PKG_DIR" ] && [ -f "$PKG_DIR/package.json" ]; then
PKG_NAME=$(basename "$PKG_DIR")
if [ ! -d "$PKG_DIR/dist" ]; then
MISSING_BUILDS="$MISSING_BUILDS $PKG_NAME"
fi
fi
done
if [ -n "$MISSING_BUILDS" ]; then
echo "❌ Build outputs missing for: $MISSING_BUILDS"
exit 1
fi
echo "✅ All build outputs verified"
- name: Validate changesets
run: |
set -e
CHANGESET_FILES=$(find .changeset -name "*.md" -type f ! -name "README.md" 2>/dev/null || true)
if [ -z "$CHANGESET_FILES" ]; then
echo "❌ No changesets found!"
echo ""
echo "Please create changesets locally with: pnpm changeset"
exit 1
fi
CHANGESET_COUNT=$(echo "$CHANGESET_FILES" | wc -l | tr -d ' ')
echo "✅ Found $CHANGESET_COUNT changeset(s):"
echo "$CHANGESET_FILES" | while read -r file; do
echo " - $(basename "$file")"
done
- name: Create Release Pull Request or Publish
if: ${{ !inputs.dry_run }}
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
commit: "chore: version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry Run - Show Changes
if: ${{ inputs.dry_run }}
run: |
echo "🔍 This is a dry run. The following changes would be made:"
echo ""
echo "📋 Changeset contents:"
for file in .changeset/*.md; do
if [ -f "$file" ] && [ "$(basename "$file")" != "README.md" ]; then
echo "--- $(basename "$file") ---"
cat "$file"
echo ""
fi
done
echo "📦 Version changes that would be applied:"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
ORIGINAL_HEAD=$(git rev-parse HEAD)
FALLBACK_ID=${GITHUB_RUN_ID:-$RANDOM$RANDOM}
TEMP_BRANCH="dry-run-temp-$FALLBACK_ID"
git checkout -b "$TEMP_BRANCH"
pnpm changeset version
echo ""
echo "🔍 Changed files:"
git diff --name-status "$ORIGINAL_HEAD"
echo ""
echo "🔍 Package version changes:"
VERSION_CHANGES=$(git diff "$ORIGINAL_HEAD" -- '**/package.json' | grep -E "^[+-]\s*\"version\"" || true)
if [ -z "$VERSION_CHANGES" ]; then
echo " No version changes detected (this might indicate an issue with changesets)"
else
echo "$VERSION_CHANGES"
fi
git checkout -
git branch -D "$TEMP_BRANCH"
echo ""
echo "✅ Dry run completed successfully"