-
Notifications
You must be signed in to change notification settings - Fork 5
140 lines (119 loc) · 4.83 KB
/
nightly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: nightly
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
ignore_commits_force_release:
type: boolean
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: 'dev'
path: workdir
- name: Check if release is required
id: release_check
run: |
last_built_commit=$(cat last-built-commit.txt || echo "")
current_commit=$(cd workdir && git rev-parse HEAD)
echo "Last built commit: $last_built_commit"
echo "Current commit: $current_commit"
do_release=false
if [[ "${{ inputs.ignore_commits_force_release }}" == "true" ]]; then
echo "Ignoring commits - Forcing release"
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: 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=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: Sign release
if: ${{ env.do_release == 'true' }}
uses: ilharp/sign-android-release@d4c98d58d708ca2d2e6a3469b189a5c8260f2896
id: sign_app
with:
releaseDir: workdir/app/build/outputs/apk/release
signingKey: ${{ secrets.SIGNING_KEY }}
keyAlias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
# Version shipped on GitHub's runners can be found at https://github.com/actions/runner-images
# Changelogs can be found at https://developer.android.com/tools/releases/platform-tools
buildToolsVersion: 35.0.1
- name: Rename apk
if: ${{ env.do_release == 'true' }}
id: rename_apk
run: |
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
if: ${{ env.do_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tagger.outputs.new_tag }}
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 "actions@github.com"
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