-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
97 additions
and
85 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 |
---|---|---|
@@ -1,119 +1,114 @@ | ||
name: Checkout & Build App | ||
name: Build automatic release | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-22.04 | ||
runs-on: ubuntu-24.04 | ||
outputs: | ||
should_build: ${{ steps.check-updates.outputs.has_changes }} | ||
steps: | ||
- name: Check for updates 🌏 | ||
id: check-updates | ||
run: | | ||
last_run=$(curl -s "https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/runs?status=completed&per_page=1" | jq -r '.workflow_runs[0].created_at') | ||
kotatsu_updated=$(curl -s "https://api.github.com/repos/KotatsuApp/Kotatsu/commits?since=$last_run" | jq '. | length') | ||
parsers_updated=$(curl -s "https://api.github.com/repos/KotatsuApp/kotatsu-parsers/commits?since=$last_run" | jq '. | length') | ||
if [ "$kotatsu_updated" -gt "0" ] || [ "$parsers_updated" -gt "0" ]; then | ||
echo "has_changes=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "has_changes=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Check for updates 🌏 | ||
id: check-updates | ||
run: | | ||
last_run=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r '.created_at') | ||
kotatsu_updated=$(curl -s "https://api.github.com/repos/KotatsuApp/Kotatsu/commits?since=$last_run" | jq '. | length') | ||
parsers_updated=$(curl -s "https://api.github.com/repos/KotatsuApp/kotatsu-parsers/commits?since=$last_run" | jq '. | length') | ||
if [ "$kotatsu_updated" -gt "0" ] || [ "$parsers_updated" -gt "0" ]; then | ||
echo "has_changes=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "has_changes=false" >> $GITHUB_OUTPUT | ||
fi | ||
build: | ||
needs: check | ||
if: needs.check.outputs.should_build == 'true' | ||
runs-on: ubuntu-22.04 | ||
runs-on: ubuntu-24.04 | ||
outputs: | ||
new_tag: ${{ steps.tagger.outputs.new_tag }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: base | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: autobuild | ||
|
||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'gradle' | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'gradle' | ||
|
||
- name: Setup Android SDK 💻 | ||
uses: android-actions/setup-android@v3 | ||
- name: Setup Android SDK 💻 | ||
uses: android-actions/setup-android@v3 | ||
|
||
- name: Grant permissions 💻 | ||
run: chmod a+x gradlew | ||
- name: Grant permissions 💻 | ||
run: chmod a+x gradlew | ||
|
||
- name: Generate build number 📆 | ||
id: tagger | ||
run: | | ||
echo "new_tag=$(./gradlew -q versionInfo)" >> $GITHUB_OUTPUT | ||
echo "formatted_date=$(date +'%Y/%m/%d')" >> $GITHUB_OUTPUT | ||
- name: Generate build number 📆 | ||
id: tagger | ||
run: | | ||
echo "new_tag=$(./gradlew -q versionInfo -DbuildNumberIncrement=true)" >> $GITHUB_OUTPUT | ||
echo "formatted_date=$(date +'%Y/%m/%d')" >> $GITHUB_OUTPUT | ||
- name: Building new APK 💻 | ||
run: >- | ||
./gradlew assembleRelease | ||
-DbuildNumberIncrement=true | ||
-DparsersVersionOverride=$(curl -s https://api.github.com/repos/kotatsuapp/kotatsu-parsers/commits/master -H "Accept: application/vnd.github.sha" | cut -c -10) | ||
- name: Decode Keystore | ||
id: decode_keystore | ||
uses: timheuer/base64-to-file@v1 | ||
with: | ||
fileName: 'keystore/kotatsu.jks' | ||
encodedString: ${{ secrets.ANDROID_SIGNING_KEY }} | ||
|
||
- name: Packaging new APK 💻 | ||
uses: ilharp/sign-android-release@v1 | ||
id: sign_app | ||
with: | ||
releaseDir: app/build/outputs/apk/release | ||
signingKey: ${{ secrets.ANDROID_SIGNING_KEY }} | ||
keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }} | ||
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | ||
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} | ||
buildToolsVersion: 35.0.0 | ||
- name: Building new APK 💻 | ||
run: >- | ||
./gradlew assembleRelease | ||
-DparsersVersionOverride=$(curl -s https://api.github.com/repos/kotatsuapp/kotatsu-parsers/commits/master -H "Accept: application/vnd.github.sha" | cut -c -10) | ||
- name: Prepare to Upload 🌏 | ||
run: | | ||
mv ${{steps.sign_app.outputs.signedFile}} app/build/outputs/apk/release/release.apk | ||
echo "SIGNED_APK=app/build/outputs/apk/release/release.apk" >> $GITHUB_ENV | ||
- name: Prepare to Upload 🌏 | ||
run: | | ||
mv ${{steps.sign_app.outputs.signedFile}} app/build/outputs/apk/release/release.apk | ||
echo "SIGNED_APK=app/build/outputs/apk/release/release.apk" >> $GITHUB_ENV | ||
- name: Get latest changes 📑 | ||
id: changelog | ||
run: | | ||
CHANGELOG=$(cat CHANGELOG.txt) | ||
echo "content<<EOF" >> $GITHUB_OUTPUT | ||
echo "$CHANGELOG" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Get latest changes 📑 | ||
id: changelog | ||
run: | | ||
CHANGELOG=$(cat CHANGELOG.txt) | ||
echo "content<<EOF" >> $GITHUB_OUTPUT | ||
echo "$CHANGELOG" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Create new GH Release + Uploading 🌏 | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: v${{ steps.tagger.outputs.new_tag }} | ||
name: "Build ${{ steps.tagger.outputs.new_tag }}" | ||
body: | | ||
Automated build generated on ${{ steps.tagger.outputs.formatted_date }} | ||
${{ steps.changelog.outputs.content }} | ||
files: ${{ env.SIGNED_APK }} | ||
prerelease: false | ||
- name: Create new GH Release + Uploading 🌏 | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: v${{ steps.tagger.outputs.new_tag }} | ||
name: "Build ${{ steps.tagger.outputs.new_tag }}" | ||
body: | | ||
Automated build generated on ${{ steps.tagger.outputs.formatted_date }} | ||
${{ steps.changelog.outputs.content }} | ||
files: ${{ env.SIGNED_APK }} | ||
prerelease: false | ||
|
||
update: | ||
needs: build | ||
if: needs.check.outputs.should_build == 'true' | ||
runs-on: ubuntu-22.04 | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: master | ||
fetch-depth: 0 | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: autobuild | ||
fetch-depth: 0 | ||
|
||
- name: Commit 🌏 | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "autorelease" | ||
if [[ -n $(git status -s) ]]; then | ||
git add README.md | ||
git commit -m "Automatic release v${{ needs.build.outputs.new_tag }}" | ||
git push origin master | ||
else | ||
echo "No changes to push!" | ||
fi | ||
- name: Commit 🌏 | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "autorelease" | ||
if [[ -n $(git status -s) ]]; then | ||
git add README.md | ||
git commit -m "Automatic release v${{ needs.build.outputs.new_tag }}" | ||
git push origin autobuild | ||
else | ||
echo "No changes to push!" | ||
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