Skip to content

Commit b63b057

Browse files
committed
CI: Publish a GitHub Action to generate a remote repository
1 parent a6d31fd commit b63b057

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Build Pog remote repository'
2+
description: 'Use a local package repository to generate a remote Pog package repository.'
3+
4+
inputs:
5+
source:
6+
description: 'Path to the source local repository.'
7+
required: true
8+
9+
output:
10+
description: 'Output path where the generated remote repository files are placed.'
11+
required: true
12+
13+
validate:
14+
description: "Whether to validate the local repository before processing it."
15+
required: false
16+
default: true
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- shell: pwsh
22+
run: |
23+
$Validate = $env:VALIDATE -eq "true"
24+
& $env:GITHUB_ACTION_PATH\build-remote-repo.ps1 $env:OUTPUT $env:SOURCE -Validate:$Validate
25+
env:
26+
OUTPUT: ${{ inputs.output }}
27+
SOURCE: ${{ inputs.source }}
28+
VALIDATE: ${{ inputs.validate }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
param(
2+
[Parameter(Mandatory)]
3+
[string]
4+
$RemoteRepoDir,
5+
[Parameter(Mandatory)]
6+
[string]
7+
$SourceRepoDir,
8+
[switch]
9+
$Validate
10+
)
11+
12+
Set-StrictMode -Version 3
13+
$ErrorActionPreference = "Stop"
14+
$PSNativeCommandUseErrorActionPreference = $true
15+
16+
Import-Module Pog
17+
# use the local repository, instead of the default remote repo
18+
Set-PogRepository $SourceRepoDir
19+
20+
if ($Validate) {
21+
# validate the input repository before building, allow missing hashes
22+
if (-not (Confirm-PogRepository -IgnoreMissingHash)) {
23+
throw "Input repository validation failed (see warnings above)."
24+
}
25+
}
26+
27+
28+
$null = mkdir -Force $RemoteRepoDir
29+
cd $RemoteRepoDir
30+
31+
rm -Recurse *
32+
33+
$Packages = [array][Pog.InternalState]::Repository.Enumerate()
34+
35+
$VersionMap = [ordered]@{}
36+
$Packages | % {
37+
$VersionMap[$_.PackageName] = @($_.EnumerateVersions() | % ToString)
38+
}
39+
# not really html, but whatever
40+
$VersionMap | ConvertTo-Json -Depth 100 -Compress > index.html
41+
42+
# TODO: build in parallel
43+
$TmpPackage = New-PogPackage _zip_export
44+
try {
45+
$Packages | % {
46+
$null = mkdir $_.PackageName
47+
$VersionCounter = 0
48+
$_.Enumerate() | % {
49+
$_.ImportTo($TmpPackage)
50+
Compress-Archive "$($TmpPackage.Path)\*" ".\$($_.PackageName)\$($_.Version).zip"
51+
$VersionCounter++
52+
}
53+
54+
[pscustomobject]@{
55+
PackageName = $_.PackageName
56+
VersionCount = $VersionCounter
57+
}
58+
}
59+
} finally {
60+
rm -Force -Recurse $TmpPackage.Path
61+
}

0 commit comments

Comments
 (0)