Update Java Version #253
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 for Android | |
on: | |
push: | |
jobs: | |
build: | |
name: Build APK | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v2 | |
- name: Set up Java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '17.x' | |
- name: Install flutter | |
uses: subosito/flutter-action@v1 | |
- name: Install app dependencies (flutter pub get) | |
run: flutter pub get | |
- name: Run tests | |
run: flutter test | |
- name: Extract app variables to workflow env | |
run: | | |
sudo wget -q "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64" -O "/usr/bin/yq" | |
sudo chmod +x /usr/bin/yq | |
echo "APP_VERSION=$(yq eval .version pubspec.yaml | cut -d+ -f1)" >> $GITHUB_ENV | |
echo "COMMIT_MESSAGE=$(git log -n 1 --oneline | cut -d' ' -f2- -)" >> $GITHUB_ENV | |
echo "CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | |
- name: Set up signing config | |
run: | | |
echo "${{ secrets.SIGNING_KEYSTORE_CONTENT }}" | base64 -d - > upload-keystore.jks | |
export X_KEYSTORE_PATH="$(pwd)/upload-keystore.jks" | |
echo "X_KEYSTORE_PATH=$X_KEYSTORE_PATH" >> $GITHUB_ENV | |
echo "${{ secrets.SIGNING_PROPERTIES_CONTENT }}" > android/key.properties | |
- name: Build signed APK | |
run: flutter build apk --release | |
env: | |
X_KEYSTORE_PATH: ${{ env.X_KEYSTORE_PATH }} | |
- name: Show APK hashes | |
run: find build/app/outputs -type f -name "*.apk" | xargs -L1 sha256sum | |
- name: Generate diff from commit messages | |
run: | | |
# Download tags which the following git command needs | |
git fetch --prune --unshallow | |
# Now generate a diff using commit messages | |
echo "Changes:" > out.md | |
git log $(git describe --tags --abbrev=0)..HEAD --oneline --decorate=no | sed "s/^[^ ]* /* /" >> out.md | |
- name: Upload release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
build/app/outputs/flutter-apk/*-release.apk | |
tag_name: v${{ env.APP_VERSION }} | |
name: ${{ env.COMMIT_MESSAGE }} | |
fail_on_unmatched_files: true | |
draft: true | |
body_path: out.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ env.CURRENT_BRANCH == 'main' && (startsWith(env.COMMIT_MESSAGE, '[Release]') || startsWith(env.COMMIT_MESSAGE, 'Release')) }} |