-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/github_actions' into sync-chan…
…ges-from-nightly
- Loading branch information
Showing
3 changed files
with
77 additions
and
39 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 |
---|---|---|
|
@@ -7,78 +7,99 @@ on: | |
inputs: | ||
ignore_commits_force_release: | ||
type: boolean | ||
description: 'Ignore (new) commits and force a release' | ||
description: 'Do not check for new commits / Force new release' | ||
default: false | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# This is required for checking out the tags, so that the next tag can be computed | ||
fetch-depth: '0' | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
repository: 'TeamNewPipe/NewPipe' | ||
ref: 'refactor' | ||
token: ${{secrets.ACCESS_TOKEN}} | ||
|
||
- name: "Determine next tag" | ||
id: tagger | ||
path: workdir | ||
- name: Check if release is required | ||
id: release_check | ||
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 | ||
last_built_commit=$(cat last-built-commit.txt || echo "") | ||
current_commit=$(cd workdir && git rev-parse HEAD) | ||
- name: "Pull upstream" | ||
run: | | ||
git remote add upstream https://github.com/TeamNewPipe/NewPipe.git | ||
git pull upstream refactor | ||
echo "Last built commit: $last_built_commit" | ||
echo "Current commit: $current_commit" | ||
do_release=false | ||
- 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 | ||
do_release=true | ||
elif [[ "$last_built_commit" != "$current_commit" ]]; then | ||
echo "Commits differ - Will do a release" | ||
do_release=true | ||
fi | ||
if [[ "$do_release" != "true" ]]; then | ||
echo "No release required: Nothing changed" | ||
exit 0 | ||
fi | ||
echo "Saving current commit to file" | ||
echo "$current_commit" > last-built-commit.txt | ||
echo "do_release=true" >> $GITHUB_ENV | ||
echo "current_commit=$current_commit" >> $GITHUB_OUTPUT | ||
- uses: actions/setup-java@v4 | ||
if: ${{ env.do_release == 'true' }} | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
cache: 'gradle' | ||
|
||
- name: "Build release apk" | ||
- name: Determine next tag | ||
if: ${{ env.do_release == 'true' }} | ||
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: Build release apk | ||
if: ${{ env.do_release == 'true' }} | ||
working-directory: workdir | ||
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" | ||
- 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: | ||
github_token: ${{secrets.ACCESS_TOKEN}} | ||
branch: refactor | ||
|
||
- name: "Sign release" | ||
- name: Sign release | ||
if: ${{ env.do_release == 'true' }} | ||
uses: ilharp/sign-android-release@d4c98d58d708ca2d2e6a3469b189a5c8260f2896 | ||
id: sign_app | ||
with: | ||
releaseDir: app/build/outputs/apk/release | ||
releaseDir: workdir/app/build/outputs/apk/release | ||
signingKey: ${{ secrets.SIGNING_KEY }} | ||
keyAlias: ${{ secrets.ALIAS }} | ||
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | ||
|
@@ -87,19 +108,33 @@ jobs: | |
# Changelogs can be found at https://developer.android.com/tools/releases/platform-tools | ||
buildToolsVersion: 35.0.1 | ||
|
||
- name: "Rename apk" | ||
- 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 | ||
mv "${{steps.sign_app.outputs.signedFile}}" "workdir/app/build/outputs/apk/release/NewPipe_${{steps.tagger.outputs.new_tag}}.apk" | ||
echo "apkFile=workdir/app/build/outputs/apk/release/NewPipe_${{steps.tagger.outputs.new_tag}}.apk" >> $GITHUB_OUTPUT | ||
- name: "Create GitHub release with APK" | ||
- 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 | ||
body: | | ||
Build of [``${{ steps.release_check.outputs.current_commit }}``](https://github.com/TeamNewPipe/NewPipe/commit/${{ steps.release_check.outputs.current_commit }}) | ||
files: | | ||
${{steps.rename_apk.outputs.apkFile}} | ||
- name: Commit changed files | ||
if: ${{ env.do_release == 'true' }} | ||
run: | | ||
echo "Removing workdir" | ||
rm -rf workdir | ||
echo "Configuring git" | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions" | ||
echo "Committing changed tracking files" | ||
git add -A || true | ||
git commit -m "Updated tracking files" && git push || true |
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,2 @@ | ||
*.apk | ||
workdir/ |
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 @@ | ||
ba86ce137bb5ecd4beda76bd7616381831268fbb |