Browse Source

Switch from AppVeyor to GitHub Actions

Douglas Thrift 2 months ago
parent
commit
33966b5628

+ 0 - 107
.appveyor.yml

@@ -1,107 +0,0 @@
-# AU template: https://github.com/majkinetor/au-packages-template
-
-version: '{build}'
-max_jobs: 1
-image: WMF 5
-# History plugin requires complete log
-#clone_depth: 5
-branches:
-  only:
-  - master
-#build:
-#  verbosity: minimal
-
-environment:
-  # Set au version to use or omit to use the latest. Specify branch name to use development version from Github
-  #au_version:
-  au_push: true
-  # Force test: use 1 to test all, or N to split testing into N groups
-  au_test_groups: 1
-
-  # Github token to commit pushed packages to repository
-  github_user_repo: douglaswth/chocolatey-packages
-  github_api_key:
-    secure: vBQ66VcMD7oL1DZk4lKbBLKH0SLnGdTAg87cHRjCwQ6wENWv0mNln+1J6uN3HdJK
-
-
-  # Mail credentials - for error notifications
-  mail_user:
-    secure: lVYpTAAoZdcEVOzCISGQtpAvwL/ZjlB1NsxUBEQQv9g/Y9OCc5v+nnlbghTYwEgq
-  mail_pass:
-    secure: wLGxZRm3B8BkkKqf+C6WAM/dp7CfGtgaO20Xp2y9Shs=
-  mail_server: smtp.gmail.com
-  mail_port: 587
-  mail_enablessl: true
-
-  # ID of the gist used to save run results - create a gist under the github_user (secret or not) and grab the id - https://gist.github.com/name/id
-  # Optional, leave empty to create anonymous gist
-  gist_id: d98014ed4fcaa5cc65bb902f21ce366a
-
-  # Force test: gist id for test results
-  gist_id_test: b003c5505c6cc5c6a67f8de9e68c183e
-
-  # Chocolatey API key - to push updated packages
-  api_key:
-    secure: oODJ824CND7pSFOUd6ben+k0hRi5bsHPckwiisDA4rHIX4fPI708FnxUosWvy5lc
-
-init:
-- git config --global user.email "chocolatey@realdimensions.net"
-- git config --global user.name "Chocolatey"
-- git config --global core.safecrlf false
-
-install:
-- ps: 'Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version'
-- ps: $PSVersionTable
-- git --version
-- ps: |
-    git clone -q https://github.com/majkinetor/au.git $Env:TEMP/au
-    . "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
-
-- ps: |
-    "Build info"
-    '  {0,-20} {1}' -f 'SCHEDULED BUILD:', ($Env:APPVEYOR_SCHEDULED_BUILD -eq 'true')
-    '  {0,-20} {1}' -f 'FORCED BUILD:'   , ($Env:APPVEYOR_FORCED_BUILD    -eq 'true')
-    '  {0,-20} {1}' -f 'RE BUILD:'       , ($Env:APPVEYOR_RE_BUILD        -eq 'true')
-
-build_script:
-- ps: |
-    $ErrorActionPreference = 'Continue'
-
-    if ($Env:APPVEYOR_PROJECT_NAME  -like '*test*') { ./test_all.ps1 "random $Env:au_test_groups"; return }
-
-    if ( ($Env:APPVEYOR_SCHEDULED_BUILD -ne 'true') -and ($Env:APPVEYOR_FORCED_BUILD -ne 'true') ) {
-        switch -regex ($Env:APPVEYOR_REPO_COMMIT_MESSAGE)
-        {
-            '\[AU (.+?)\]'   { $forced = $Matches[1] }
-
-            '\[PUSH (.+?)\]' {
-                $packages = $Matches[1] -split ' '
-                Write-Host "PUSHING PACKAGES: $packages"
-                foreach ($package in $packages) {
-                    Write-Host ("{0}`n{1}`n" -f ('-'*60), "PACKAGE: $package")
-                    $package_dir = ls -recurse | ? { $_.Name -eq "$package.nuspec"} | select -First 1 | % Directory
-                    if (!$package_dir) { Write-Warning "Can't find package '$package'"; continue }
-                    pushd $package_dir; choco pack; Push-Package; popd
-                }
-                return
-            }
-        }
-    }
-
-    ./update_all.ps1 -ForcedPackages $forced
-    7z a au_temp.zip $Env:TEMP\chocolatey\au\*
-
-artifacts:
-- path: update_info.xml
-- path: Update-AUPackages.md
-- path: au_temp.zip
-
-notifications:
-- provider: Email
-  to: $(mail_user)
-  on_build_success: false
-  on_build_failure: true
-  on_build_status_changed: true
-
-#on_finish:
-#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

