Release #302
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: Release | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- '.github/workflows/release.yml' | |
- 'module/**' | |
- 'update.json' | |
- 'tileapp/**' | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Set variables | |
id: setup | |
run: | | |
COMMIT_ID=$(git rev-parse --short HEAD) | |
CURRENT_VERSION_CODE=$(jq -r .versionCode update.json) | |
PREVIOUS_VERSION_CODE=$(jq -r .versionCode <(git show HEAD~1:update.json)) | |
VERSION=$(jq -r .version update.json) | |
echo "COMMIT_ID=$COMMIT_ID" | |
echo "CURRENT_VERSION_CODE=$CURRENT_VERSION_CODE" | |
echo "PREVIOUS_VERSION_CODE=$PREVIOUS_VERSION_CODE" | |
echo "VERSION=$VERSION" | |
echo "COMMIT_ID=$COMMIT_ID" >> $GITHUB_ENV | |
echo "CURRENT_VERSION_CODE=$CURRENT_VERSION_CODE" >> $GITHUB_ENV | |
echo "PREVIOUS_VERSION_CODE=$PREVIOUS_VERSION_CODE" >> $GITHUB_ENV | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
if [ "$CURRENT_VERSION_CODE" -gt "$PREVIOUS_VERSION_CODE" ]; then | |
echo "version_changed=true" >> $GITHUB_ENV | |
echo "ZIP_NAME=bindhosts" >> $GITHUB_ENV | |
else | |
echo "version_changed=false" >> $GITHUB_ENV | |
echo "ZIP_NAME=bindhosts_$CURRENT_VERSION_CODE-$COMMIT_ID" >> $GITHUB_ENV | |
fi | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: '21' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
- name: Write key | |
if: ${{ (github.event_name != 'pull_request') || github.ref_type == 'tag' }} | |
run: | | |
if [ ! -z "${{ secrets.KEYSTORE }}" ]; then | |
{ | |
echo KEYSTORE_PASSWORD='${{ secrets.KEYSTORE_PASSWORD }}' | |
echo KEY_ALIAS='${{ secrets.KEY_ALIAS }}' | |
echo KEY_PASSWORD='${{ secrets.KEY_PASSWORD }}' | |
echo KEYSTORE_FILE='key.jks' | |
} >> gradle.properties | |
echo "${{ secrets.KEYSTORE }}" | base64 -d > key.jks | |
fi | |
echo "KEYSTORE_FILE=$(pwd)/key.jks" >> $GITHUB_ENV | |
echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> $GITHUB_ENV | |
echo "KEY_ALIAS=${{ secrets.KEY_ALIAS }}" >> $GITHUB_ENV | |
echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> $GITHUB_ENV | |
- name: Build the Android app | |
run: | | |
cd tileapp/ | |
./gradlew clean assembleRelease | |
- name: Copy app-release.apk to /module/common/ | |
run: | | |
cp tileapp/app/build/outputs/apk/release/app-release.apk ./module/common/app-release.apk | |
echo "app-release.apk copied to /module/common/" | |
- name: Upload APK as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: app-release-apk | |
path: tileapp/app/build/outputs/apk/release/app-release.apk | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ZIP_NAME }} | |
path: module/ | |
- name: Compressing files | |
if: env.version_changed == 'true' | |
run: | | |
echo "Compressing files..." | |
cd module/ | |
zip -r "${{ env.ZIP_NAME }}" * | |
mv *.zip ../ | |
echo "Created zip file: ${{ env.ZIP_NAME }}" | |
- name: Create release | |
if: env.version_changed == 'true' | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: ${{ env.ZIP_NAME }}.zip | |
tag_name: "${{ env.VERSION }}" | |
name: "Release ${{ env.VERSION }}" | |
body_path: CHANGELOG.md | |
draft: false | |
prerelease: false |