Skip to content

Build and Release

Build and Release #28

Workflow file for this run

name: Build and Release
on:
workflow_dispatch:
inputs:
create_release:
description: 'Create a GitHub Release'
required: false
default: false
type: boolean
release_tag:
description: 'Release tag (e.g., v1.0.0)'
required: false
type: string
version:
description: 'Version number (e.g., 1.0.0)'
required: false
default: '1.0.0'
type: string
env:
FLUTTER_VERSION: '3.41.2'
APP_VERSION: ${{ github.event.inputs.version || '1.0.0' }}
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Run tests
run: flutter test
build-web:
name: Build Web
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Build web
run: flutter build web --release
- name: Package web
run: |
cd build/web
zip -r ../SecRandom_lutter_${{ env.APP_VERSION }}_web.zip .
- name: Upload web artifact
uses: actions/upload-artifact@v4
with:
name: web-build
path: build/SecRandom_lutter_${{ env.APP_VERSION }}_web.zip
build-android:
name: Build Android
runs-on: ubuntu-latest
steps:
- name: Checkout code
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:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Decode keystore
run: |
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > android/app/release-keystore.jks
- name: Create key.properties
run: |
cat > android/app/key.properties << EOF
storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}
keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}
storeFile=release-keystore.jks
EOF
- name: Verify keystore file
run: |
echo "Checking keystore file..."
if [ -f "android/app/release-keystore.jks" ]; then
echo "Keystore file exists"
ls -lh android/app/release-keystore.jks
else
echo "ERROR: Keystore file not found!"
exit 1
fi
- name: Verify key.properties
run: |
echo "Checking key.properties file..."
if [ -f "android/app/key.properties" ]; then
echo "key.properties file exists"
cat android/app/key.properties
else
echo "ERROR: key.properties file not found!"
exit 1
fi
- name: Test keystore with keytool
run: |
echo "Testing keystore with keytool..."
keytool -list -v -keystore android/app/release-keystore.jks -storepass "${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" -storetype JKS || exit 1
- name: Build APK
run: flutter build apk --release
- name: Rename APK
run: mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/SecRandom_lutter_${{ env.APP_VERSION }}_android.apk
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: android-apk
path: build/app/outputs/flutter-apk/SecRandom_lutter_${{ env.APP_VERSION }}_android.apk
build-windows:
name: Build Windows
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Enable Windows desktop
run: flutter config --enable-windows-desktop
- name: Build Windows
run: flutter build windows --release
- name: Package Windows
run: |
cd build/windows/x64/runner
Compress-Archive -Path Release/* -DestinationPath SecRandom_lutter_${{ env.APP_VERSION }}_windows.zip
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-build
path: build/windows/x64/runner/SecRandom_lutter_${{ env.APP_VERSION }}_windows.zip
build-linux:
name: Build Linux
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libgtk-3-0 libglib2.0-0
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Enable Linux desktop
run: flutter config --enable-linux-desktop
- name: Build Linux
run: flutter build linux --release
- name: Package Linux
run: |
cd build/linux/x64/release
mkdir -p pkg/DEBIAN
cat > pkg/DEBIAN/control << 'EOF'
Package: secrandom-lutter
Version: ${{ env.APP_VERSION }}
Section: utils
Priority: optional
Architecture: amd64
Maintainer: leafs825
Description: SecRandom Lutter - A Random Roll Call Application
EOF
sed -i 's/^ //' pkg/DEBIAN/control
cp -r bundle/* pkg/
dpkg-deb --build pkg SecRandom_lutter_${{ env.APP_VERSION }}_linux_amd64.deb
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
with:
name: linux-build
path: build/linux/x64/release/SecRandom_lutter_${{ env.APP_VERSION }}_linux_amd64.deb
build-macos:
name: Build macOS
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Enable macOS desktop
run: flutter config --enable-macos-desktop
- name: Build macOS
run: flutter build macos --release
- name: List build output
run: |
echo "Build directory structure:"
find build/macos -name "*.app" -type d
- name: Create DMG
run: |
APP_PATH=$(find build/macos -name "*.app" -type d | head -1)
if [ -z "$APP_PATH" ]; then
echo "Error: No .app found"
exit 1
fi
echo "Creating DMG from: $APP_PATH"
APP_DIR=$(dirname "$APP_PATH")
hdiutil create -volname "SecRandom" -srcfolder "$APP_PATH" -ov -format UDZO "$APP_DIR/SecRandom_lutter_${{ env.APP_VERSION }}_macos.dmg"
- name: Rename app
run: |
APP_PATH=$(find build/macos -name "*.app" -type d | head -1)
APP_DIR=$(dirname "$APP_PATH")
mv "$APP_PATH" "$APP_DIR/SecRandom_lutter_${{ env.APP_VERSION }}_macos.app"
- name: Upload macOS artifact
uses: actions/upload-artifact@v4
with:
name: macos-build
path: |
build/macos/Build/Products/Release/SecRandom_lutter_${{ env.APP_VERSION }}_macos.app
build/macos/Build/Products/Release/SecRandom_lutter_${{ env.APP_VERSION }}_macos.dmg
release:
name: Create Release
needs: [test, build-web, build-android, build-windows, build-linux, build-macos]
runs-on: ubuntu-latest
if: github.event.inputs.create_release == 'true'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Read CHANGELOG
id: changelog
run: |
VERSION="${{ github.event.inputs.version }}"
CHANGELOG_PATH="changelogs/${VERSION}.md"
if [ -f "$CHANGELOG_PATH" ]; then
{
printf 'content<<EOF\n'
cat "$CHANGELOG_PATH"
printf '\nEOF\n'
} >> "$GITHUB_OUTPUT"
else
echo "content=Release version $VERSION" >> "$GITHUB_OUTPUT"
fi
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.release_tag }}
body: ${{ steps.changelog.outputs.content }}
files: |
artifacts/web-build/SecRandom_lutter_*.zip
artifacts/android-apk/SecRandom_lutter_*.apk
artifacts/windows-build/SecRandom_lutter_*.zip
artifacts/linux-build/SecRandom_lutter_*.deb
artifacts/macos-build/SecRandom_lutter_*.dmg
draft: false
prerelease: false
generate_release_notes: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}