Skip to content

Commit fbb4cbc

Browse files
feat: enhance nightly build workflow with additional outputs and tagging logic
1 parent 88cc16c commit fbb4cbc

1 file changed

Lines changed: 49 additions & 34 deletions

File tree

‎.github/workflows/nightly-build.yml‎

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@
7474

7575
outputs:
7676
release_output_url: ${{ steps.release.outputs.url }}
77-
updated_version: ${{ steps.update-version.outputs.UPDATED_VERSION}}
77+
updated_version: ${{ steps.update-version.outputs.UPDATED_VERSION}}
78+
NORMAL_APK_PATH: ${{ steps.update-version.outputs.NORMAL_APK_PATH }}
79+
FDROID_APK_PATH: ${{ steps.update-version.outputs.FDROID_APK_PATH }}
7880
RELEASE_NOTES: ${{ env.RELEASE_NOTES }}
81+
tag_commit: ${{ steps.check-nightly-tag-force-update.outputs.tag_commit }}
7982
steps:
8083
- name: Fast Fail if secrets are missing
8184
if: ${{ env.KEYSTORE_CONTENT == '' || env.BUILD_JSON_CONTENT == '' }}
@@ -216,68 +219,80 @@
216219
rm $STORE_FILE_PATH $BUILD_JSON_PATH
217220
echo "Keystore and build.json removed successfully."
218221
219-
- name: Check Nightly Tag and Force Update
220-
#if: github.event_name == 'push' && contains(github.event.ref, 'tags/nightly') == false
221-
if: ${{ ! inputs.skip_tagging_and_releases }}
222+
- name: Check Nightly Tag
223+
if: ${{ !inputs.skip_tagging_and_releases && !inputs.is_PR }}
222224
id: check-nightly-tag-force-update
223225
run: |
224-
# Check if the nightly tag exists and get the commit it points to
225226
if git show-ref --quiet refs/tags/nightly; then
226227
TAG_COMMIT=$(git rev-parse nightly)
227228
else
228229
TAG_COMMIT=""
229230
fi
230-
231-
# If the current commit is the same as the tag, skip updating the tag
231+
232232
if [ "$TAG_COMMIT" != "${{ env.GIT_COMMIT }}" ]; then
233-
echo "releaseRequired=true" >> $GITHUB_ENV
234-
# export tag commit before updating for change logs comparing.
235-
echo "TAG_COMMIT=$TAG_COMMIT" >> $GITHUB_ENV
236-
237-
git config --global user.name 'GitHub Actions'
238-
git config --global user.email 'github-actions@github.com'
239-
git tag -f nightly
240-
git push origin nightly --force
233+
echo "release_required=true" >> "$GITHUB_OUTPUT"
241234
else
242-
echo "Nightly tag already points to this commit. Skipping update."
235+
echo "release_required=false" >> "$GITHUB_OUTPUT"
243236
fi
237+
echo "tag_commit=$TAG_COMMIT" >> "$GITHUB_OUTPUT"
238+
239+
release:
240+
needs: build
241+
runs-on: ubuntu-latest
242+
if: ${{ github.repository_owner == 'Acode-Foundation' && !inputs.is_PR && !inputs.skip_tagging_and_releases && needs.build.outputs.release_output_url }}
243+
permissions:
244+
contents: write
245+
steps:
246+
- name: Checkout Repository
247+
uses: actions/checkout@v7
248+
with:
249+
fetch-depth: 0
250+
persist-credentials: true
244251

252+
- name: Force-update nightly tag
253+
run: |
254+
git config --global user.name 'GitHub Actions'
255+
git config --global user.email 'github-actions@github.com'
256+
git tag -f nightly "${{ github.sha }}"
257+
git push origin nightly --force
258+
259+
- name: Download APK artifacts
260+
uses: actions/download-artifact@v7
261+
with:
262+
path: /tmp/artifacts
263+
245264
# 🚨⚠️ WARNING: the GITHUB_TOKEN under this step, has access to write & read access to Contents, Pull Requests
246265
# Which is why, it uses a fine-granted token with Read-Only Access to Public Repos Only.
247266
- name: Generate Release Notes (Experimental)
248-
if: ${{ success() && env.releaseRequired == 'true' }}
249267
id: gen-release-notes
250268
continue-on-error: true
251269
run: |
252-
RELEASE_NOTES=$(node utils/scripts/generate-release-notes.js ${{ github.repository_owner }} Acode ${{ github.sha }} --format md --from-tag ${{ env.TAG_COMMIT }} --important-only --quiet --changelog-only)
253-
{
254-
echo "RELEASE_NOTES<<EOF"
255-
echo "$RELEASE_NOTES"
256-
echo "EOF"
257-
} >> $GITHUB_ENV
258-
env:
270+
RELEASE_NOTES=$(node utils/scripts/generate-release-notes.js ${{ github.repository_owner }} Acode ${{ github.sha }} --format md --from-tag ${{ needs.build.outputs.tag_commit }} --important-only --quiet || true)
271+
{
272+
echo "RELEASE_NOTES<<EOF"
273+
echo "$RELEASE_NOTES"
274+
echo "EOF"
275+
} >> $GITHUB_ENV
276+
env:
259277
GITHUB_TOKEN: ${{ secrets.NIGHTLY_RELEASE_NOTES_GH_TOKEN }}
278+
260279
- name: Release Nightly Version
261-
# Only run this step, if not called from another workflow. And a previous step is successful with releasedRequired=true
262-
id: release
263-
if: ${{ ! inputs.skip_tagging_and_releases && steps.check-nightly-tag-force-update.outcome == 'success' && env.releaseRequired == 'true' && !inputs.is_PR }}
264280
uses: softprops/action-gh-release@v3
265281
env:
266282
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
267283
with:
268284
prerelease: true
269-
name: ${{ env.UPDATED_VERSION }}
270-
tag_name: ${{ env.UPDATED_VERSION }}
285+
name: ${{ needs.build.outputs.updated_version }}
286+
tag_name: ${{ needs.build.outputs.updated_version }}
271287
files: |
272-
${{ env.NORMAL_APK_PATH }}
273-
${{ env.FDROID_APK_PATH }}
288+
/tmp/artifacts/**/acode-debug-normal-*.apk
289+
/tmp/artifacts/**/acode-debug-fdroid-*.apk
274290
body: |
275291
Automated Nightly (pre-release) Releases for Today
276-
277-
[Compare Changes](https://github.com/${{ github.repository }}/compare/${{ env.TAG_COMMIT }}...${{ github.sha }})
292+
293+
[Compare Changes](https://github.com/${{ github.repository }}/compare/${{ needs.build.outputs.tag_commit }}...${{ github.sha }})
278294
279295
${{ env.RELEASE_NOTES }}
280-
281296
282297
community-release-notifier:
283298
needs: build

0 commit comments

Comments
 (0)