+ 76 - 0
.github/workflows/au.yml

@@ -0,0 +1,76 @@
+name: Auto Update
+
+on:
+  workflow_dispatch: # Enable manual trigger
+    inputs:
+      forced_packages:
+        description: The list of packages to forcibly update (like "pkg1:ver1 pkg2")
+        required: false
+  schedule:
+    - cron: 5 */8 * * *
+
+jobs:
+  auto_update:
+    runs-on: windows-latest
+    defaults:
+      run:
+        shell: powershell
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          fetch-depth: 100
+      - name: Check a build environment
+        run: |
+          Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version
+          $PSVersionTable
+          git --version
+          choco --version
+      - name: Initialize Git config
+        run: |
+          git config --global user.email "chocolatey@realdimensions.net"
+          git config --global user.name "Chocolatey"
+          git config --global core.safecrlf false
+      - name: Install AU
+        run: |
+          git clone -q https://github.com/majkinetor/au.git $Env:TEMP/au
+          . "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
+      - name: Check update for packages
+        run: |
+          $ErrorActionPreference = 'Continue'
+          ./update_all.ps1 -ForcedPackages '${{ github.event.inputs.forced_packages }}'
+          7z a au_temp.zip $Env:TEMP\chocolatey\au\*
+        env:
+          # Set au version to use or omit to use the latest. Specify branch name to use development version from Github
+          #au_version:
+          au_push: true
+
+          # Github token to commit pushed packages to repository
+          github_user_repo: ${{ github.repository }}
+          github_api_key: ${{ secrets.GITHUB_TOKEN }}
+
+          # Mail credentials - for error notifications
+          mail_to: ${{ secrets.MAIL_TO }}
+          mail_from: ${{ secrets.MAIL_FROM }}
+          mail_user: ${{ secrets.MAIL_USER }}
+          mail_pass: ${{ secrets.MAIL_PASS }}
+          mail_server: mail.douglasthrift.net
+          mail_port: 587
+          mail_enablessl: true
+
+          # ID of the gist used to save run results - create a gist under the github_user (secret or not) and grab the id - https://gist.github.com/name/id
+          # Optional, leave empty to create anonymous gist
+          gist_id: d98014ed4fcaa5cc65bb902f21ce366a
+
+          # Force test: gist id for test results
+          gist_id_test: b003c5505c6cc5c6a67f8de9e68c183
+
+          # Chocolatey API key - to push updated packages
+          api_key: ${{ secrets.CHOCOLATEY_API_KEY }}
+      - name: Upload update results
+        uses: actions/upload-artifact@v2
+        with:
+          name: update_results
+          path: |
+            update_info.xml
+            Update-AUPackages.md
+            au_temp.zip

+ 19 - 0
.vscode/settings.json

@@ -0,0 +1,19 @@
+{
+    "cSpell.words": [
+        "bluebrick",
+        "choco",
+        "douglasthrift",
+        "douglaswth",
+        "enablessl",
+        "lsau",
+        "operatingsystem",
+        "safecrlf"
+    ],
+    "markdownlint.config": {
+        "no-inline-html": {
+            "allowed_elements": [
+                "br"
+            ]
+        }
+    }
+}

+ 2 - 3
README.md

@@ -1,8 +1,7 @@
 # Chocolatey Packages (Douglas Thrift)
 
