add pipeline
This commit is contained in:
232
.gitea/workflows/release.yml
Normal file
232
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- dev
|
||||||
|
|
||||||
|
env:
|
||||||
|
JAVA_VERSION: "17"
|
||||||
|
ANDROID_SDK_ROOT: "${{ github.workspace }}/android-sdk"
|
||||||
|
FLUTTER_CHANNEL: "stable"
|
||||||
|
BUILD_WINDOWS: "false" # set to "true" when you have a Windows runner available
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
base_version: ${{ steps.meta.outputs.base }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install OS deps (Android + Linux desktop)
|
||||||
|
run: |
|
||||||
|
if command -v sudo >/dev/null 2>&1; then
|
||||||
|
SUDO="sudo"
|
||||||
|
else
|
||||||
|
SUDO=""
|
||||||
|
fi
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y unzip xz-utils zip libstdc++6 libglu1-mesa clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev curl
|
||||||
|
|
||||||
|
- name: Install Android SDK
|
||||||
|
run: |
|
||||||
|
mkdir -p "$ANDROID_SDK_ROOT"/cmdline-tools
|
||||||
|
curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o /tmp/cli-tools.zip
|
||||||
|
unzip -q /tmp/cli-tools.zip -d "$ANDROID_SDK_ROOT"/cmdline-tools
|
||||||
|
mv "$ANDROID_SDK_ROOT"/cmdline-tools/cmdline-tools "$ANDROID_SDK_ROOT"/cmdline-tools/latest
|
||||||
|
yes | "$ANDROID_SDK_ROOT"/cmdline-tools/latest/bin/sdkmanager --licenses
|
||||||
|
yes | "$ANDROID_SDK_ROOT"/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.2"
|
||||||
|
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> "$GITHUB_ENV"
|
||||||
|
echo "$ANDROID_SDK_ROOT/platform-tools" >> "$GITHUB_PATH"
|
||||||
|
echo "$ANDROID_SDK_ROOT/build-tools/33.0.2" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: ${{ env.JAVA_VERSION }}
|
||||||
|
|
||||||
|
- name: Setup Flutter
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: ${{ env.FLUTTER_CHANNEL }}
|
||||||
|
|
||||||
|
- name: Flutter dependencies
|
||||||
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Enable Linux desktop
|
||||||
|
run: flutter config --enable-linux-desktop
|
||||||
|
|
||||||
|
- name: Determine version
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
RAW_VERSION=$(awk '/^version:/{print $2}' pubspec.yaml)
|
||||||
|
BASE_VERSION=${RAW_VERSION%%+*}
|
||||||
|
echo "base=${BASE_VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build APK (release)
|
||||||
|
run: |
|
||||||
|
flutter build apk --release
|
||||||
|
cp build/app/outputs/flutter-apk/app-release.apk app-release.apk
|
||||||
|
|
||||||
|
- name: Build Linux binary (release)
|
||||||
|
run: |
|
||||||
|
flutter build linux --release
|
||||||
|
tar -C build/linux/x64/release/bundle -czf app-linux-x64.tar.gz .
|
||||||
|
|
||||||
|
- name: Upload APK artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: apk
|
||||||
|
path: app-release.apk
|
||||||
|
|
||||||
|
- name: Upload Linux artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux
|
||||||
|
path: app-linux-x64.tar.gz
|
||||||
|
|
||||||
|
windows-build:
|
||||||
|
if: env.BUILD_WINDOWS == 'true'
|
||||||
|
runs-on: windows-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Flutter
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: ${{ env.FLUTTER_CHANNEL }}
|
||||||
|
|
||||||
|
- name: Flutter dependencies
|
||||||
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Enable Windows desktop
|
||||||
|
run: flutter config --enable-windows-desktop
|
||||||
|
|
||||||
|
- name: Build Windows binary (release)
|
||||||
|
run: |
|
||||||
|
flutter build windows --release
|
||||||
|
powershell -Command "Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath app-windows-x64.zip"
|
||||||
|
|
||||||
|
- name: Upload Windows artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows
|
||||||
|
path: app-windows-x64.zip
|
||||||
|
|
||||||
|
release-dev:
|
||||||
|
if: github.ref_name == 'dev'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build]
|
||||||
|
steps:
|
||||||
|
- name: Download APK
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: apk
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Download Linux bundle
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Download Windows bundle (optional)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows
|
||||||
|
path: artifacts
|
||||||
|
if-no-files-found: ignore
|
||||||
|
|
||||||
|
- name: Prepare artifacts and tag
|
||||||
|
id: bundle
|
||||||
|
run: |
|
||||||
|
BASE="${{ needs.build.outputs.base_version }}"
|
||||||
|
TAG="v${BASE}-dev"
|
||||||
|
mv artifacts/app-release.apk "artifacts/app-${BASE}-dev.apk"
|
||||||
|
mv artifacts/app-linux-x64.tar.gz "artifacts/app-linux-x64-${BASE}-dev.tar.gz"
|
||||||
|
if [ -f artifacts/app-windows-x64.zip ]; then
|
||||||
|
mv artifacts/app-windows-x64.zip "artifacts/app-windows-x64-${BASE}-dev.zip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILES="artifacts/app-${BASE}-dev.apk
|
||||||
|
artifacts/app-linux-x64-${BASE}-dev.tar.gz"
|
||||||
|
if [ -f artifacts/app-windows-x64-${BASE}-dev.zip ]; then
|
||||||
|
FILES="$FILES
|
||||||
|
artifacts/app-windows-x64-${BASE}-dev.zip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "files<<EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "$FILES" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create prerelease on Gitea
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
tag: ${{ steps.bundle.outputs.tag }}
|
||||||
|
name: ${{ steps.bundle.outputs.tag }}
|
||||||
|
prerelease: true
|
||||||
|
token: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
artifacts: ${{ steps.bundle.outputs.files }}
|
||||||
|
|
||||||
|
release-master:
|
||||||
|
if: github.ref_name == 'master'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build]
|
||||||
|
steps:
|
||||||
|
- name: Download APK
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: apk
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Download Linux bundle
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Download Windows bundle (optional)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows
|
||||||
|
path: artifacts
|
||||||
|
if-no-files-found: ignore
|
||||||
|
|
||||||
|
- name: Prepare artifacts and tag
|
||||||
|
id: bundle
|
||||||
|
run: |
|
||||||
|
BASE="${{ needs.build.outputs.base_version }}"
|
||||||
|
TAG="v${BASE}"
|
||||||
|
mv artifacts/app-release.apk "artifacts/app-${BASE}.apk"
|
||||||
|
mv artifacts/app-linux-x64.tar.gz "artifacts/app-linux-x64-${BASE}.tar.gz"
|
||||||
|
if [ -f artifacts/app-windows-x64.zip ]; then
|
||||||
|
mv artifacts/app-windows-x64.zip "artifacts/app-windows-x64-${BASE}.zip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILES="artifacts/app-${BASE}.apk
|
||||||
|
artifacts/app-linux-x64-${BASE}.tar.gz"
|
||||||
|
if [ -f artifacts/app-windows-x64-${BASE}.zip ]; then
|
||||||
|
FILES="$FILES
|
||||||
|
artifacts/app-windows-x64-${BASE}.zip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "files<<EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "$FILES" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create release on Gitea
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
tag: ${{ steps.bundle.outputs.tag }}
|
||||||
|
name: ${{ steps.bundle.outputs.tag }}
|
||||||
|
prerelease: false
|
||||||
|
token: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
artifacts: ${{ steps.bundle.outputs.files }}
|
||||||
@@ -99,13 +99,13 @@ class Loco {
|
|||||||
|
|
||||||
factory Loco.fromJson(Map<String, dynamic> json) => Loco(
|
factory Loco.fromJson(Map<String, dynamic> json) => Loco(
|
||||||
id: json['loco_id'],
|
id: json['loco_id'],
|
||||||
type: json['loco_type'],
|
type: json['type'],
|
||||||
number: json['loco_number'],
|
number: json['number'],
|
||||||
name: json['loco_name'] ?? "",
|
name: json['name'] ?? "",
|
||||||
locoClass: json['loco_class'],
|
locoClass: json['class'],
|
||||||
operator: json['loco_operator'],
|
operator: json['operator'],
|
||||||
notes: json['loco_notes'],
|
notes: json['notes'],
|
||||||
evn: json['loco_evn'],
|
evn: json['evn'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,13 +137,13 @@ class LocoSummary extends Loco {
|
|||||||
|
|
||||||
factory LocoSummary.fromJson(Map<String, dynamic> json) => LocoSummary(
|
factory LocoSummary.fromJson(Map<String, dynamic> json) => LocoSummary(
|
||||||
locoId: json['loco_id'],
|
locoId: json['loco_id'],
|
||||||
locoType: json['loco_type'],
|
locoType: json['type'],
|
||||||
locoNumber: json['loco_number'],
|
locoNumber: json['number'],
|
||||||
locoName: json['loco_name'] ?? "",
|
locoName: json['name'] ?? "",
|
||||||
locoClass: json['loco_class'],
|
locoClass: json['class'],
|
||||||
locoOperator: json['loco_operator'],
|
locoOperator: json['operator'],
|
||||||
locoNotes: json['loco_notes'],
|
locoNotes: json['notes'],
|
||||||
locoEvn: json['loco_evn'],
|
locoEvn: json['evn'],
|
||||||
mileage: (json['loco_mileage'] as num?)?.toDouble() ?? 0,
|
mileage: (json['loco_mileage'] as num?)?.toDouble() ?? 0,
|
||||||
journeys: json['loco_journeys'] ?? 0,
|
journeys: json['loco_journeys'] ?? 0,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user