Skip to content

Commit

Permalink
Ubuntu only supports maui-android
Browse files Browse the repository at this point in the history
  • Loading branch information
danzuep committed Dec 6, 2023
1 parent 164dc51 commit d01c728
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 130 deletions.
70 changes: 41 additions & 29 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 🚀 Publish Android package
run-name: Publish ${{ inputs.projectName }} Android package
run-name: Publish Android package

on:
workflow_call:
Expand All @@ -25,38 +25,50 @@ on:
default: Release
type: string

env:
DotNetVersion: 8.0.x
DotNetTarget: net8.0

jobs:
deploy:
name: Android
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

steps:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- name: Checkout the source repository from Git
uses: actions/checkout@v4

# https://github.com/actions/setup-dotnet
- name: Get .NET externals
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-quality: 'ga'

- name: Publish Android package
run: |
echo "Project Name: ${{ inputs.projectName }}";
echo "Project File: $projectFile";
echo "Project Version: $buildVersion";
dotnet workload restore;
dotnet publish $projectFile -c $configuration -f $targetFramework /p:Version=$buildVersion /p:AndroidPackageFormats=$androidPackageFormats -o $publishOutputFolder --nologo;
env:
projectFile: '${{ inputs.projectFile }}'
buildVersion: '${{ inputs.version }}'
configuration: ${{ inputs.configuration }}
targetFramework: "net8.0-android"
androidPackageFormats: "apk" # "aab;apk"
publishOutputFolder: "publish"

- name: Markdown workflow job summary
run: echo "### ${{ inputs.projectName }} ${{ inputs.version }} apk published" >> $GITHUB_STEP_SUMMARY
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- name: Checkout the source repository from Git
uses: actions/checkout@v4

# https://github.com/actions/setup-dotnet
- name: Get .NET externals
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DotNetVersion }}
dotnet-quality: 'ga'

- name: Install .NET MAUI
shell: pwsh
run: |
echo ".NET Version: ${{ env.DotNetVersion }}";
dotnet --version;
echo "Project Name: ${{ inputs.projectName }}";
dotnet workload install maui-android;
dotnet workload list;
- name: Publish Android package
run: |
echo "Project File: $projectFile";
echo "Project Version: $buildVersion";
echo "Target Framework: $targetFramework";
dotnet publish $projectFile -c $configuration -f $targetFramework /p:Version=$buildVersion /p:AndroidPackageFormats=$androidPackageFormats -o $publishOutputFolder --nologo;
env:
projectFile: '${{ inputs.projectFile }}'
buildVersion: '${{ inputs.version }}'
configuration: ${{ inputs.configuration }}
targetFramework: "${{ env.DotNetTarget }}-android"
androidPackageFormats: "apk" # "aab;apk"
publishOutputFolder: "publish"

- name: Markdown workflow job summary
run: echo "### ${{ inputs.projectName }} ${{ inputs.version }} apk published" >> $GITHUB_STEP_SUMMARY
131 changes: 59 additions & 72 deletions .github/workflows/_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,82 +30,69 @@ jobs:
projectFile: ${{ steps.metadata.outputs.projectFile }}

steps:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- name: Fetch all tags and branches for GitVersion
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
- name: Fetch all tags and branches for GitVersion
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Git repository project name and list all project files in the directory
id: metadata
shell: bash
run: |
repositoryName=$(basename '${{ github.repository }}')
echo "Project name: $repositoryName"
shopt -s globstar
for project in ./**/*.csproj; do
echo "Project file: $project"
projectFile=${project}
done
echo "projectName=${repositoryName}" >> $GITHUB_ENV
echo "projectName=${repositoryName}" >> $GITHUB_OUTPUT
echo "projectFile=${projectFile}" >> $GITHUB_ENV
echo "projectFile=${projectFile}" >> $GITHUB_OUTPUT
- name: Get Git repository project name and list all project files in the directory
id: metadata
shell: bash
run: |
repositoryName=$(basename '${{ github.repository }}')
echo "Project name: $repositoryName"
shopt -s globstar
for project in ./**/*.csproj; do
echo "Project file: $project"
projectFile=${project}
done
echo "projectName=${repositoryName}" >> $GITHUB_ENV
echo "projectName=${repositoryName}" >> $GITHUB_OUTPUT
echo "projectFile=${projectFile}" >> $GITHUB_ENV
echo "projectFile=${projectFile}" >> $GITHUB_OUTPUT
- run: |
echo "Generate release notes from the Git commit log."
echo "## $projectName" > release-notes.txt
git log --pretty=format:"- %s" >> release-notes.txt
- run: |
echo "Generate release notes from the Git commit log."
echo "## $projectName" > release-notes.txt
git log --pretty=format:"- %s" >> release-notes.txt
# # TODO: fix this
# - run: |
# echo "Generate release notes from the Git commit log."
# last_tag=$(git describe --abbrev=0 --tags 2>/dev/null)
# if [[ -z "$last_tag" ]]; then
# echo "## $projectName" > release-notes.txt
# git log --pretty=format:"- %s" >> release-notes.txt
# else
# echo "## $projectName changes since $last_tag" > release-notes.txt
# git log --pretty=format:"- %s" --since="$last_tag" >> release-notes.txt
# fi
# https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/setup/usage-examples.md#example-1
- name: Set up GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'

