diff --git a/.github/.powershell-psscriptanalyzer.psd1 b/.github/.powershell-psscriptanalyzer.psd1 deleted file mode 100644 index a961da3a..00000000 --- a/.github/.powershell-psscriptanalyzer.psd1 +++ /dev/null @@ -1,20 +0,0 @@ -#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/markdown/Invoke-ScriptAnalyzer.md#-settings -@{ - ExcludeRules = @( - 'PSMissingModuleManifestField', - 'PSUseLiteralInitializerForHashtable', - 'MissingPropertyName' - 'PSAvoidGlobalVars', - 'PSAvoidUsingPositionalParameters', - 'PSAvoidUsingWriteHost', - 'PSAvoidUsingEmptyCatchBlock', - 'PSPossibleIncorrectComparisonWithNull', - 'PSAvoidTrailingWhitespace', - 'PSUseApprovedVerbs', - 'PSAvoidUsingWMICmdlet', - 'PSReviewUnusedParameter', - 'PSUseDeclaredVarsMoreThanAssignment', - 'PSUseShouldProcessForStateChangingFunctions', - 'PSUseDeclaredVarsMoreThanAssignments' - ) -} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 458b6889..f763d8d9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,4 @@ updates: schedule: interval: weekly time: "06:00" + target-branch: "develop" diff --git a/.github/workflows/Check-pull-request-source-branch.yml b/.github/workflows/Check-pull-request-source-branch.yml new file mode 100644 index 00000000..1d6bc9a1 --- /dev/null +++ b/.github/workflows/Check-pull-request-source-branch.yml @@ -0,0 +1,20 @@ +name: Check pull request source branch + +on: + pull_request_target: + types: + - opened + - reopened + - synchronize + - edited + +jobs: + check-branches: + runs-on: ubuntu-latest + steps: + - name: Check branches + run: | + if [ "${{ github.head_ref }}" != "develop" ] && [ "${{ github.base_ref }}" == "main" ]; then + echo "Error: Pull requests to the main branch are only allowed from the develop branch. Please submit your pull request to the develop branch." + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/WAU-ReleaseBuilder.yml b/.github/workflows/WAU-ReleaseBuilder.yml index d8b9f9eb..09a37b1c 100644 --- a/.github/workflows/WAU-ReleaseBuilder.yml +++ b/.github/workflows/WAU-ReleaseBuilder.yml @@ -144,7 +144,7 @@ jobs: wget https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v1.21.13/WAU.zip -UseBasicParsing -OutFile .\WAU.zip - name: Create release - uses: ncipollo/release-action@cdcc88a9acf3ca41c16c37bb7d21b9ad48560d87 # v1.15.0 + uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0 if: env.ReleaseType != 'No' with: tag: v${{ env.NextSemVer }} diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index feb06380..91a5aa75 100644 --- a/.github/workflows/mega-linter.yml +++ b/.github/workflows/mega-linter.yml @@ -7,6 +7,8 @@ on: # Trigger mega-linter at every push. Action will also be visible from Pull Requests to main #push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions) pull_request: + branches-ignore: + - main permissions: contents: write diff --git a/.github/workflows/powershell-tests.yaml b/.github/workflows/powershell-tests.yaml deleted file mode 100644 index f5b89de7..00000000 --- a/.github/workflows/powershell-tests.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -name: Powershell Test Runs - -# yamllint disable-line rule:truthy -on: - pull_request: - branches: [master, main] - workflow_dispatch: - -permissions: - contents: read - pull-requests: read - -jobs: - powershell-tests: - name: Pester test and PSScriptAnalyzer - runs-on: windows-latest - steps: - - name: Check out repository code - uses: actions/checkout@v4 - - name: Perform a Pester test for the WAU installation - shell: powershell - run: | - $command = New-PesterContainer -Path Sources/Winget-AutoUpdate-Install.ps1 -Data @{ Silent = $true } - Invoke-Pester -PassThru -Container $command -ErrorAction Continue - - name: Perform a Pester test for WAU run - shell: powershell - run: | - $command = New-PesterContainer -Path "C:\Program Files\Winget-AutoUpdate\user-run.ps1" - Invoke-Pester -PassThru -Container $command -ErrorAction Continue - #- name: Read WAU Log - # id: package - # uses: juliangruber/read-file-action@v1 - # with: - # path: 'C:\ProgramData\Winget-AutoUpdate\Logs\updates.log' - #- name: Display WAU Log - # run: type "${{ steps.package.outputs.content }}" - - name: Install PSScriptAnalyzer module from PSGallery - shell: powershell - run: | - Set-PSRepository PSGallery -InstallationPolicy Trusted - Install-Module PSScriptAnalyzer -ErrorAction Stop - - name: Lint with PSScriptAnalyzer - shell: powershell - run: | - Invoke-ScriptAnalyzer -Path *.ps1 -Recurse -Outvariable issues - $errors = $issues.Where({$_.Severity -eq 'Error'}) - $warnings = $issues.Where({$_.Severity -eq 'Warning'}) - if ($($errors.Count) -gt 0) { - $ErrorAction = "Stop" - } else { - $ErrorAction = "Continue" - } - if ($errors) { - Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction $ErrorAction - } else { - Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total." - } diff --git a/Sources/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 b/Sources/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 index 9566a1b2..2f4d41a1 100644 --- a/Sources/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Get-WingetCmd.ps1 @@ -12,14 +12,12 @@ Function Get-WingetCmd #default winget path (in user context) [string]$pu = "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe"; - try - { - #Get Admin Context Winget Location - $WingetInfo = (Get-Item -Path $ps -ErrorAction Stop).VersionInfo | Sort-Object -Property FileVersionRaw -Descending | Select-Object -First 1; - #If multiple versions, pick most recent one - $WingetCmd = $WingetInfo.FileName; - } - catch + #Get Admin Context Winget Location + $WingetInfo = (Get-Item -Path $ps -ErrorAction Stop).VersionInfo | Sort-Object -Property FileVersionRaw -Descending | Select-Object -First 1; + #If multiple versions, pick most recent one + $WingetCmd = $WingetInfo.FileName; + + if ([String]::IsNullOrEmpty($WingetCmd)) { #Get User context Winget Location if (Test-Path -Path $pu -PathType Leaf) @@ -27,5 +25,6 @@ Function Get-WingetCmd $WingetCmd = $pu; } } + return $WingetCmd; -} +} \ No newline at end of file