Skip to content

Commit

Permalink
GitVersion, Android
Browse files Browse the repository at this point in the history
  • Loading branch information
danzuep committed Dec 5, 2023
1 parent 46e4d87 commit 795277b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 🚀 Deploy to NuGet
run-name: Deploy ${{ inputs.projectName }} NuGet package
name: 🚀 Publish Android package
run-name: Publish ${{ inputs.projectName }} Android package

on:
workflow_call:
Expand All @@ -24,17 +24,11 @@ on:
description: 'The publish configuration'
default: Release
type: string
secrets:
envPAT:
required: true

jobs:
deploy:
name: 🚀 ${{ inputs.projectName }}
name: Android
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
environment: ${{ inputs.environment }}

steps:
Expand All @@ -44,10 +38,7 @@ jobs:

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

# https://github.com/actions/cache/blob/main/examples.md#c---nuget
- name: Get any cached NuGet packages from the last run
Expand All @@ -58,7 +49,12 @@ jobs:
restore-keys: nugetpackages-${{ runner.os }}

- name: Publish Android package
run: dotnet publish $projectFile -c $configuration -f $targetFramework /p:Version=$buildVersion /p:AndroidPackageFormats=$androidPackageFormats -o $publishOutputFolder --nologo;
run: |
echo "Project Name: $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 }}'
Expand Down
53 changes: 27 additions & 26 deletions .github/workflows/_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

jobs:
version:
name: Version
name: GitVersion
runs-on: 'ubuntu-latest'

outputs: # alternative usage: $GitVersion_<outputName>
Expand All @@ -26,8 +26,8 @@ jobs:
majorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}
preReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}
commitDate: ${{ steps.gitversion.outputs.commitDate }}
projectName: $projectName
projectFile: $projectFile
projectName: ${{ steps.metadata.outputs.projectName }}
projectFile: ${{ steps.metadata.outputs.projectFile }}

steps:
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
Expand All @@ -37,15 +37,20 @@ jobs:
fetch-depth: 0

- name: Get Git repository project name and list all project files in the directory
id: metadata
shell: bash
run: |
echo "projectName=$(basename '${{ github.repository }}')" >> $GITHUB_ENV
echo "Project name: $projectName"
repositoryName=$(basename '${{ github.repository }}')
echo "Project name: $repositoryName"
shopt -s globstar
for project in ./**/*.csproj; do
echo "Project file: $project"
echo "projectFile=$project" >> $GITHUB_ENV
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."
Expand Down Expand Up @@ -78,33 +83,29 @@ jobs:
uses: gittools/actions/gitversion/execute@v0

- run: |
echo 'Save the GitVersion outputs to a file.'
echo "Major: ${{ steps.gitversion.outputs.major }}" > version.txt
echo "Minor: ${{ steps.gitversion.outputs.minor }}" >> version.txt
echo "Patch: ${{ steps.gitversion.outputs.patch }}" >> version.txt
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}" >> version.txt
echo 'Semantic Version: ${{ steps.gitversion.outputs.semVer }}' >> version.txt
echo 'Full Semantic Version: ${{ steps.gitversion.outputs.fullSemVer }}' >> version.txt
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}" >> version.txt
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}" >> version.txt
echo 'CommitDate: ${{ steps.gitversion.outputs.commitDate }}' >> version.txt
# https://github.com/actions/upload-artifact
- name: Upload version artifacts
uses: actions/upload-artifact@v3
with:
path: |
version.txt
release-notes.txt
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.workflowName }} build summary' >> $GITHUB_STEP_SUMMARY
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:
workflowName: '$projectName version ${{ steps.gitversion.outputs.semVer }}'
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
uses: ./.github/workflows/_publish.yml
with:
projectName: ${{ needs.version.outputs.projectName }}
projectFile: ${{ needs.version.outputs.projectFiles }}
projectFile: ${{ needs.version.outputs.projectFile }}
version: ${{ needs.version.outputs.semVer }}
secrets: inherit
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LocalGuideAI

Local Guide app using ChatGPT AI, a project for Microsoft Hack Together: The Great .NET 8 Hack.
A local guide in the form of an 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

0 comments on commit 795277b

Please sign in to comment.