Skip to content

Commit

Permalink
Nightly packages (#6)
Browse files Browse the repository at this point in the history
* Added workflow for packages

* Update packages 2023-03-20

* Update pkgs 2023-03-20

* Update pkgs 2023-03-21
  • Loading branch information
bostrot authored Mar 21, 2023
1 parent b2f3421 commit f9f4759
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Workflow that runs every day at 00:00 and checks for new packages
name: Packages

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- nightly-packages

jobs:
check:
runs-on: windows-latest
steps:
# Checkout branch nightly-packages
- name: Checkout branch nightly-packages
uses: actions/checkout@v3
with:
ref: nightly-packages
# Checkout winget-pkgs
- name: Checkout winget-pkgs
uses: actions/checkout@v3
with:
repository: microsoft/winget-pkgs
path: ./winget-pkgs
# Run the script
- name: Run the script
run: |
./updater.ps1
# Commit the changes
- name: Commit the changes
run: |
git config --local user.email "eric@bostrot.com"
git config --local user.name "Eric"
git add pkgs.json
git commit -m "Update pkgs $((Get-Date).ToString(`"yyyy-MM-dd`"))"
git push
1 change: 1 addition & 0 deletions pkgs.json

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions updater.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Updates winget packages repository

# Checkout repo https://github.com/microsoft/winget-pkgs/tree/master/manifests
# git clone https://github.com/microsoft/winget-pkgs.git
cd ./winget-pkgs/manifests

# Create pkgs.json file with [ as first character
"[" | Out-File -NoNewline -FilePath "../../pkgs.json" -Encoding UTF8

# For every folder (a-z)
foreach ($folder in (Get-ChildItem -Path . -Directory)) {
# For every company in the folder
foreach ($company in (Get-ChildItem -Path $folder.FullName -Directory)) {
# For every package in the company
foreach ($package in (Get-ChildItem -Path $company.FullName -Directory)) {
# For every version in the package
$latestVersion = 0
foreach ($version in (Get-ChildItem -Path $package.FullName -Directory)) {
# Check if version is greater than latest version with format 1.0.0.0
if ($version.Name -gt $latestVersion) {
$latestVersion = $version.Name
}
}
$packageName = $package.Name
$companyName = $company.Name
$versionName = $latestVersion

# Append to pkgs.json without new line
$packageString = "{`"name`":`"$packageName`",`"company`":`"$companyName`",`"version`":`"$versionName`"},"

$packageString | Out-File -NoNewline -FilePath "../../pkgs.json" -Encoding UTF8 -Append

# Write-Host "Added $packageName from $companyName with version $versionName"
}
}
}

# Write packages to file in json format
"]" | Out-File -NoNewline -FilePath "../../pkgs.json" -Encoding UTF8 -Append

cd ../../
41 changes: 41 additions & 0 deletions updater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# # Updates winget packages repository

# # Checkout repo https://github.com/microsoft/winget-pkgs/tree/master/manifests
# # git clone https://github.com/microsoft/winget-pkgs.git

#!/bin/bash
cd ./winget-pkgs

# Create pkgs.json file with [ as first character
echo "[" > ./pkgs.json

# For every folder (a-z)
for folder in */; do
# For every company in the folder
for company in $folder*/; do
# For every package in the company
for package in $company*/; do
# For every version in the package
latestVersion=0
for version in $package*/; do
# Check if version is greater than latest version with format
if [[ $version > $latestVersion ]]; then
latestVersion=$version
fi
done
packageName=${package::-1}
companyName=${company::-1}
versionName=${latestVersion::-1}

# Append to pkgs.json without new line
packageString="{\"name\":\"$packageName\",\"company\":\"$companyName\",\"version\":\"$versionName\"},"

echo $packageString >> ./pkgs.json
done
done
done

# Write packages to file in json format
echo "]" >> ./pkgs.json

cd ../

0 comments on commit f9f4759

Please sign in to comment.