Move debug menu to settings and enable it only in debug mode #57
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 app | |
on: | |
push: | |
paths: | |
- ".github/workflows/build.yaml" | |
- "android/**" | |
- "lib/**" | |
- "web/**" | |
- "analysis_options.yaml" | |
- "CHANGELOG.md" | |
- "pubspec.yaml" | |
- "pubspec.lock" | |
pull_request: | |
paths: | |
- ".github/workflows/build.yaml" | |
- "android/**" | |
- "lib/**" | |
- "web/**" | |
- "analysis_options.yaml" | |
- "pubspec.yaml" | |
- "pubspec.lock" | |
env: | |
JAVA_VERSION: "17" | |
JAVA_DISTRIBUTION: temurin | |
FLUTTER_CHANNEL: beta | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
name: Lint code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Install Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Install Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: ${{ env.FLUTTER_CHANNEL }} | |
cache: "true" | |
- name: Get Flutter dependencies | |
run: flutter pub get | |
- name: Analyze code | |
run: flutter analyze | |
- name: Check formatting | |
run: dart format --set-exit-if-changed --output none --line-length=100 lib/ | |
build-apk: | |
name: Build app for Android | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Install Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
java-version: ${{ env.JAVA_VERSION }} | |
cache: gradle | |
- name: Install Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: ${{ env.FLUTTER_CHANNEL }} | |
cache: "true" | |
- name: Get Flutter dependencies | |
run: flutter pub get | |
- name: Decode keystore file | |
env: | |
KEYSTORE_CONTENTS: ${{ secrets.KEYSTORE_CONTENTS }} | |
run: | | |
echo "$KEYSTORE_CONTENTS" | base64 -d >android/keystore.jks | |
- name: Build app for Android | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
run: flutter build apk --release --split-per-abi | |
- name: Upload APK artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android-apks | |
if-no-files-found: error | |
path: | | |
build/app/outputs/flutter-apk/app-*.apk | |
build/app/outputs/flutter-apk/app-*.apk.sha1 | |
build-web: | |
name: Build app for web | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Install Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Install Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: ${{ env.FLUTTER_CHANNEL }} | |
cache: true | |
- name: Get Flutter dependencies | |
run: flutter pub get | |
- name: Build app for web | |
run: flutter build web | |
- name: Patch app name for web | |
run: | | |
jq -c '.app_name = "Mafia companion"' build/web/version.json >build/web/version.new.json | |
mv build/web/version{.new,}.json | |
- name: Upload web artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: build/web/ | |
publish-web: | |
name: Publish web build on GitHub Pages | |
runs-on: ubuntu-latest | |
needs: | |
- build-web | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Publish web on GitHub pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
create-release: | |
name: Create release | |
runs-on: ubuntu-latest | |
needs: | |
- build-apk | |
permissions: | |
contents: write | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download APK artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: android-apks | |
path: build | |
- name: Generate release notes | |
id: release_notes | |
run: | | |
file="$(mktemp --suffix=.md)" | |
previous_tag="$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^")" | |
start_line="$(grep -En "## \[v?$GITHUB_REF_NAME\]" CHANGELOG.md | cut -d ':' -f 1)" | |
end_line="$(grep -En "## \[v?$previous_tag\]" CHANGELOG.md | cut -d ':' -f 1)" | |
sed -n "$((${start_line} + 1)),$((${end_line} - 1))p" CHANGELOG.md >$file | |
sed -Ei 's/###/##/;1{/^\s*$/d}' $file | |
# ChatGPT-powered magic to remove trailing empty lines | |
sed -i ':l;/^\n*$/{$d;N;bl;}' $file | |
echo -ne '\n## Commits\n\n' >>$file | |
git log --format="- %h: %s (%aN)" "${previous_tag}..${GITHUB_REF_NAME}" >>$file | |
echo "$GITHUB_REF_NAME" | awk '{ print "prerelease=" (($1 ~ /v[0-9]+\.[0-9]+\.[0-9]+-.+/) ? "true" : "false"); }' >>$GITHUB_OUTPUT | |
echo "release_notes=$file" >>$GITHUB_OUTPUT | |
- name: Create a release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: ${{ steps.release_notes.outputs.release_notes }} | |
prerelease: ${{ steps.release_notes.outputs.prerelease }} | |
files: | | |
build/app-*.apk | |
fail_on_unmatched_files: true |