-[![](https://img.shields.io/appveyor/ci/douglaswth/chocolatey-packages/master.svg?style=flat-square)](https://ci.appveyor.com/project/douglaswth/chocolatey-packages/branch/master)
-[![](https://img.shields.io/badge/gist-update%20status-blue.svg?style=flat-square)](https://gist.github.com/douglaswth/d98014ed4fcaa5cc65bb902f21ce366a)
-[![](https://img.shields.io/badge/chocolatey-douglaswth-884b2e.svg?style=flat-square)](https://chocolatey.org/profiles/douglaswth)
+[![gist: update status](https://img.shields.io/badge/gist-update%20status-blue.svg?style=flat-square)](https://gist.github.com/douglaswth/d98014ed4fcaa5cc65bb902f21ce366a)
+[![chocolatey: douglaswth](https://img.shields.io/badge/chocolatey-douglaswth-884b2e.svg?style=flat-square)](https://chocolatey.org/profiles/douglaswth)
 
 * [AWS IAM Authenticator for Kubernetes](automatic/aws-iam-authenticator)<br>
   [![Chocolatey](https://img.shields.io/chocolatey/v/aws-iam-authenticator.svg?style=flat-square)](https://chocolatey.org/packages/aws-iam-authenticator)

+ 2 - 3
automatic/README.md

@@ -1,8 +1,8 @@
-## Automatic Folder
+# Automatic Folder
 
 This is where you put your Chocolatey packages that are automatically packaged up by [AU](https://chocolatey.org/packages/au).
 
-### Automatic Updater (AU)
+## Automatic Updater (AU)
 
 AU works with packages without automatic package tokens necessary. So you can treat the packages as normal.
 
@@ -13,4 +13,3 @@ To fully setup all the features ensure you perform the steps in the [setup/READM
 To get the packages that implement AU updater run `Get-AUPackages` or `lsau` in this directory.
 
 **NOTE:** Ensure when you are creating packages for AU, you don't use `--auto` as the packaging files should be normal packages. AU doesn't need the tokens to do replacement.
-

+ 4 - 4
automatic/bluebrick/update.ps1

@@ -4,10 +4,10 @@ $latest_release = 'https://bluebrick.lswproject.com/download.html'
 
 function global:au_GetLatest {
     $download_page = Invoke-WebRequest -Uri $latest_release
-    $regex         = '^.+/BlueBrick(\d+\.\d+\.\d+)\.zip$'
-    $url           = $download_page.Links | ? href -Match $regex | select -First 1 -ExpandProperty href
-    $url           = [System.Uri]::new([System.Uri]$latest_release, $url).AbsoluteUri
-    $version       = $url -replace $regex, '$1'
+    $regex = '^.+/BlueBrick(\d+\.\d+\.\d+)\.zip$'
+    $url = $download_page.Links | Where-Object href -Match $regex | Select-Object -First 1 -ExpandProperty href
+    $url = [System.Uri]::new([System.Uri]$latest_release, $url).AbsoluteUri
+    $version = $url -replace $regex, '$1'
     return @{ Version = $version; URL32 = $url }
 }
 

+ 1 - 1
automatic/fpt/update.ps1

@@ -5,7 +5,7 @@ $latest_release = 'https://github.com/rightscale/policy_sdk/releases'
 function global:au_GetLatest {
   $download_page = Invoke-WebRequest -Uri $latest_release -UseBasicParsing
   $regex = '^.+/v(\d+\.\d+\.\d+)/fpt-windows-amd64\.zip$'
-  $url64 = $download_page.Links | ? href -Match $regex | select -First 1 -ExpandProperty href
+  $url64 = $download_page.Links | Where-Object href -Match $regex | Select-Object -First 1 -ExpandProperty href
   $version = $url64 -replace $regex, '$1'
   return @{ Version = $version; URL64 = $url64 }
 }

+ 3 - 3
automatic/right-st/update.ps1

@@ -4,9 +4,9 @@ $latest_release = 'https://github.com/rightscale/right_st/releases/latest'
 
 function global:au_GetLatest {
   $download_page = Invoke-WebRequest -Uri $latest_release -UseBasicParsing
-  $regex         = '^.+/v(\d+\.\d+\.\d+)/right_st-windows-amd64\.zip$'
-  $url64         = $download_page.Links | ? href -Match $regex | select -First 1 -ExpandProperty href
-  $version       = $url64 -replace $regex, '$1'
+  $regex = '^.+/v(\d+\.\d+\.\d+)/right_st-windows-amd64\.zip$'
+  $url64 = $download_page.Links | Where-Object href -Match $regex | Select-Object -First 1 -ExpandProperty href
+  $version = $url64 -replace $regex, '$1'
   return @{ Version = $version; URL64 = $url64 }
 }
 

+ 5 - 5
automatic/rsc/update.ps1

@@ -4,11 +4,11 @@ $branches = 'https://github.com/rightscale/rsc/branches/all'
 
 function global:au_GetLatest {
   $download_page = Invoke-WebRequest -Uri $branches -UseBasicParsing
-  $regex         = '^/rightscale/rsc/tree/(v\d+\.\d+\.\d+)$'
-  $tree          = $download_page.Links | ? href -Match $regex | select -First 1 -ExpandProperty href
-  $branch        = $tree -replace $regex, '$1'
-  $version       = $branch.Substring(1)
-  $url64         = "https://binaries.rightscale.com/rsbin/rsc/$branch/rsc-windows-amd64.zip"
+  $regex = '^/rightscale/rsc/tree/(v\d+\.\d+\.\d+)$'
+  $tree = $download_page.Links | Where-Object href -Match $regex | Select-Object -First 1 -ExpandProperty href
+  $branch = $tree -replace $regex, '$1'
+  $version = $branch.Substring(1)
+  $url64 = "https://binaries.rightscale.com/rsbin/rsc/$branch/rsc-windows-amd64.zip"
   return @{ Version = $version; URL64 = $url64 }
 }
 

+ 1 - 1
icons/README.md

@@ -1,3 +1,3 @@
-## Icons
+# Icons
 
 Images / Icons go here. This is done so that the image isn't being copied around inside the auto packages

+ 2 - 2
setup/au_setup.ps1

@@ -5,7 +5,7 @@ if ($PSVersionTable.PSVersion -lt $(New-Object System.Version("5.0.0.0"))) {
 }
 
 $refreshenv = Get-Command refreshenv -ea SilentlyContinue
-if ($refreshenv -ne $null -and $refreshenv.CommandType -ne 'Application') {
+if ($null -ne $refreshenv -and $refreshenv.CommandType -ne 'Application') {
   refreshenv # You need the Chocolatey profile installed for this to work properly (Choco v0.9.10.0+).
 } else {
   Write-Warning "We detected that you do not have the Chocolatey PowerShell profile installed, which is necessary for 'refreshenv' to work in PowerShell."
@@ -14,4 +14,4 @@ if ($refreshenv -ne $null -and $refreshenv.CommandType -ne 'Application') {
 Install-PackageProvider -Name NuGet -Force
 Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
 Install-Module au -Scope AllUsers
-Get-Module au -ListAvailable | select Name, Version
+Get-Module au -ListAvailable | Select-Object Name, Version

+ 6 - 3
update_all.ps1

@@ -48,7 +48,8 @@ $Options = [ordered]@{
 
     Mail = if ($Env:mail_user) {
             @{
-                To         = $Env:mail_user
+                To         = $Env:mail_to
+                From       = $Env:mail_from
                 Server     = $Env:mail_server
                 UserName   = $Env:mail_user
                 Password   = $Env:mail_pass
@@ -63,10 +64,12 @@ $Options = [ordered]@{
     ForcedPackages = $ForcedPackages -split ' '
     BeforeEach = {
         param($PackageName, $Options )
-        $p = $Options.ForcedPackages | ? { $_ -match "^${PackageName}(?:\:(.+))*$" }
+        $p = $Options.ForcedPackages | Where-Object { $_ -match "^${PackageName}(?:\:(.+))*$" }
         if (!$p) { return }
 
-        $global:au_Force   = $true
+        [Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseDeclaredVarsMoreThanAssignments', '')]
+        $global:au_Force = $true
+        [Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseDeclaredVarsMoreThanAssignments', '')]
         $global:au_Version = ($p -split ':')[1]
     }
 }