Skip to content

Commit

Permalink
Merge pull request #60 from md-owes/develop
Browse files Browse the repository at this point in the history
added mac build and github cache along with separate workflow for release
  • Loading branch information
md-owes authored Jul 27, 2023
2 parents ad8823e + 4197a31 commit 059a00e
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 52 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/mac-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: MacBuild

on:
push:
branches: [develop]
pull_request:
branches: [main]

workflow_dispatch:

permissions:
contents: read
env:
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry

jobs:
calculate-version:
name: Calculate Version
runs-on: ubuntu-latest
outputs:
semVer: ${{ steps.gitversion.outputs.semVer }}
steps:
- name: Checkout
uses: actions/checkout@v3.5.3
with:
fetch-depth: 0

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: "5.x"
preferLatestVersion: true

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0

buildmacCatalyst:
runs-on: macos-latest
name: Mac Build
needs: calculate-version
env:
SEMVER: ${{ needs.calculate-version.outputs.semVer }}

steps:
- uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
7.0.x
- name: List installed .NET info
shell: pwsh
run: dotnet --info

# - name: Restore nuget packages
# run: |
# cd 6.0/Apps/WeatherTwentyOne/src/
# dotnet restore WeatherTwentyOne.sln

- name: Install .NET MAUI
shell: bash
run: |
dotnet workload install maui
- name: Create MAUI version
uses: managedcode/MAUIAppVersion@v1
with:
csproj: "directory-deleter/directory-deleter.csproj"
version: "0"
displayVersion: ${{env.SEMVER}}
printFile: true

- name: Restore Dependencies
run: dotnet restore directory-deleter/directory-deleter.csproj

# https://docs.microsoft.com/en-us/dotnet/maui/macos/deployment/overview
- name: Build MacCatalyst App
shell: bash
run: |
dotnet build -f net7.0-maccatalyst -c Release -o ./bin/publish/artifacts
dotnet publish -f net7.0-maccatalyst -c Release -p:CreatePackage=true -o ./bin/publish/artifacts
- name: Display publish path
shell: bash
run: |
cd ./bin/publish/artifacts
ls
# - name: Build and Run UnitTests
# shell: bash
# run: |
# dotnet build <path to unit test csproj>
# dotnet test <path to unit test csproj> --no-build --verbosity normal

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: artifacts-mac
path: |
./bin/publish/artifacts/**/*.pkg
- name: Upload cache
uses: actions/cache@v3
with:
path: |
./bin/publish/artifacts/**/*.pkg
key: directory-deleter-${{runner.os}}-v${{env.SEMVER}}
enableCrossOsArchive: true
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release App
on:
workflow_run:
workflows: ["WindowsBuid,MacBuild"]
branches: [main]
types: [completed]
permissions:
contents: read
env:
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry

jobs:
release-artifacts:
name: Release Artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ahmadnassri/action-workflow-run-wait@v1

- name: Install GitReleaseManager
uses: gittools/actions/gitreleasemanager/setup@v0
with:
versionSpec: "0.10.x"
preferLatestVersion: true

- uses: actions/cache/restore@v3
id: mac-cache
with:
path: "**/*.pkg"
key: directory-deleter-macos-v${{env.SEMVER}}

- uses: actions/cache/restore@v3
id: winexe-cache
with:
path: "**/*.exe.zip"
key: directory-deleter-macos-v${{env.SEMVER}}

- uses: actions/cache/restore@v3
id: winmsi-cache
with:
path: "**/*.msi.zip"
key: directory-deleter-macos-v${{env.SEMVER}}

- name: Create git tag
run: |
git remote remove origin
git remote add origin https://${{ secrets.GITRELEASEMANAGERALLACCESS }}@github.com/md-owes/directory-deleter
git tag ${{secrets.SEMVER}}
git push origin ${{secrets.SEMVER}}
- name: Create release with GitReleaseManager
uses: gittools/actions/gitreleasemanager/create@v0.10.2
with:
token: ${{ secrets.GITRELEASEMANAGERALLACCESS }}
owner: "md-owes"
repository: "directory-deleter"
milestone: ${{secrets.SEMVER}}
name: "${{secrets.SEMVER}}"
assets: |
directory-deleter-v${{secrets.SEMVER}}.msix.zip
directory-deleter-v${{secrets.SEMVER}}.exe.zip
directory-deleter-v${{secrets.SEMVER}}.pkg.zip
90 changes: 38 additions & 52 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: Windows build
on:
name: WindowsBuild
on:
push:
branches: [ main ]
branches: [develop]
paths-ignore:
- '**/*.md'
- '**/*.gitignore'
- '**/*.gitattributes'
# pull_request:
# branches: [ main ]
- "**/*.md"
- "**/*.gitignore"
- "**/*.gitattributes"
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
env:
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry

