diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 1cbb00b..63e16cd 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -10,7 +10,7 @@ env: JAVA_VERSION: "17" ANDROID_SDK_ROOT: "${{ github.workspace }}/android-sdk" FLUTTER_VERSION: "3.38.5" - BUILD_WINDOWS: "false" # set to "true" when you actually want Windows builds + BUILD_WINDOWS: "true" GITEA_BASE_URL: https://git.tgj.services jobs: @@ -238,6 +238,58 @@ jobs: name: linux-bundle path: app-linux-x64.tar.gz + windows-build: + runs-on: + - mileograph + needs: meta + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Flutter SDK (Windows) + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + $flutterHome = "$env:USERPROFILE\flutter" + if (-Not (Test-Path "$flutterHome\bin\flutter.bat")) { + if (Test-Path $flutterHome) { Remove-Item -Recurse -Force $flutterHome } + $flutterZip = "$env:TEMP\flutter_windows_${env:FLUTTER_VERSION}-stable.zip" + Invoke-WebRequest -Uri "https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_${env:FLUTTER_VERSION}-stable.zip" -OutFile $flutterZip + Expand-Archive -Path $flutterZip -DestinationPath $env:USERPROFILE -Force + } + "$flutterHome\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + & "$flutterHome\bin\flutter.bat" --version + + - name: Allow all git directories (CI) + run: git config --global --add safe.directory '*' + + - name: Set pub cache path + shell: pwsh + run: | + "PUB_CACHE=$env:GITHUB_WORKSPACE\.pub-cache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Enable Windows desktop + run: flutter config --enable-windows-desktop + + - name: Flutter dependencies + run: flutter pub get + + - name: Build Windows binary (release) + env: + BASE_VERSION: ${{ needs.meta.outputs.base_version }} + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + flutter build windows --release + $zipName = "mileograph-windows-$env:BASE_VERSION.zip" + Compress-Archive -Path "build/windows/x64/runner/Release/*" -DestinationPath $zipName -Force + + - name: Upload Windows artifact + uses: actions/upload-artifact@v3 + with: + name: windows-bundle + path: mileograph-windows-${{ needs.meta.outputs.base_version }}.zip + release-dev: runs-on: - mileograph @@ -245,6 +297,7 @@ jobs: - meta - android-build - linux-build + - windows-build steps: - name: Install jq run: | @@ -262,6 +315,13 @@ jobs: name: android-apk path: artifacts + - name: Download Windows bundle + if: ${{ github.ref == 'refs/heads/dev' }} + uses: actions/download-artifact@v3 + with: + name: windows-bundle + path: artifacts + - name: Prepare APK and tag if: ${{ github.ref == 'refs/heads/dev' }} id: bundle @@ -270,9 +330,11 @@ jobs: TAG="${{ needs.meta.outputs.release_tag }}" mv "artifacts/mileograph-${BASE}.apk" "artifacts/mileograph-${BASE}-dev.apk" + mv "artifacts/mileograph-windows-${BASE}.zip" "artifacts/mileograph-windows-${BASE}-dev.zip" echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "apk=artifacts/mileograph-${BASE}-dev.apk" >> "$GITHUB_OUTPUT" + echo "windows_zip=artifacts/mileograph-windows-${BASE}-dev.zip" >> "$GITHUB_OUTPUT" - name: Create prerelease on Gitea if: ${{ github.ref == 'refs/heads/dev' }} @@ -313,6 +375,32 @@ jobs: "${GITEA_BASE_URL}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \ >/dev/null + - name: Attach Windows bundle to Gitea release + if: ${{ github.ref == 'refs/heads/dev' }} + run: | + set -euo pipefail + + TAG="${{ steps.bundle.outputs.tag }}" + ZIP="${{ steps.bundle.outputs.windows_zip }}" + + RELEASE_JSON=$(curl -sS \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + "${GITEA_BASE_URL}/api/v1/repos/${{ github.repository }}/releases/tags/${TAG}") + + RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id') + + echo "Release ID: $RELEASE_ID" + + NAME=$(basename "$ZIP") + echo "Uploading $NAME" + + curl -sS -X POST \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -F "attachment=@${ZIP}" \ + -F "name=${NAME}" \ + "${GITEA_BASE_URL}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \ + >/dev/null + release-master: runs-on: - mileograph @@ -320,6 +408,7 @@ jobs: - meta - android-build - linux-build + - windows-build steps: - name: Install jq run: | @@ -337,6 +426,13 @@ jobs: name: android-apk path: artifacts + - name: Download Windows bundle + if: ${{ github.ref == 'refs/heads/master' }} + uses: actions/download-artifact@v3 + with: + name: windows-bundle + path: artifacts + - name: Prepare APK and tag if: ${{ github.ref == 'refs/heads/master' }} id: bundle @@ -346,6 +442,7 @@ jobs: echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "apk=artifacts/mileograph-${BASE}.apk" >> "$GITHUB_OUTPUT" + echo "windows_zip=artifacts/mileograph-windows-${BASE}.zip" >> "$GITHUB_OUTPUT" - name: Create release on Gitea if: ${{ github.ref == 'refs/heads/master' }} @@ -384,3 +481,29 @@ jobs: -F "name=${NAME}" \ "${GITEA_BASE_URL}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \ >/dev/null + + - name: Attach Windows bundle to Gitea release + if: ${{ github.ref == 'refs/heads/master' }} + run: | + set -euo pipefail + + TAG="${{ steps.bundle.outputs.tag }}" + ZIP="${{ steps.bundle.outputs.windows_zip }}" + + RELEASE_JSON=$(curl -sS \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + "${GITEA_BASE_URL}/api/v1/repos/${{ github.repository }}/releases/tags/${TAG}") + + RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id') + + echo "Release ID: $RELEASE_ID" + + NAME=$(basename "$ZIP") + echo "Uploading $NAME" + + curl -sS -X POST \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -F "attachment=@${ZIP}" \ + -F "name=${NAME}" \ + "${GITEA_BASE_URL}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \ + >/dev/null diff --git a/pubspec.yaml b/pubspec.yaml index ae41d9b..f1be19a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.4.4+1 +version: 0.4.5+1 environment: sdk: ^3.8.1