# https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/setup/usage-examples.md#example-1
- name: Set up GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
# https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/execute/usage-examples.md#example-5
# For a list of all GitVersion Version Variables, see https://gitversion.net/docs/reference/variables
- name: Use GitVersion to determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0

# https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/execute/usage-examples.md#example-5
# For a list of all GitVersion Version Variables, see https://gitversion.net/docs/reference/variables
# pwsh> dotnet-gitversion | ConvertFrom-Json
- name: Use GitVersion to determine version
id: gitversion # e.g. steps.gitversion.outputs.<outputName>
uses: gittools/actions/gitversion/execute@v0
- run: |
echo 'Save the GitVersion environment variables to a file.'
echo "projectName=${projectName}" > version.txt
echo "projectFile=${projectFile}" >> version.txt
for var in $(env | grep '^GitVersion_' | cut -d= -f1); do
echo "$var=${!var}" >> version.txt
done
- run: |
echo 'Save the GitVersion environment variables to a file.'
echo "projectName=${projectName}" > version.txt
echo "projectFile=${projectFile}" >> version.txt
for var in $(env | grep '^GitVersion_' | cut -d= -f1); do
echo "$var=${!var}" >> version.txt
done
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
- name: Markdown workflow job summary
run: |
echo '### ${{ env.workflowVersion }} build summary' >> $GITHUB_STEP_SUMMARY
echo "Repository: ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
echo "Branch: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
echo 'Commit Date: ${{ steps.gitversion.outputs.commitDate }}' >> $GITHUB_STEP_SUMMARY
echo 'Full Semantic Version: ${{ steps.gitversion.outputs.fullSemVer }}' >> $GITHUB_STEP_SUMMARY
echo 'Pre-release Label: ${{ steps.gitversion.outputs.preReleaseLabel }}' >> $GITHUB_STEP_SUMMARY
env:
workflowVersion: '${{ steps.metadata.outputs.projectName }} version ${{ steps.gitversion.outputs.semVer }}'

# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
- name: Markdown workflow job summary
run: |
echo '### ${{ env.workflowVersion }} build summary' >> $GITHUB_STEP_SUMMARY
echo "Repository: ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
echo "Branch: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
echo 'Commit Date: ${{ steps.gitversion.outputs.commitDate }}' >> $GITHUB_STEP_SUMMARY
echo 'Full Semantic Version: ${{ steps.gitversion.outputs.fullSemVer }}' >> $GITHUB_STEP_SUMMARY
echo 'Pre-release Label: ${{ steps.gitversion.outputs.preReleaseLabel }}' >> $GITHUB_STEP_SUMMARY
env:
workflowVersion: '${{ steps.metadata.outputs.projectName }} version ${{ steps.gitversion.outputs.semVer }}'

# https://github.com/actions/upload-artifact
- name: Upload version artifacts
uses: actions/upload-artifact@v3
with:
path: |
version.txt
release-notes.txt
# https://github.com/actions/upload-artifact
- name: Upload version artifacts
uses: actions/upload-artifact@v3
with:
path: |
version.txt
release-notes.txt
3 changes: 0 additions & 3 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ run-name: Get version and build release notes

on:
workflow_dispatch:
push:
branches:
- main

