nightly #5
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
name: nightly | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
inputs: | |
ignore_commits_force_release: | |
type: boolean | |
description: 'Ignore (new) commits and force a release' | |
default: false | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
ref: 'refactor' | |
- name: "Determine next tag" | |
id: tagger | |
run: | | |
TAG="$(git tag --sort=-v:refname | grep nightly- | head -n 1)" | |
VERSION="$(echo $TAG | sed -e s/[^0-9]//g)" | |
INCREMENT="$((VERSION + 1))" | |
NEW_TAG="nightly-${INCREMENT}" | |
echo next tag "${NEW_TAG}" | |
echo "new_tag=${NEW_TAG}" >> $GITHUB_OUTPUT | |
echo "new_version_id=${INCREMENT}" >> $GITHUB_OUTPUT | |
- name: "Pull upstream" | |
run: | | |
git remote add upstream https://github.com/TeamNewPipe/NewPipe.git | |
git pull upstream refactor | |
- name: "Checking if a release needs to be done" | |
run : | | |
if [[ "${{ inputs.ignore_commits_force_release }}" == "true" ]]; then | |
echo "Ignoring commits - Forcing release" | |
echo "do_release=true" >> $GITHUB_ENV | |
elif [[ "$(git log --since=1.days)" ]]; then | |
echo "New commits found - Will do a release" | |
echo "do_release=true" >> $GITHUB_ENV | |
fi | |
- uses: actions/setup-java@v4 | |
if: ${{ env.do_release == 'true' }} | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
cache: 'gradle' | |
- name: "Build release apk" | |
if: ${{ env.do_release == 'true' }} | |
run: >- | |
./gradlew assembleRelease | |
--stacktrace | |
-DpackageSuffix=refactor.nightly | |
-DversionNameSuffix=-${{ steps.tagger.outputs.new_version_id }}-$(date -u '+%Y%m%d%H%M') | |
-DversionCodeOverride=${{ steps.tagger.outputs.new_version_id }} | |
- name: "Tag commit" | |
if: ${{ env.do_release == 'true' }} | |
run: git tag "${{ steps.tagger.outputs.new_tag }}" | |
- name: "Push to nightly repo" | |
if: ${{ env.do_release == 'true' }} | |
uses: ad-m/[email protected] | |
with: | |
branch: refactor | |
- name: "Sign release" | |
if: ${{ env.do_release == 'true' }} | |
uses: ilharp/sign-android-release@v1 | |
id: sign_app | |
with: | |
releaseDir: app/build/outputs/apk/release | |
signingKey: ${{ secrets.SIGNING_KEY }} | |
keyAlias: ${{ secrets.ALIAS }} | |
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEY_PASSWORD }} | |
buildToolsVersion: 33.0.0 | |
- name: "Rename apk" | |
if: ${{ env.do_release == 'true' }} | |
id: rename_apk | |
run: | | |
mv "${{steps.sign_app.outputs.signedFile}}" "app/build/outputs/apk/release/NewPipe_${{steps.tagger.outputs.new_tag}}.apk" | |
echo "apkFile=app/build/outputs/apk/release/NewPipe_${{steps.tagger.outputs.new_tag}}.apk" >> $GITHUB_OUTPUT | |
- name: "Create GitHub release with APK" | |
if: ${{ env.do_release == 'true' }} | |
uses: softprops/action-gh-release@v2 | |
id: create_release | |
with: | |
tag_name: ${{ steps.tagger.outputs.new_tag }} | |
target_commitish: refactor | |
files: | | |
${{steps.rename_apk.outputs.apkFile}} |