Skip to content

build: Fix CICD

build: Fix CICD #31

Workflow file for this run

name: "Build & deploy for Android, Linux, Web and Windows"
on:
push:
tags: ['v*']
jobs:
build_android:
name: Build and release Android app
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Flutter version
run: flutter --version
- name: Bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Download Android keystore
id: android_keystore
uses: timheuer/base64-to-file@v1
with:
fileName: key.jks
encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
- name: Create key.properties
run: |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> android/key.properties
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties
- name: Build Android App Bundle
run: flutter build appbundle --dart-define=IS_PLAYSTORE=true --obfuscate --split-debug-info=/tmp
- name: Build Android APK files
run: flutter build apk --release --split-per-abi --obfuscate --split-debug-info=/tmp
- name: Release to GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/app-*-release.apk,build/app/outputs/bundle/release/app-release.aab"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
allowUpdates: true
build_linux:
needs: build_android
name: Build and release Linux app
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
include:
- label: x86_64
os: ubuntu-latest
- label: aarch64
os: ubuntu-24.04-arm
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install missing packages
run: |
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev desktop-file-utils
# Workaround for building for arm (https://github.com/subosito/flutter-action/issues/345)
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: master
flutter-version: 3.29.0
- name: Flutter version
run: flutter --version
- name: Bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Build for linux
run: flutter build linux --release
- name: Tar linux package
run: |
arch=$(ls build/linux)
tar -C build/linux/$arch/release/bundle -czf converternow-linux-${{ matrix.label }}.tar.gz .
- name: Build appimage
run: |
arch=$(ls build/linux)
wget https://github.com/AppImage/appimagetool/releases/latest/download/appimagetool-${{ matrix.label }}.AppImage
chmod +x appimagetool-${{ matrix.label }}.AppImage
mkdir ConverterNOW.AppDir
cp -r build/linux/$arch/release/bundle/* ConverterNOW.AppDir
cp assets/app_icons/logo.svg ConverterNOW.AppDir
echo -e '#!/bin/sh\ncd "$(dirname "$0")"\nexec ./converternow' > ConverterNOW.AppDir/AppRun
chmod +x ConverterNOW.AppDir/AppRun
cp snap/gui/converternow.desktop ConverterNOW.AppDir
desktop-file-edit --set-icon="logo" --set-key="Exec" --set-value="converternow %u" ConverterNOW.AppDir/converternow.desktop
APPIMAGETOOL_APP_NAME=converternow ./appimagetool-${{ matrix.label }}.AppImage ConverterNOW.AppDir
- name: Release to GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "converternow-linux-${{ matrix.label }}.tar.gz,converternow-${{ matrix.label }}.AppImage"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
allowUpdates: true
build_web:
needs: build_linux
name: Build and release Web app
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Flutter version
run: flutter --version
- name: Bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Build for Web
run: flutter build web --release --wasm
- name: Upload to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CONVERTER_NOW }}'
channelId: live
projectId: converter-now
build_windows:
needs: build_web
name: Build and release Windows app
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Flutter version
run: flutter --version
- name: Bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Build and create the .msix installer
run: dart run msix:create --store
- name: Release to GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "build/windows/x64/runner/Release/converternow-windows.msix"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
allowUpdates: true
build_docker:
needs: build_windows
name: Build and release Docker image
runs-on: ubuntu-latest
timeout-minutes: 10
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true