From d01c728b29315b68c8c7071237a07e37b0b91ae1 Mon Sep 17 00:00:00 2001 From: Daniel Collingwood <82693586+danzuep@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:10:27 +0800 Subject: [PATCH] Ubuntu only supports maui-android --- .github/workflows/_publish.yml | 70 +++++++++------- .github/workflows/_version.yml | 131 ++++++++++++++---------------- .github/workflows/development.yml | 3 - .github/workflows/release.yml | 1 + LocalGuideAI/LocalGuideAI.csproj | 58 +++++++------ README.md | 2 +- Scripts/publish.ps1 | 6 +- 7 files changed, 141 insertions(+), 130 deletions(-) diff --git a/.github/workflows/_publish.yml b/.github/workflows/_publish.yml index be77e9c..6ae87b4 100644 --- a/.github/workflows/_publish.yml +++ b/.github/workflows/_publish.yml @@ -1,5 +1,5 @@ name: 🚀 Publish Android package -run-name: Publish ${{ inputs.projectName }} Android package +run-name: Publish Android package on: workflow_call: @@ -25,6 +25,10 @@ on: default: Release type: string +env: + DotNetVersion: 8.0.x + DotNetTarget: net8.0 + jobs: deploy: name: Android @@ -32,31 +36,39 @@ jobs: 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 diff --git a/.github/workflows/_version.yml b/.github/workflows/_version.yml index bf5b735..cf72dbe 100644 --- a/.github/workflows/_version.yml +++ b/.github/workflows/_version.yml @@ -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. - 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 diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 7756cf6..67337a4 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -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: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48b1030..fb71560 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ on: - 'v[0-9]+.[0-9]+.*' branches: - release/** + - devops # Cancel any other running workflows with the same ID concurrency: diff --git a/LocalGuideAI/LocalGuideAI.csproj b/LocalGuideAI/LocalGuideAI.csproj index 13e7b86..6b120a6 100644 --- a/LocalGuideAI/LocalGuideAI.csproj +++ b/LocalGuideAI/LocalGuideAI.csproj @@ -1,7 +1,8 @@  - net8.0-android;net8.0-ios;net8.0-maccatalyst + net8.0-android + $(TargetFrameworks);net8.0-ios;net8.0-macios $(TargetFrameworks);net8.0-windows10.0.19041.0 @@ -21,7 +22,7 @@ enable - LocalGuideAI + AI Local Guide com.danzuep.localguideai @@ -30,6 +31,9 @@ 1.0 1 + + True + 11.0 13.1 21.0 @@ -39,6 +43,25 @@ LocalGuideAI-69b33f45-de4c-4083-9a70-939952647ea2 + + + WinExe + win10-x64 + + + + + + @@ -58,40 +81,27 @@ - - - + + + - - - - - - - <_Parameter1>$(MSBuildProjectName).Tests - + + - + + <_Parameter1>$(MSBuildProjectName).Tests + - - + - - - SettingsPage.xaml - - - - - diff --git a/README.md b/README.md index a66dd31..23a0e57 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/Scripts/publish.ps1 b/Scripts/publish.ps1 index 17a15c1..162ce56 100644 --- a/Scripts/publish.ps1 +++ b/Scripts/publish.ps1 @@ -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}"; @@ -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.";