From 63b434dfab9ecb2e999ea3429a4193368af198d2 Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Mon, 10 Mar 2025 21:33:17 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7Get=20continuous=20improvement=20bu?= =?UTF-8?q?ilds=20working=20separately=20from=20deployment=20Fixes=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/continuous.yml | 19 +++++++ .github/workflows/deploy.yml | 15 ++++++ .github/workflows/dotnetcore.yml | 54 -------------------- .gitignore | 1 + src/PSModuleTemplate/PSModuleTemplate.fsproj | 7 +-- 5 files changed, 39 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/continuous.yml create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/dotnetcore.yml diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml new file mode 100644 index 0000000..ba80b48 --- /dev/null +++ b/.github/workflows/continuous.yml @@ -0,0 +1,19 @@ +name: .NET build and test +on: push +jobs: + continuous-integration: + name: Build and test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + permissions: + contents: read + issues: read + checks: write + pull-requests: write + steps: + - name: .NET CI + uses: brianary/dotnet-ci@v1 + with: + test-target: test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..8961275 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,15 @@ +name: Publish module to PowerShell Gallery +on: + workflow_run: + workflows: [".NET build and test"] + types: [completed] + branches: [main] +jobs: + publish: + name: Publish to PowerShell Gallery + runs-on: windows-latest + steps: + - name: Publish module + uses: brianary/powershell-gallery-publish@v1 + with: + gallery-key: ${{ secrets.gallerykey }} diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml deleted file mode 100644 index 2514250..0000000 --- a/.github/workflows/dotnetcore.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: .NET Core -on: push -jobs: - ci-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - name: Build - run: dotnet build -c Release - - name: Test - run: dotnet publish -t:test - ci-windows: - runs-on: windows-latest - env: - gallerykey: ${{ secrets.gallerykey }} - steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 - - name: Module update check - id: is_module_update_test - shell: pwsh - run: | - Write-Host "::set-output name=is_module_update::$(@(git diff --name-only HEAD~ HEAD -- "$(Resolve-Path .\src\*\*.psd1)").Count -gt 0)" - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - name: Build - run: dotnet build -c Release - - name: Test - run: dotnet publish -t:test - - name: Publish - if: success() && env.gallerykey && steps.is_module_update_test.outputs.is_module_update == 'True' - shell: pwsh - run: | - dotnet publish -c Release - $MSBuildProjectName = [io.path]::GetFileNameWithoutExtension("$(Resolve-Path ./src/*/*.fsproj)") - $env:PSModulePath -split ';' | - ForEach-Object {"$_/$MSBuildProjectName"} | - Where-Object {Test-Path $_ -Type Container} | - Remove-Item -Recurse -Force - Push-Location ./src/*/bin/Release/*/publish - Import-LocalizedData Module -FileName $MSBuildProjectName -BaseDirectory "$PWD" - $Version = $Module.ModuleVersion - $InstallPath = "$env:UserProfile/Documents/PowerShell/Modules/$MSBuildProjectName/$Version" - if(!(Test-Path $InstallPath -Type Container)) {mkdir $InstallPath} - Copy-Item * -Destination $InstallPath - Pop-Location - Publish-Module -Name $MSBuildProjectName -NuGetApiKey $env:gallerykey diff --git a/.gitignore b/.gitignore index d3c4f18..22ee4ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .*/ +!.github/ !.template.config/ bin/ obj/ diff --git a/src/PSModuleTemplate/PSModuleTemplate.fsproj b/src/PSModuleTemplate/PSModuleTemplate.fsproj index 07baa5b..daf5fef 100644 --- a/src/PSModuleTemplate/PSModuleTemplate.fsproj +++ b/src/PSModuleTemplate/PSModuleTemplate.fsproj @@ -4,7 +4,8 @@ netstandard2.0 true true - true + false + false @@ -41,9 +42,9 @@ - -