From eec3b0d9614ff4ff78965ff1c8c1a1b67c9b3af1 Mon Sep 17 00:00:00 2001 From: sanjay7178 Date: Thu, 22 Aug 2024 19:13:08 +0530 Subject: [PATCH] Refactor workflow files for Android, Linux, and Windows builds --- .github/workflows/android.yml | 65 ++++++++++++++++++----------------- .github/workflows/linux.yml | 49 +++++++++++++------------- .github/workflows/windows.yml | 25 +++++--------- 3 files changed, 66 insertions(+), 73 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index bfe2c3a..426bc7f 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,12 +1,14 @@ -name: Android Build and Release +name: Android Build and release on: release: types: [created] jobs: - build-android: + build: + name: Build runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v2 @@ -16,55 +18,54 @@ jobs: with: go-version: '1.22' - - name: Set up Java - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - - name: Set up Android SDK - uses: android-actions/setup-android@v2 - - - name: Set up Fyne - run: | - go install fyne.io/fyne/v2/cmd/fyne@latest + - name: Set up Fyne Cross + run: go install github.com/fyne-io/fyne-cross@latest - - name: Build for Android + - name: Build for Android run: | - fyne package -os android -appID com.sanjay7178.openfortiap -icon Icon.png + fyne-cross android - name: Read TOML and set env vars run: | - APP_NAME=$(awk -F '=' '/Name/ {gsub(/"/, "", $2); print $2}' FyneApp.toml | xargs) + APP_NAME=$(awk -F '=' '/Name/ {gsub(/"/, "", $2); print $2}' fyne-cross.toml | xargs) echo "APP_NAME=$APP_NAME" >> $GITHUB_ENV - - name: Upload Android Artifact + + - name: Upload Android APKs uses: actions/upload-artifact@v2 with: name: android - path: ${{ env.APP_NAME }}.apk + path: | + fyne-cross/dist/android/ + fyne-cross/dist/android-386/ + fyne-cross/dist/android-amd64/ + fyne-cross/dist/android-arm/ + fyne-cross/dist/android-arm64/ - create-android-release: - needs: build-android + create-release: + needs: build runs-on: ubuntu-latest steps: - - name: Download Android artifact + - name: Download all artifacts uses: actions/download-artifact@v2 - with: - name: android - - name: Get release - id: get_release - uses: bruceadams/get-release@v1.2.3 + - name: Create Release + id: create_release + uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false - - name: Upload Android Release Asset + - name: Upload Android Release Assets uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./${{ env.APP_NAME }}.apk - asset_name: ${{ env.APP_NAME }}-android.apk - asset_content_type: application/vnd.android.package-archive + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./android/android/${{ env.APP_NAME }}.apk + asset_name: ${{ env.APP_NAME }}-android-all.apk + asset_content_type: application/vnd.android.package-archive \ No newline at end of file diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4338cf8..b3fe95b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -5,8 +5,10 @@ on: types: [created] jobs: - build-linux: + build: + name: Build runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v2 @@ -16,47 +18,44 @@ jobs: with: go-version: '1.22' - - name: Set up Fyne - run: | - sudo apt-get update - sudo apt-get install -y gcc libgl1-mesa-dev xorg-dev - go install fyne.io/fyne/v2/cmd/fyne@latest - - - name: Build for Linux - run: fyne package -os linux -icon Icon.png + - name: Set up Fyne Cross + run: go install github.com/fyne-io/fyne-cross@latest - - name: Read TOML and set env vars + - name: Build for linux run: | - APP_NAME=$(awk -F '=' '/Name/ {gsub(/"/, "", $2); print $2}' FyneApp.toml | xargs) - echo "APP_NAME=$APP_NAME" >> $GITHUB_ENV + fyne-cross linux - name: Upload Linux Artifact uses: actions/upload-artifact@v2 with: name: linux - path: ${{ env.APP_NAME }} + path: fyne-cross/dist/linux-amd64/ + - create-linux-release: - needs: build-linux + create-release: + needs: build runs-on: ubuntu-latest steps: - - name: Download Linux artifact + - name: Download all artifacts uses: actions/download-artifact@v2 - with: - name: linux - - name: Get release - id: get_release - uses: bruceadams/get-release@v1.2.3 + - name: Create Release + id: create_release + uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false - name: Upload Linux Release Asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./${{ env.APP_NAME }} - asset_name: ${{ env.APP_NAME }}-linux-amd64 - asset_content_type: application/octet-stream + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./linux/tmp.tar.xz + asset_name: linux-amd64.tar.xz + asset_content_type: application/x-xz diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e627a52..02a08c7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -6,7 +6,7 @@ on: jobs: build-windows: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 @@ -16,33 +16,26 @@ jobs: with: go-version: '1.22' - - name: Set up Fyne and dependencies - run: | - go install fyne.io/fyne/v2/cmd/fyne@latest - choco install mingw - choco install msys2 - go install github.com/fyne-io/fyne-cross@latest + - name: Set up Fyne Cross + run: go install github.com/fyne-io/fyne-cross@latest - name: Build for Windows - run: | - $env:PATH += ";C:\tools\mingw64\bin" - # fyne package -os windows -icon Icon.png - fyne-cross windows -arch=amd64 + run: fyne-cross windows - name: Read TOML and set env vars run: | - $appName = (Get-Content FyneApp.toml | Select-String 'Name =').ToString().Split('=')[1].Trim().Trim('"') - echo "APP_NAME=$appName" >> $env:GITHUB_ENV + APP_NAME=$(awk -F '=' '/Name/ {gsub(/"/, "", $2); print $2}' FyneApp.toml | xargs) + echo "APP_NAME=$APP_NAME" >> $GITHUB_ENV - name: Upload Windows Artifact uses: actions/upload-artifact@v2 with: name: windows - path: ${{ env.APP_NAME }}.exe + path: fyne-cross/dist/windows-amd64/ create-windows-release: needs: build-windows - runs-on: windows-latest + runs-on: ubuntu-latest steps: - name: Download Windows artifact uses: actions/download-artifact@v2 @@ -63,4 +56,4 @@ jobs: upload_url: ${{ steps.get_release.outputs.upload_url }} asset_path: ./${{ env.APP_NAME }}.exe asset_name: ${{ env.APP_NAME }}-windows-amd64.exe - asset_content_type: application/vnd.microsoft.portable-executable + asset_content_type: application/vnd.microsoft.portable-executable \ No newline at end of file