CI #947
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
name: CI | |
on: | |
push: | |
branches: [master] | |
schedule: | |
- cron: "5 03 * * 1-6" | |
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 ($context.repository_owner + '+github@gmail.com') | |
git config --global user.name $context.repository_owner | |
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 -Name PowerHTML -Force -SkipPublisherCheck | |
Install-Module -Name Wormies-AU-Helpers -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: configure_java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- name: validate java config | |
shell: powershell | |
run: | | |
java --version | |
echo $ENV:JAVA_HOME | |
- 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_TOKEN }} | |
github_user_repo: ${{ github.repository }} | |
gist_id: "8abc37a8c3b020ffdd9704a810331790" | |
gist_id_test: | |
au_test_groups: 1 | |
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 ) | |
{ | |
'\[Chocolatey-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 # Instead of pwsh because au fails on pwsh core. | |
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 |