-
Notifications
You must be signed in to change notification settings - Fork 929
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GHA: Only execute nightly if changes made (#5289)
Task/Issue URL: https://app.asana.com/0/1174433894299346/1208527152986496 ### Description Currently we make nightly releases daily, even if there are no new changes in develop. This PR fixes that, so we only make nightly releases when there are new commits since the last tag. ### Steps to test this PR See task for examples of runs
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: 'Check for code changes after a specific tag' | ||
description: 'Checks if there are any new commits to the develop branch since the specified tag' | ||
|
||
inputs: | ||
tag: | ||
description: 'Tag to check' | ||
required: true | ||
|
||
outputs: | ||
has_changes: | ||
description: Whether there are new commits since the last tag | ||
value: ${{ steps.check_for_changes.outputs.has_changes }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- id: check_for_changes | ||
shell: bash | ||
run: | | ||
# Check if there are any new commits since the tag | ||
new_commits=$(git rev-list ${{ inputs.tag }}..develop --count) | ||
echo "$new_commits commits since ${{ inputs.tag }} tag" | ||
if [ $new_commits -gt 0 ]; then | ||
echo "has_changes=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "has_changes=false" >> $GITHUB_OUTPUT | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,71 +48,101 @@ jobs: | |
echo "Latest tag: $output" | ||
echo "latest_tag=$output" >> $GITHUB_OUTPUT | ||
- name: Check for changes | ||
id: check_for_changes | ||
uses: ./.github/actions/check-for-changes-since-tag | ||
with: | ||
github_token: ${{ secrets.GT_DAXMOBILE }} | ||
tag: ${{ steps.get_latest_tag.outputs.latest_tag }} | ||
|
||
- name: Notify if no changes | ||
if: steps.check_for_changes.outputs.has_changes == 'false' | ||
run: | | ||
echo "No new commits since the last tag. Skipping nightly release." | ||
echo "No new commits since the last tag. Skipping nightly release." >> $GITHUB_STEP_SUMMARY | ||
exit 0 | ||
- name: Decode upload keys | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208 | ||
with: | ||
secret: ${{ secrets.UPLOAD_RELEASE_PROPERTIES }} | ||
fileName: ddg_android_build_upload.properties | ||
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/ | ||
|
||
- name: Decode key file | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208 | ||
with: | ||
secret: ${{ secrets.UPLOAD_RELEASE_KEY }} | ||
fileName: ddg-upload-keystore.jks | ||
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/ | ||
|
||
- name: Decode Play Store credentials file | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208 | ||
with: | ||
secret: ${{ secrets.UPLOAD_PLAY_CREDENTIALS }} | ||
fileName: api.json | ||
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/ | ||
|
||
- name: Decode Firebase credentials file | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208 | ||
with: | ||
secret: ${{ secrets.UPLOAD_FIREBASE_CREDENTIALS }} | ||
fileName: ddg-upload-firebase.json | ||
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/ | ||
|
||
- name: Clean project | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
run: | | ||
gradle clean | ||
- name: Assemble the bundle | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
run: gradle bundleInternalRelease -PversionNameSuffix=-nightly -PuseUploadSigning -PlatestTag=${{ steps.get_latest_tag.outputs.latest_tag }} | ||
|
||
- name: Generate nightly version name | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
id: generate_version_name | ||
run: | | ||
output=$(gradle getBuildVersionName -PversionNameSuffix=-nightly -PlatestTag=${{ steps.get_latest_tag.outputs.latest_tag }} --quiet | tail -n 1) | ||
echo "version=$output" >> $GITHUB_OUTPUT | ||
- name: Capture App Bundle Path | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
id: capture_output | ||
run: | | ||
output=$(find app/build/outputs/bundle/internalRelease -name "*.aab") | ||
echo "bundle_path=$output" >> $GITHUB_OUTPUT | ||
- name: Upload bundle to Play Store Internal track | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
id: create_app_bundle | ||
run: | | ||
bundle exec fastlane deploy_dogfood aab_path:${{ steps.capture_output.outputs.bundle_path }} | ||
- name: Tag Nightly release | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
id: tag_nightly_release | ||
run: | | ||
git checkout develop | ||
git tag -a ${{ steps.generate_version_name.outputs.version }} -m "Create tag ${{ steps.generate_version_name.outputs.version }} for nightly release." | ||
git push origin ${{ steps.generate_version_name.outputs.version }} | ||
- name: Upload APK as artifact | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: duckduckgo-${{ steps.generate_version_name.outputs.version }}.apk | ||
path: duckduckgo.apk | ||
|
||
- name: Set successful summary | ||
if: steps.check_for_changes.outputs.has_changes == 'true' | ||
run: | | ||
echo "### Nightly release completed! :rocket:" >> $GITHUB_STEP_SUMMARY | ||
- name: Create Asana task when workflow failed | ||
if: ${{ failure() }} | ||
uses: duckduckgo/[email protected] | ||
|