Skip to content

Commit

Permalink
Refactor workflow files for Android, Linux, and Windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay7178 committed Aug 22, 2024
1 parent deb2dd8 commit eec3b0d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 73 deletions.
65 changes: 33 additions & 32 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
49 changes: 24 additions & 25 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
25 changes: 9 additions & 16 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build-windows:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -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
Expand All @@ -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

0 comments on commit eec3b0d

Please sign in to comment.