46
46
pull-requests : write
47
47
id-token : write
48
48
49
+ outputs :
50
+ plugin_version : ${{ steps.version.outputs.version }}
51
+
49
52
steps :
50
53
- name : Validate Freemius Credentials
51
54
id : credentials
71
74
tools : composer:v2
72
75
coverage : none
73
76
74
- # Step 5: Cache Composer dependencies
77
+ - name : Setup Git
78
+ run : |
79
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
80
+ git config --global user.name "github-actions[bot]"
81
+
75
82
- name : Cache Composer dependencies
76
83
uses : actions/cache@v4
77
84
with :
@@ -107,6 +114,8 @@ jobs:
107
114
echo "::error::Failed to create ZIP file"
108
115
exit 1
109
116
fi
117
+
118
+ echo "zip_path=$(realpath build/datakit.zip)" >> $GITHUB_OUTPUT
110
119
111
120
- name : Validate ZIP
112
121
id : validate
@@ -218,7 +227,60 @@ jobs:
218
227
}
219
228
"
220
229
221
- # Step 12: Create Release Comment
230
+ - name : Upload Release Assets
231
+ if : github.event_name == 'release' && !github.event.release.prerelease
232
+ env :
233
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
234
+ timeout-minutes : 2
235
+ run : |
236
+ # Upload to current release
237
+ if ! gh release upload ${{ github.ref_name }} build/datakit.zip --clobber; then
238
+ echo "::error::Failed to upload to current release"
239
+ exit 1
240
+ fi
241
+
242
+ # Only update latest if this is marked as the latest release
243
+ if [ "${{ github.event.release.draft }}" != "true" ] && [ "${{ github.event.release.prerelease }}" != "true" ]; then
244
+ echo "This is a full release - updating latest tag"
245
+
246
+ # Create or update latest release with retries
247
+ max_attempts=3
248
+ attempt=1
249
+ while [ $attempt -le $max_attempts ]; do
250
+ if gh release view latest > /dev/null 2>&1; then
251
+ if gh release upload latest build/datakit.zip --clobber; then
252
+ break
253
+ fi
254
+ else
255
+ if gh release create latest build/datakit.zip --notes "Latest stable release"; then
256
+ break
257
+ fi
258
+ fi
259
+
260
+ echo "Attempt $attempt failed, retrying..."
261
+ attempt=$((attempt + 1))
262
+ sleep 5
263
+ done
264
+
265
+ if [ $attempt -gt $max_attempts ]; then
266
+ echo "::error::Failed to update latest release after $max_attempts attempts"
267
+ exit 1
268
+ fi
269
+
270
+ # Update the latest tag
271
+ if ! git tag -f latest ${{ github.ref_name }}; then
272
+ echo "::error::Failed to create latest tag"
273
+ exit 1
274
+ fi
275
+
276
+ if ! git push --force origin latest; then
277
+ echo "::error::Failed to push latest tag"
278
+ exit 1
279
+ fi
280
+ else
281
+ echo "This is a draft/pre-release - not updating latest tag"
282
+ fi
283
+
222
284
- name : Create Release Comment
223
285
if : success() && github.event_name == 'release'
224
286
uses : actions/github-script@v6
@@ -239,9 +301,18 @@ jobs:
239
301
downloadUrl = 'Download URL not available';
240
302
}
241
303
304
+ const versionedUrl = `https://github.com/${owner}/${repo}/releases/download/${process.env.GITHUB_REF_NAME}/datakit.zip`;
305
+ const latestUrl = `https://github.com/${owner}/${repo}/releases/download/latest/datakit.zip`;
306
+
242
307
await github.rest.repos.updateRelease({
243
308
owner,
244
309
repo,
245
310
release_id,
246
- body: context.payload.release.body + '\n\n✅ Successfully deployed to Freemius\n\n[📥 Download Plugin ZIP File](' + downloadUrl + ')'
311
+ body: context.payload.release.body + '\n\n✅ Successfully deployed to Freemius\n\n' +
312
+ '[📥 Download from Freemius](' + downloadUrl + ')\n\n' +
313
+ '[📦 Download Build](' + versionedUrl + ')\n\n' +
314
+ '_Stable URL:_\n' +
315
+ '```\n' +
316
+ latestUrl + '\n' +
317
+ '```'
247
318
});
0 commit comments