ci #2871
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: https://github.com/javydekoning/chocolatey-fanatec-packages/blob/master/.github/workflows/ci.yml | |
name: ci | |
on: | |
workflow_dispatch: | |
push: | |
branches: [dev, ci, main] | |
schedule: | |
- cron: "5 0/8 * * *" | |
jobs: | |
ci: | |
runs-on: windows-latest | |
outputs: | |
remote_ver: ${{ steps.compare.outputs.remote_ver }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: init | |
env: | |
github_context: ${{ toJson(github) }} | |
run: | | |
$context = $ENV:github_context | ConvertFrom-JSON | |
git config --global user.email "[email protected]" | |
git config --global user.name "github-actions[bot]" | |
git config --global core.safecrlf false | |
$info = [PSCustomObject]@{ | |
'Event' = $ENV:GITHUB_EVENT_NAME | |
#THIS DOES NOT WORK WHEN RUNNING ON SCHEDULE | |
'CommitMsg' = (gc $ENV:GITHUB_EVENT_PATH | ConvertFrom-Json).commits.message | |
'Ref' = $ENV:GITHUB_REF | |
'VersionOS' = $PSVersionTable["OS"].toString() | |
'VersionChoco' = choco --version | |
'VersionGit' = (git --version).split(' ')[-1] | |
} | |
$info | fl * | |
# Dumping Context | |
$context | ConvertTo-Json | |
- name: install | |
shell: powershell | |
env: | |
au_version: "master" | |
run: | | |
Install-Module powerhtml -Force -SkipPublisherCheck | |
git clone -q https://github.com/chocolatey-community/chocolatey-au.git $Env:TEMP/au | |
. "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version -verbose | |
- name: build_script | |
shell: powershell # Instead of pwsh because au fails on pwsh core. | |
env: | |
github_context: ${{ toJson(github) }} | |
github_api_key: ${{ secrets.GH_TOKEN }} | |
choco_api_key: ${{ secrets.CHOCO_API_KEY }} | |
github_user_repo: ${{ github.repository }} | |
gist_id: "b4a53804191ce7de9e54d7ac28743ee2" | |
au_test_groups: 1 | |
GH_ACTIONS_BUILD_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
au_push: true | |
run: | | |
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 | |
$context = $ENV:github_context | ConvertFrom-JSON | |
choco apikey --key $ENV:choco_api_key --source https://push.chocolatey.org/ | |
$ErrorActionPreference = 'Continue' | |
if ($context.ref -like '*ci*') { ./test_all.ps1 "random $Env:au_test_groups"; return } | |
if ( $ENV:GITHUB_EVENT_NAME -eq 'push' ) { | |
switch -regex ( (gc $ENV:GITHUB_EVENT_PATH | ConvertFrom-Json).commits.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 | |
if (Test-Path update.ps1 -ea 0) { ./update.ps1 } | |
choco pack; Push-Package; | |
popd | |
} | |
return | |
} | |
} | |
} | |
./update_all.ps1 -ForcedPackages $forced | |
7z a au_temp.zip $Env:TEMP\chocolatey\au\* | |
- name: create artifact | |
shell: pwsh | |
run: | | |
7z a au_temp.zip $Env:TEMP\chocolatey\au\* | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: au_temp | |
path: au_temp.zip |