Refactor the way the releases are built #72
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 release artefacts | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
branches: | |
- feature/build-process | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release, use X.Y.Z format' | |
required: true | |
type: string | |
env: | |
FLUTTER_VERSION: 3.22.x | |
RUBY_VERSION: 3.2 | |
JAVA_VERSION: 17 | |
jobs: | |
build_linux: | |
name: Build flathub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Common flutter setup | |
uses: ./.github/actions/flutter-common | |
with: | |
flutter-version: ${{env.FLUTTER_VERSION}} | |
java-version: ${{env.JAVA_VERSION}} | |
ruby-version: ${{env.RUBY_VERSION}} | |
decrypt-playstore: 'false' | |
version: ${{ inputs.version }} | |
- name: Build application for linux | |
run: | | |
sudo apt update | |
sudo apt install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev | |
flutter build linux --release | |
cd flatpak/scripts | |
dart pub get | |
dart flatpak_packager.dart --meta ../flatpak_meta.json --addTodaysVersion ${{ env.VERSION }} | |
# dart flatpak_packager.dart --meta ../flatpak_meta.json --github --addTodaysVersion ${{ env.VERSION }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: builds-linux | |
path: | | |
flatpak/scripts/flatpak_generator_exports/wger-linux-x86_64.tar.gz | |
flatpak/scripts/flatpak_generator_exports/wger-linux-x86_64.sha256 | |
build_android_apk: | |
name: Build android APK file | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Common flutter setup | |
uses: ./.github/actions/flutter-common | |
with: | |
flutter-version: ${{env.FLUTTER_VERSION}} | |
java-version: ${{env.JAVA_VERSION}} | |
ruby-version: ${{env.RUBY_VERSION}} | |
version: ${{ inputs.version }} | |
decrypt-playstore: 'true' | |
key-playstore: ${{ secrets.DECRYPTKEY_PLAYSTORE }} | |
key-playstore-sign: ${{ secrets.DECRYPTKEY_PLAYSTORE_SIGNING_KEY }} | |
key-properties: ${{ secrets.DECRYPTKEY_PROPERTIES }} | |
- name: SDK and NDK cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
/usr/local/lib/android/sdk | |
key: sdk-cache-${{ runner.os }}-${{ hashFiles('**/pubspec.yaml') }} | |
- name: Build APK | |
run: flutter build apk --release | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: builds-apk | |
path: build/app/outputs/flutter-apk/app-release.apk | |
build_android_aab: | |
name: Build android AAB file | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Common flutter setup | |
uses: ./.github/actions/flutter-common | |
with: | |
flutter-version: ${{env.FLUTTER_VERSION}} | |
java-version: ${{env.JAVA_VERSION}} | |
ruby-version: ${{env.RUBY_VERSION}} | |
version: ${{ inputs.version }} | |
decrypt-playstore: 'true' | |
key-playstore: ${{ secrets.DECRYPTKEY_PLAYSTORE }} | |
key-playstore-sign: ${{ secrets.DECRYPTKEY_PLAYSTORE_SIGNING_KEY }} | |
key-properties: ${{ secrets.DECRYPTKEY_PROPERTIES }} | |
- name: Build AAB | |
run: flutter build appbundle --release | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: builds-aab | |
path: build/app/outputs/bundle/release/app-release.aab | |
build_ios: | |
name: Build iOS | |
runs-on: macos-latest | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Common flutter setup | |
uses: ./.github/actions/flutter-common | |
with: | |
flutter-version: ${{env.FLUTTER_VERSION}} | |
java-version: ${{env.JAVA_VERSION}} | |
ruby-version: ${{env.RUBY_VERSION}} | |
version: ${{ inputs.version }} | |
decrypt-playstore: 'false' | |
- name: Build .app | |
run: flutter build ios --release --no-codesign | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: builds-ios | |
path: build/ios/iphoneos/Runner.app | |
build_macos: | |
name: Build macOS | |
runs-on: macos-latest | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Common flutter setup | |
uses: ./.github/actions/flutter-common | |
with: | |
flutter-version: ${{env.FLUTTER_VERSION}} | |
java-version: ${{env.JAVA_VERSION}} | |
ruby-version: ${{env.RUBY_VERSION}} | |
version: ${{ inputs.version }} | |
decrypt-playstore: 'false' | |
- name: Build .app | |
run: flutter build macos --release | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: builds-macos | |
path: build/macos/Build/Products/Release/wger.app | |
# Windows build not possible https://github.com/khoren93/flutter_zxing/issues/93 | |
# build_windows: | |
# name: Build Windows | |
# runs-on: windows-latest | |
# steps: | |
# - name: Common flutter setup | |
# uses: ./.github/actions/flutter-common | |
# with: | |
# flutter-version: ${{env.FLUTTER_VERSION}} | |
# java-version: ${{env.JAVA_VERSION}} | |
# ruby-version: ${{env.RUBY_VERSION}} | |
# version: ${{ inputs.version }} | |
# decrypt-playstore: 'false' | |
# | |
# - name: Build .exe | |
# run: flutter build windows --release -v | |
# | |
# - uses: actions/upload-artifact@v4 | |
# with: | |
# name: builds-windows | |
# path: build/windows/.../wger.exe | |
upload_play_store: | |
if: false | |
name: Upload to Play Store | |
runs-on: ubuntu-latest | |
needs: | |
- build_android_aab | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{env.RUBY_VERSION}} | |
- name: Download builds | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/ | |
- name: Decrypt config files | |
run: | | |
cd ./fastlane/metadata/envfiles | |
chmod +x ./decrypt_secrets.sh | |
./decrypt_secrets.sh | |
env: | |
DECRYPTKEY_PLAYSTORE: ${{ secrets.DECRYPTKEY_PLAYSTORE }} | |
DECRYPTKEY_PLAYSTORE_SIGNING_KEY: ${{ secrets.DECRYPTKEY_PLAYSTORE_SIGNING_KEY }} | |
DECRYPTKEY_PROPERTIES: ${{ secrets.DECRYPTKEY_PROPERTIES }} | |
- name: Upload build to Play Store | |
run: | | |
mkdir -p ./build/app/outputs/bundle/release/ | |
cp /tmp/builds-aab/app-release.aab ./build/app/outputs/bundle/release/app-release.aab | |
bundle install | |
bundle exec fastlane android test_configuration | |
upload_app_store: | |
if: false | |
name: Upload to App Store (placeholder) | |
runs-on: ubuntu-latest | |
needs: | |
- build_ios | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{env.RUBY_VERSION}} | |
- name: Download builds | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/ | |
- name: Decrypt config files | |
run: | | |
cd ./fastlane/metadata/envfiles | |
chmod +x ./decrypt_secrets.sh | |
./decrypt_secrets.sh | |
env: | |
DECRYPTKEY_PLAYSTORE: ${{ secrets.DECRYPTKEY_PLAYSTORE }} | |
DECRYPTKEY_PLAYSTORE_SIGNING_KEY: ${{ secrets.DECRYPTKEY_PLAYSTORE_SIGNING_KEY }} | |
DECRYPTKEY_PROPERTIES: ${{ secrets.DECRYPTKEY_PROPERTIES }} | |
- name: Upload build to Play Store | |
run: | | |
mkdir -p ./build/app/outputs/bundle/release/ | |
cp /tmp/builds-aab/app-release.aab ./build/app/outputs/bundle/release/app-release.aab | |
bundle install | |
bundle exec fastlane android test_configuration | |
# bundle exec fastlane android production | |
cleanup: | |
if: false | |
name: Tag release and update pubspec.yaml | |
runs-on: ubuntu-latest | |
needs: | |
- upload_play_store | |
- upload_app_store | |
- build_android_apk | |
- build_linux | |
- build_macos | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Extract version information | |
run: | | |
echo "BUILD=$(flutter pub run cider version | cut -d '+' -f 2)" >> $GITHUB_ENV | |
- name: Bump pubspec version | |
run: | | |
flutter pub run cider version ${{ inputs.version }}+${{ env.BUILD }} | |
flutter pub run cider bump build | |
- name: Commit pubspec | |
run: | | |
git config user.name Github-Actions | |
git config user.email [email protected] | |
git checkout -b release-${{ inputs.version }} | |
git add pubspec.yaml | |
git tag ${{ inputs.version }} | |
git commit -m "Bump version to $( flutter pub run cider version )" | |
git push --set-upstream origin release-${{ inputs.version }} | |
make_gh_release: | |
name: Make Github Release | |
runs-on: ubuntu-latest | |
needs: | |
- cleanup | |
steps: | |
- name: Download builds | |
uses: actions/download-artifact@v4 | |
- name: Make Github release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ inputs.version }} | |
files: | | |
builds-aab/app-release.aab | |
builds-apk/app-release.apk | |
builds-linux/wger-linux-x86_64.tar.gz | |
builds-linux/wger-linux-x86_64.sha256 | |
builds-ios/Runner.app | |
builds-macos/wger.app | |
generate_fathub_manifest: | |
runs-on: ubuntu-latest | |
name: Upload flathub manifest | |
needs: | |
- cleanup | |
steps: | |
- name: Checkout application | |
uses: actions/checkout@v4 | |
- name: Generate manifest | |
run: | | |
cd flatpak/scripts | |
dart pub get | |
dart manifest_generator.dart --meta ../flatpak_meta.json --github | |
mkdir ../../flathub | |
cp flatpak_generator_exports/de.wger.flutter.json ../../flathub | |
cp flatpak_generator_exports/flathub.json ../../flathub | |
- name: Push updated config to flathub repository | |
uses: cpina/github-action-push-to-another-repository@main | |
env: | |
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} | |
with: | |
source-directory: flathub | |
destination-github-username: wger-project | |
destination-repository-name: de.wger.flutter | |
user-email: [email protected] | |
target-branch: release-${{ inputs.version }} | |
create-target-branch-if-needed: true | |
commit-message: Update to ${{ inputs.version }} | |