# Cancel any other running workflows with the same ID
concurrency:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- 'v[0-9]+.[0-9]+.*'
branches:
- release/**
- devops

# Cancel any other running workflows with the same ID
concurrency:
Expand Down
58 changes: 34 additions & 24 deletions LocalGuideAI/LocalGuideAI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('macOS'))">$(TargetFrameworks);net8.0-ios;net8.0-macios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
Expand All @@ -21,7 +22,7 @@
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>LocalGuideAI</ApplicationTitle>
<ApplicationTitle>AI Local Guide</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.danzuep.localguideai</ApplicationId>
Expand All @@ -30,6 +31,9 @@
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<!-- C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
Expand All @@ -39,6 +43,25 @@
<UserSecretsId>LocalGuideAI-69b33f45-de4c-4083-9a70-939952647ea2</UserSecretsId>
</PropertyGroup>

<!-- https://learn.microsoft.com/en-us/dotnet/maui/android/deployment/publish-cli?view=net-maui-8.0#define-build-properties-in-your-project-file -->
<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
<OutputType>WinExe</OutputType>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>

<!--<PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidPackageFormats>apk</AndroidPackageFormats>
<AndroidSigningKeyStore>../release/android.keystore</AndroidSigningKeyStore>
<AndroidSigningKeyAlias>android-key</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>env:AndroidSigningPassword</AndroidSigningKeyPass>
<AndroidSigningStorePass>env:AndroidSigningPassword</AndroidSigningStorePass>
</PropertyGroup>-->

<!--<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
</PropertyGroup>-->

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
Expand All @@ -58,40 +81,27 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="1.0.0-beta.9" />
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Azure.AI.OpenAI" Version="1.0.0-beta.9" />
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Tests</_Parameter1>
</AssemblyAttribute>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="../*" LinkBase="Solution Items" />
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Fonts\MaterialIcons-Regular.ttf" />
<None Remove="Resources\Fonts\MaterialIconsOutlined-Regular.otf" />
<None Include="../*" LinkBase="Solution Items" />
</ItemGroup>

<ItemGroup>
<Compile Update="Views\SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties XamarinHotReloadDebuggerTimeoutExceptionLocalGuideAIHideInfoBar="True" /></VisualStudio></ProjectExtensions>

</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LocalGuideAI

A local guide in the form of an app that uses ChatGPT AI. A project for Microsoft Hack Together: The Great .NET 8 Hack.
A local guide in the form of a C# .NET MAUI app that uses ChatGPT AI. A project for Microsoft Hack Together: The Great .NET 8 Hack.

![PC](https://raw.githubusercontent.com/danzuep/LocalGuideAI/main/Assets/Animations/PC.gif)

Expand Down
6 changes: 5 additions & 1 deletion Scripts/publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $androidPackageFormats="apk"; # "aab;apk"
$targetFramework="${dotnetTarget}-android";
$publishOutputFolder="publish";
$publishPath = [IO.Path]::Combine($projectFolder, $publishOutputFolder);
$kestoreFolder = [IO.Path]::Combine($Env:LOCALAPPDATA, "Android");
$kestoreFolder = [IO.Path]::Combine($Env:LOCALAPPDATA, "Android"); # %LocalAppData%
if (-Not (Test-Path -Path "${kestoreFolder}" -PathType Container))
{
New-Item -ItemType Directory -Path "${kestoreFolder}";
Expand All @@ -40,6 +40,10 @@ if (-Not (Test-Path -Path "${kestorePath}" -PathType Leaf))
keytool -list -keystore "${kestorePath}";
}

Write-Host "Local .NET Version: "; dotnet --version;
Write-Host "Target Framework: ${targetFramework}";
Write-Host "Project File: ${projectFile} (version ${buildVersion})";

dotnet publish "${projectFile}" -c $configuration --framework $targetFramework /p:Version=$buildVersion /p:AndroidPackageFormats=$androidPackageFormats /p:AndroidKeyStore=true /p:AndroidSigningKeyStore="${kestorePath}" /p:AndroidSigningKeyAlias="${androidSigningAlias}" /p:AndroidSigningKeyPass="${Env:AndroidSigningPassword}" /p:AndroidSigningStorePass="${Env:AndroidSigningPassword}" -o "${publishOutputFolder}" --no-restore --nologo;
if (-not $?) {
Write-Host "Project failed to publish.";
Expand Down

0 comments on commit d01c728

Please sign in to comment.