jobs:
calculate-version:
name: Calculate Version
runs-on: windows-latest
runs-on: ubuntu-latest
outputs:
semVer: ${{ steps.gitversion.outputs.semVer }}
steps:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
versionSpec: "5.x"
preferLatestVersion: true

- name: Determine Version
Expand All @@ -52,10 +52,17 @@ jobs:
fetch-depth: 0
token: ${{ secrets.GITRELEASEMANAGERALLACCESS }}

- uses: hmanzur/actions-set-secret@v2.0.0
with:
name: 'SEMVER'
value: '${{env.SEMVER}}'
repository: md-owes/directory-deleter
token: ${{ secrets.GITRELEASEMANAGERALLACCESS }}

- name: Setup .NET
uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
dotnet-version: |
7.0.x
3.1.x
Expand All @@ -73,24 +80,21 @@ jobs:
uses: managedcode/MAUIAppVersion@v1
with:
csproj: 'directory-deleter\directory-deleter.csproj'
version: '0'
version: "0"
displayVersion: ${{env.SEMVER}}
printFile: true

- name: Restore Dependencies
run: dotnet restore directory-deleter\directory-deleter.csproj

- name: Publish MAUI MSIX
run: dotnet publish -p:Configuration=Release -p:RestorePackages=false -p:TargetFramework=net7.0-windows10.0.22621.0 -p:GenerateAppxPackageOnBuild=true -p:AppxPackageDir=${{github.workspace}}\${{env.PUBLISH_DIR}}\msix\

- name: Publish MAUI EXE
run: dotnet publish -p:TargetFramework=net7.0-windows10.0.22621.0 -p:RuntimeIdentifier=win10-x64 -p:SelfContained=true -p:Configuration=Release -p:RestorePackages=false -p:WindowsPackageType=None -o ${{github.workspace}}\${{env.PUBLISH_DIR}}\exe

- name: Publish MAUI PKG
run: dotnet publish -p:TargetFramework=net7.0-maccatalyst -p:Configuration=Release -p:RestorePackages=false -p:CreatePackage=true -o ${{github.workspace}}\${{env.PUBLISH_DIR}}\pkg

- name: Display path information
run: |
run: |
echo "Workspace is ${{github.workspace}} and publish path of msix is ${{github.workspace}}\${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.msix.zip"
echo "Sha to commit ${{github.sha}}"
Expand All @@ -100,42 +104,24 @@ jobs:
- name: Compress EXE
run: Compress-Archive -Path "${{github.workspace}}\${{env.PUBLISH_DIR}}\exe\*" -Destination "${{github.workspace}}\${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.exe.zip"

- name: Compress PKG
run: Compress-Archive -Path "${{github.workspace}}\${{env.PUBLISH_DIR}}\pkg\*" -Destination "${{github.workspace}}\${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.pkg.zip"

- name: Publish path listing
run: |
run: |
cd "${{github.workspace}}\${{env.PUBLISH_DIR}}"
ls
- name: Publish pkg directory content
run: |
cd "${{github.workspace}}\${{env.PUBLISH_DIR}}\pkg"
ls
- name: Install GitReleaseManager
uses: gittools/actions/gitreleasemanager/setup@v0
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
versionSpec: '0.10.x'
preferLatestVersion: true

- name: Create git tag
run: |
git remote remove origin
git remote add origin https://${{ secrets.GITRELEASEMANAGERALLACCESS }}@github.com/md-owes/directory-deleter
git tag ${{env.SEMVER}}
git push origin ${{env.SEMVER}}
name: artifacts-windows
path: |
${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.exe.zip
${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.msix.zip
- name: Create release with GitReleaseManager
uses: gittools/actions/gitreleasemanager/create@v0.10.2
- name: Upload cache
uses: actions/cache/save@v3
with:
token: ${{ secrets.GITRELEASEMANAGERALLACCESS }}
owner: 'md-owes'
repository: 'directory-deleter'
milestone: ${{env.SEMVER}}
name: '${{env.SEMVER}}'
assets: |
${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.msix.zip
path: |
${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.exe.zip
${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.pkg.zip
${{env.PUBLISH_DIR}}\directory-deleter-v${{env.SEMVER}}.msix.zip
key: directory-deleter-${{runner.os}}-v${{env.SEMVER}}
enableCrossOsArchive: true

0 comments on commit 059a00e

Please sign in to comment.