foss @ ce758292d4f8818e27d08cffa15317324384d068 #63
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: Build FOSS | |
run-name: foss @ ${{ github.sha }} | |
on: | |
workflow_dispatch: | |
inputs: | |
version_name: | |
description: Version name | |
default: 1.0.0 | |
required: true | |
version_code: | |
description: Version code | |
default: 100000 | |
required: true | |
concurrency: ${{ github.ref }} | |
env: | |
filename: delta-v${{ inputs.version_name }}-foss | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 18 | |
- name: Install dependencies | |
run: | | |
sudo pip install -r resources/utilities/requirements.txt | |
- name: Add new icons | |
run: | | |
python -u resources/utilities/add_icons_wrapper.py | |
- name: Change version | |
run: | | |
python - << EOF | |
import re | |
target = 'app/build.gradle' | |
regexp_version_code = re.compile('versionCode (\d+)') | |
regexp_version_name = re.compile('versionName "(\d+\.\d+\.\d+(-beta\d+)?)"') | |
with open(target, 'r+') as file: | |
content = file.read() | |
content = re.sub(regexp_version_code, f'versionCode ${{ inputs.version_code }}', content) | |
content = re.sub(regexp_version_name, f'versionName "${{ inputs.version_name }}"', content) | |
file.seek(0) | |
file.write(content) | |
file.truncate() | |
EOF | |
- name: Set custom icons count | |
run: | | |
drawable_xml=app/src/main/res/xml/drawable.xml | |
drawable_lines=$(grep '<item' $drawable_xml | sort) | |
summary=$(echo "$drawable_lines" | wc -l) | |
amount_all=$(echo "$drawable_lines" | uniq | wc -l) | |
amount_new=$(( $summary - $amount_all )) | |
shortcut=java/website/leifs/delta/applications/CandyBar.java | |
sed -i "s|setCustomIconsCount\(.*\);|setCustomIconsCount\($amount_all\);|" app/src/foss/$shortcut | |
sed -i "s|setCustomIconsCount\(.*\);|setCustomIconsCount\($amount_all\);|" app/src/play/$shortcut | |
- name: Create changelog | |
run: | | |
cat << EOF > app/src/main/res/values/changelog.xml | |
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<string name="changelog_date"></string> | |
<string-array name="changelog"> | |
<item><![CDATA[<font color=#ff837d><item>¯\\_(ツ)_/¯</item></font>]]></item> | |
</string-array> | |
</resources> | |
EOF | |
- name: Sort drawables | |
run: | | |
python resources/utilities/sort_drawable.py app/src/main/assets/drawable.xml | |
cp -v new_drawable.xml app/src/main/assets/drawable.xml | |
cp -v new_drawable.xml app/src/main/res/xml/drawable.xml | |
- name: Build APK | |
run: bash gradlew assembleFoss | |
- name: Move unsigned APK | |
run: mv -v app/build/outputs/apk/foss/release/*.apk ${{ env.filename }}-unsigned.apk | |
- name: Sign APK | |
uses: kevin-david/[email protected] | |
id: sign_step | |
with: | |
releaseDirectory: . | |
signingKeyBase64: ${{ secrets.KEYSTORE_BASE64 }} | |
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEYSTORE_KEY_PASSWORD }} | |
alias: ${{ secrets.KEYSTORE_KEY_ALIAS }} | |
- name: Move signed APK | |
run: mv -v ${{ steps.sign_step.outputs.signedReleaseFile }} ${{ env.filename }}.apk | |
- name: Upload signed APK in Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.filename }} | |
retention-days: 7 | |
path: ${{ env.filename }}.apk |