-
-
Notifications
You must be signed in to change notification settings - Fork 106
289 lines (247 loc) · 11.9 KB
/
release.yml
File metadata and controls
289 lines (247 loc) · 11.9 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# This workflow is used to release master releases and also by the snapshot workflow
# to release snapshots.
name: Wheels Release
on:
push:
branches:
- main
workflow_call:
secrets:
SLACK_WEBHOOK_URL:
required: true
FORGEBOX_API_TOKEN:
required: true
FORGEBOX_PASS:
required: true
env:
WHEELS_PRERELEASE: false
jobs:
#############################################
# Build Snapshot or Final Release
#############################################
build:
name: Build & Publish Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
id: Checkout-Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Environment Variables For Build Process
id: Calculate-Version-And-Branch
run: |
cat box.json
BASE_VERSION=$(cat box.json | jq '.version' -r)
echo "Base version from box.json: ${BASE_VERSION}"
# Develop builds get -SNAPSHOT qualifier; main builds are stable releases.
# Source files keep clean versions (e.g. 3.1.0) so no changes are
# needed when promoting develop to main.
if [ "$GITHUB_REF" == "refs/heads/develop" ]; then
echo "WHEELS_VERSION=${BASE_VERSION}-SNAPSHOT+${{ github.run_number }}" >> $GITHUB_ENV
echo "BRANCH=develop" >> $GITHUB_ENV
else
echo "WHEELS_VERSION=${BASE_VERSION}+${{ github.run_number }}" >> $GITHUB_ENV
echo "BRANCH=main" >> $GITHUB_ENV
fi
- name: Make build scripts executable
run: |
chmod +x tools/build/scripts/*.sh
# List scripts for verification
ls -la tools/build/scripts/
#############################################
# Pre-Release Validation (main branch only)
#############################################
- name: Validate Release Checklist
if: github.ref == 'refs/heads/main'
run: |
echo "=========================================="
echo "Validating Release Checklist"
echo "=========================================="
# Check that CHANGELOG doesn't contain TBD for this version
if grep -q "# \[${WHEELS_VERSION%+*}\].*=> TBD" CHANGELOG.md; then
echo "ERROR: CHANGELOG still contains 'TBD' for version ${WHEELS_VERSION%+*}"
echo "Please update CHANGELOG.md with the actual release date before releasing."
exit 1
fi
# Check that source version in box.json is clean (no -SNAPSHOT suffix).
# The workflow injects -SNAPSHOT for develop builds automatically.
BASE_VERSION=$(jq -r '.version' templates/base/src/box.json)
if echo "$BASE_VERSION" | grep -qi "snapshot"; then
echo "ERROR: Version in box.json contains -SNAPSHOT suffix ($BASE_VERSION)"
echo "Source files should have clean versions (e.g., 3.1.0)."
echo "The workflow adds -SNAPSHOT automatically for develop builds."
exit 1
fi
echo "✓ Release checklist validation passed"
#############################################
# Prepare and Publish to ForgeBox
#############################################
- name: Prepare Wheels Base Template for ForgeBox
run: |
./tools/build/scripts/prepare-base.sh "${{ env.WHEELS_VERSION }}" "${{ env.BRANCH }}" "${{ github.run_number }}" "${{ env.WHEELS_PRERELEASE }}"
- name: Prepare Wheels Core for ForgeBox
run: |
./tools/build/scripts/prepare-core.sh "${{ env.WHEELS_VERSION }}" "${{ env.BRANCH }}" "${{ github.run_number }}" "${{ env.WHEELS_PRERELEASE }}"
- name: Prepare Wheels CLI for ForgeBox
run: |
./tools/build/scripts/prepare-cli.sh "${{ env.WHEELS_VERSION }}" "${{ env.BRANCH }}" "${{ github.run_number }}" "${{ env.WHEELS_PRERELEASE }}"
- name: Prepare Wheels Starter App for ForgeBox
run: |
./tools/build/scripts/prepare-starterApp.sh "${{ env.WHEELS_VERSION }}"
- name: Install CommandBox
run: |
curl -fsSl https://downloads.ortussolutions.com/debs/gpg | sudo gpg --dearmor -o /usr/share/keyrings/ortussolutions.gpg
echo "deb [signed-by=/usr/share/keyrings/ortussolutions.gpg] https://downloads.ortussolutions.com/debs/noarch /" | sudo tee /etc/apt/sources.list.d/ortussolutions.list
sudo apt-get update && sudo apt-get install -y commandbox
#############################################
# Validate Packages Before Publishing
#############################################
- name: Validate Package Structure and Versions
run: |
echo "=========================================="
echo "Validating Packages Before ForgeBox Publish"
echo "=========================================="
# Function to validate a package
validate_package() {
local PACKAGE_DIR=$1
local PACKAGE_NAME=$2
echo ""
echo "Validating $PACKAGE_NAME..."
# Check if directory exists
if [ ! -d "$PACKAGE_DIR" ]; then
echo "ERROR: Directory $PACKAGE_DIR does not exist!"
exit 1
fi
# Check if box.json exists
if [ ! -f "$PACKAGE_DIR/box.json" ]; then
echo "ERROR: box.json not found in $PACKAGE_DIR!"
exit 1
fi
# Validate box.json syntax
if ! jq empty "$PACKAGE_DIR/box.json" 2>/dev/null; then
echo "ERROR: Invalid JSON in $PACKAGE_DIR/box.json"
exit 1
fi
# Extract and display version
local VERSION=$(jq -r '.version' "$PACKAGE_DIR/box.json")
echo " Version: $VERSION"
# Check that version matches expected version
if [[ "$VERSION" != "${{ env.WHEELS_VERSION }}" ]]; then
echo " WARNING: Version mismatch! Expected ${{ env.WHEELS_VERSION }}, got $VERSION"
fi
# Count files
local FILE_COUNT=$(find "$PACKAGE_DIR" -type f | wc -l)
echo " Files: $FILE_COUNT"
if [ "$FILE_COUNT" -eq 0 ]; then
echo "ERROR: No files found in package directory!"
exit 1
fi
echo " ✓ Package validated successfully"
}
# Validate all packages
validate_package "build-wheels-base" "Wheels Base Template"
validate_package "build-wheels-core/wheels" "Wheels Core"
validate_package "build-wheels-cli/wheels-cli" "Wheels CLI"
validate_package "build-wheels-starterApp" "Wheels Starter App"
echo ""
echo "=========================================="
echo "All packages validated successfully!"
echo "=========================================="
- name: Publish All Packages to ForgeBox
run: |
# Publish stable release and mark as current/stable version
./tools/build/scripts/publish-to-forgebox.sh "wheels-dev" "${{ secrets.FORGEBOX_PASS }}" "true" "true"
#############################################
# Build Artifacts for GitHub
#############################################
- name: Build All Wheels Artifacts
run: |
./tools/build/scripts/build-base.sh "${{ env.WHEELS_VERSION }}" "${{ env.BRANCH }}" "${{ github.run_number }}" "${{ env.WHEELS_PRERELEASE }}"
./tools/build/scripts/build-core.sh "${{ env.WHEELS_VERSION }}" "${{ env.BRANCH }}" "${{ github.run_number }}" "${{ env.WHEELS_PRERELEASE }}"
./tools/build/scripts/build-cli.sh "${{ env.WHEELS_VERSION }}" "${{ env.BRANCH }}" "${{ github.run_number }}" "${{ env.WHEELS_PRERELEASE }}"
./tools/build/scripts/build-starterApp.sh "${{ env.WHEELS_VERSION }}"
- name: Upload Wheels Base Template Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifacts-base-template
path: |
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-base-template-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-base-template-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-base-template-*.sha512
artifacts/wheels/wheels-base-template-be.zip
- name: Upload Wheels Core Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifacts-core
path: |
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-core-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-core-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-core-*.sha512
artifacts/wheels/wheels-core-be.zip
- name: Upload Wheels CLI Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifacts-cli
path: |
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-cli-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-cli-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-cli-*.sha512
artifacts/wheels/wheels-cli-be.zip
- name: Upload Wheels Starter App Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifacts-starter-app
path: |
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-starter-app-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-starter-app-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-starter-app-*.sha512
artifacts/wheels/wheels-starter-app-be.zip
- name: Upload All Wheels Artifacts (Combined)
uses: actions/upload-artifact@v4
with:
name: build-artifacts-all
path: |
artifacts/**/*
- name: Upload Workflow Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: logs-release
path: |
${{ runner.temp }}/_runner_diag/
${{ runner.temp }}/_github_workflow/
#############################################
# Create GitHub Release (main branch only)
#############################################
- name: Extract Release Notes from CHANGELOG
if: github.ref == 'refs/heads/main'
id: extract-release-notes
run: |
# Extract the release notes for the current version from CHANGELOG.md
VERSION_PATTERN=$(echo "${WHEELS_VERSION%+*}" | sed 's/\./\\./g')
awk '/^# \['"${VERSION_PATTERN}"'\]/,/^---$/ {print}' CHANGELOG.md | sed '1d;$d' > release-notes.md
echo "Release notes extracted to release-notes.md"
cat release-notes.md
- name: Create GitHub Release
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.WHEELS_VERSION }}
name: Wheels ${{ env.WHEELS_VERSION }}
body_path: release-notes.md
draft: false
prerelease: ${{ env.WHEELS_PRERELEASE }}
files: |
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-base-template-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-base-template-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-base-template-*.sha512
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-core-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-core-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-core-*.sha512
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-cli-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-cli-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-cli-*.sha512
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-starter-app-*.zip
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-starter-app-*.md5
artifacts/wheels/${{ env.WHEELS_VERSION }}/wheels-starter-app-*.sha512