prod @ 861911181f2e876cd39a2001960ef14354237d53 #116
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 All | |
run-name: ${{ inputs.release_type }} @ ${{ github.sha }} | |
permissions: | |
contents: write | |
concurrency: | |
group: delta | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
description: Release type | |
default: beta | |
type: choice | |
options: | |
- beta | |
- prod | |
build_foss: | |
description: Build FOSS | |
type: boolean | |
default: true | |
publish: | |
description: Publish the app | |
type: boolean | |
default: true | |
changelog_1: | |
description: Changelog 1 | |
changelog_2: | |
description: Changelog 2 | |
changelog_3: | |
description: Changelog 3 | |
changelog_4: | |
description: Changelog 4 | |
env: | |
token: ${{ secrets.PA_TOKEN || github.token }} | |
organization: Delta-Icons | |
current_repo: ${{ github.repository }} | |
website_repo: Delta-Icons/delta-icons.github.io | |
package_name: website.leifs.delta | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ env.token }} | |
fetch-depth: 0 | |
- name: Export variables | |
run: | | |
python -u .github/scripts/resolve_paths.py -p >> $GITHUB_ENV | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 18 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y optipng | |
sudo pip install -r ${{ env.sd }}/requirements.txt | |
- name: Configure tools | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
cat << EOF >> $GITHUB_ENV | |
coauthor='Co-authored-by: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>' | |
EOF | |
- name: Bump version | |
run: | | |
python \ | |
-u ${{ env.sd }}/bump_version.py -p \ | |
-t ${{ inputs.release_type }} >> $GITHUB_ENV | |
- name: Add new icons | |
run: | | |
python -u ${{ env.sd }}/add_icons_wrapper.py | |
- name: Create a changelog and set custom icons count | |
run: | | |
mkdir changelog | |
changelog_txt=metadata/en-US/changelogs/${{ env.version_code }}.txt | |
changelog_tmp=changelog/whatsnew-en-US | |
changelog_xml=app/src/main/res/values/changelog.xml | |
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 )) | |
candybar_play=app/src/play/java/website/leifs/delta/applications/CandyBar.java | |
candybar_foss=app/src/foss/java/website/leifs/delta/applications/CandyBar.java | |
sed -i "s|setCustomIconsCount\(.*\);|setCustomIconsCount\($amount_all\);|" $candybar_play | |
sed -i "s|setCustomIconsCount\(.*\);|setCustomIconsCount\($amount_all\);|" $candybar_foss | |
changelog_1='${{ inputs.changelog_1 }}' | |
changelog_2='${{ inputs.changelog_2 }}' | |
changelog_3='${{ inputs.changelog_3 }}' | |
changelog_4='${{ inputs.changelog_4 }}' | |
echo "- $amount_new new icons, $amount_all in total" > $changelog_txt | |
cat << EOF > $changelog_xml | |
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<string name="changelog_date"></string> | |
<string-array name="changelog"> | |
<item><![CDATA[<font color=#ff837d>$amount_new</font> new icons, <font color=#ff837d>$amount_all</font> in total]]></item> | |
EOF | |
if [[ '${{ inputs.release_type }}' == 'prod' ]]; then | |
echo "- Fixed icons not applying properly" >> $changelog_txt | |
echo " <item>Fixed icons not applying properly</item>" >> $changelog_xml | |
for n in $(seq 1 4); do | |
changelog="changelog_${n}" | |
if [ ! -z "${!changelog}" ]; then | |
echo "- ${!changelog}" >> $changelog_txt | |
echo " <item>${!changelog}</item>" >> $changelog_xml | |
fi | |
done | |
fi | |
if [[ '${{ inputs.release_type }}' == 'beta' ]]; then | |
message="Full changelog will be published upon release!" | |
echo "- $message" >> $changelog_txt | |
echo " <item>$message</item>" >> $changelog_xml | |
fi | |
cat << EOF >> $changelog_xml | |
</string-array> | |
</resources> | |
EOF | |
cp $changelog_txt $changelog_tmp | |
cat $changelog_xml | |
echo "changelog=$changelog_tmp" >> $GITHUB_ENV | |
- name: Optimize images | |
run: | | |
latest_tag=$(git tag --sort version:refname | grep -v 'beta' | tail -n 1) | |
if [[ $latest_tag ]]; then | |
echo "Latest tag is $latest_tag; optimizing images since this tag" | |
optipng $(git diff --name-only $latest_tag -- "***.png") || true | |
else | |
echo 'No release found, skip optimizing' | |
fi | |
- name: Sort appfilter and drawable | |
run: | | |
cd ${{ env.sd }} | |
python sort_appfilter.py -o | |
python sort_drawable.py -o | |
cp -fv ${{ env.a1 }} ${{ env.a2 }} | |
cp -fv ${{ env.d1 }} ${{ env.d2 }} | |
- name: Commit pre-build changes | |
run: | | |
git add \ | |
app/build.gradle \ | |
app/src/ \ | |
contribs/ \ | |
metadata/ \ | |
resources/vectors/ | |
git commit -m 'Release: ${{ env.version }}' --author "${{ env.coauthor }}" | |
- name: Build APK | |
run: | | |
bash gradlew assemblePlay | |
- name: Build AAB | |
run: | | |
bash gradlew bundlePlay | |
if: | | |
inputs.publish == true | |
- name: Build APK FOSS | |
run: | | |
bash gradlew assembleFoss | |
if: | | |
inputs.build_foss == true | |
- name: Move unsigned builds | |
run: | | |
builds=$(find . -regextype posix-egrep -regex '.*-(release|unsigned).(aab|apk)$') | |
if [ -z "${builds}" ]; then | |
echo 'no builds found' | |
exit 1 | |
fi | |
for build in ${builds[@]}; do | |
mv -v $build . 2> /dev/null || true | |
done | |
- name: Sign builds | |
uses: kevin-david/zipalign-sign-android-release@main | |
with: | |
releaseDirectory: . | |
signingKeyBase64: ${{ secrets.KEYSTORE_BASE64 }} | |
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEYSTORE_KEY_PASSWORD }} | |
alias: ${{ secrets.KEYSTORE_KEY_ALIAS }} | |
- name: Rename signed builds | |
run: | | |
rm -v *unsigned.apk | |
mv -v *foss*.apk ${{ env.filename }}-foss.apk 2> /dev/null || true | |
mv -v *play*.apk ${{ env.filename }}.apk 2> /dev/null || true | |
mv -v *play*.aab ${{ env.filename }}.aab 2> /dev/null || true | |
- name: Upload APKs to Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.filename }} | |
path: ${{ env.filename }}*.apk | |
if-no-files-found: error | |
retention-days: 90 | |
- name: Push pre-build changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ env.token }} | |
branch: ${{ github.ref }} | |
if: | | |
inputs.publish == true | |
- name: Create a GitHub release | |
uses: softprops/action-gh-release@v2 | |
with: | |
prerelease: ${{ env.is_beta }} | |
files: '${{ env.filename }}*.apk' | |
name: ${{ env.version }} | |
tag_name: ${{ env.version }} | |
body_path: ${{ env.changelog }} | |
if: | | |
inputs.publish == true | |
- name: Commit post-release changes | |
run: | | |
sed -i '7,/^$/c\\' ${{ env.d1 }} ${{ env.d2 }} | |
git add ${{ env.d1 }} ${{ env.d2 }} | |
git commit -m "Cleanup: ${{ env.version }}" --author "${{ env.coauthor }}" | |
if: | | |
inputs.release_type == 'prod' && | |
inputs.publish == true | |
- name: Push post-release changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ env.token }} | |
branch: ${{ github.ref }} | |
if: | | |
inputs.release_type == 'prod' && | |
inputs.publish == true | |
- name: Upload AAB to Google Play beta channel | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
track: beta | |
status: completed | |
releaseFiles: ${{ env.filename }}.aab | |
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT }} | |
packageName: ${{ env.package_name }} | |
mappingFile: app/build/outputs/mapping/playRelease/mapping.txt | |
whatsNewDirectory: changelog | |
inAppUpdatePriority: 5 | |
if: | | |
github.repository_owner == env.organization && | |
inputs.publish == true | |
- name: Promote beta to production channel | |
uses: kevin-david/[email protected] | |
with: | |
service-account-json-raw: ${{ secrets.SERVICE_ACCOUNT }} | |
package-name: ${{ env.package_name }} | |
inapp-update-priority: 5 | |
user-fraction: 1.0 | |
if: | | |
github.repository_owner == env.organization && | |
inputs.release_type == 'prod' && | |
inputs.publish == true | |
- name: Update the website | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
token: ${{ env.token }} | |
repo: ${{ env.website_repo }} | |
workflow: deploy.yml | |
if: | | |
github.repository_owner == env.organization && | |
inputs.release_type == 'prod' && | |
inputs.publish == true | |
- name: Update the requests list | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
repo: ${{ github.repository }} | |
workflow: update_requests.yml | |
token: ${{ env.token }} | |
if: | | |
github.repository_owner == env.organization && | |
inputs.release_type == 'prod' && | |
inputs.publish == true |