Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 4284023

Browse files
committed
Update workflows to combine releases
Combine the releases from this repository and the upstream actions/python-versions.
1 parent 8c54e52 commit 4284023

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

.github/workflows/create-pr-to-update-manifest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# It is designed to create a PR with update of versions-manifest.json when a new release is published
33
# The GITHUB_TOKEN secret is used to create versions-manifest.json and publish related PR
44

5-
name: Create Pull Request
5+
name: Create Pull Request (called indirectly)
66
on:
77
workflow_call:
88
inputs:
@@ -26,7 +26,7 @@ jobs:
2626

2727
- name: Create versions-manifest.json
2828
run: |
29-
./helpers/packages-generation/manifest-generator.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" `
29+
./nogil-helpers/manifest-generator.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" `
3030
-GitHubAccessToken "${{ secrets.GITHUB_TOKEN }}" `
3131
-OutputFile "./versions-manifest.json" `
3232
-ConfigurationFile "./config/${{ inputs.tool-name }}-manifest-config.json"

.github/workflows/create-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44

55
jobs:
66
create-pr:
7-
uses: actions/versions-package-tools/.github/workflows/create-pr-to-update-manifest.yml@main
7+
uses: ./.github/workflows/create-pr-to-update-manifest.yml
88
with:
99
tool-name: "python"
1010
secrets: inherit

nogil-helpers/manifest-generator.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ param (
2020
[Parameter(Mandatory)] [string] $ConfigurationFile
2121
)
2222

23-
Import-Module (Join-Path $PSScriptRoot "../github/github-api.psm1")
23+
Import-Module (Join-Path $PSScriptRoot "../helpers/github/github-api.psm1")
2424
Import-Module (Join-Path $PSScriptRoot "manifest-utils.psm1") -Force
2525

2626
$configuration = Read-ConfigurationFile -Filepath $ConfigurationFile
2727

2828
$gitHubApi = Get-GitHubApi -RepositoryFullName $RepositoryFullName -AccessToken $GitHubAccessToken
29-
$releases = $gitHubApi.GetReleases()
30-
$versionIndex = Build-VersionsManifest -Releases $releases -Configuration $configuration
29+
$noGILreleases = $gitHubApi.GetReleases()
30+
31+
$upstreamApi = Get-GitHubApi -RepositoryFullName "actions/python-versions" -AccessToken $GitHubAccessToken
32+
$releases = $upstreamApi.GetReleases()
33+
34+
$versionIndex = Build-VersionsManifest -Releases $releases -NoGILReleases $noGILreleases -Configuration $configuration
3135
$versionIndex | ConvertTo-Json -Depth 5 | Out-File $OutputFile -Encoding UTF8NoBOM -Force

nogil-helpers/manifest-utils.psm1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ function Get-VersionFromRelease {
4646
function Build-VersionsManifest {
4747
param (
4848
[Parameter(Mandatory)][array]$Releases,
49+
[Parameter(Mandatory)][array]$NoGILReleases,
4950
[Parameter(Mandatory)][object]$Configuration
5051
)
5152

5253
$Releases = $Releases | Sort-Object -Property "published_at" -Descending
54+
$NoGILReleases = $NoGILReleases | Sort-Object -Property "published_at" -Descending
5355
$ltsRules = Get-LtsRules -Configuration $Configuration
5456

5557
$versionsHash = @{}
@@ -80,6 +82,42 @@ function Build-VersionsManifest {
8082
$versionsHash.Add($versionKey, $versionHash)
8183
}
8284

85+
$noGILversionsHash = @{}
86+
foreach ($release in $NoGILReleases) {
87+
if (($release.draft -eq $true) -or ($release.prerelease -eq $true)) {
88+
continue
89+
}
90+
91+
[Semver]$version = Get-VersionFromRelease $release
92+
$versionKey = $version.ToString()
93+
94+
if ($noGILversionsHash.ContainsKey($versionKey)) {
95+
continue
96+
}
97+
98+
$ltsStatus = Get-VersionLtsStatus -Version $versionKey -LtsRules $ltsRules
99+
$stable = $version.PreReleaseLabel ? $false : $true
100+
[array]$releaseAssets = $release.assets | Where { $_.Name -ne "hashes.sha256" } | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration }
101+
102+
$versionHash = [PSCustomObject]@{}
103+
$versionHash | Add-Member -Name "version" -Value $versionKey -MemberType NoteProperty
104+
$versionHash | Add-Member -Name "stable" -Value $stable -MemberType NoteProperty
105+
if ($ltsStatus) {
106+
$versionHash | Add-Member -Name "lts" -Value $ltsStatus -MemberType NoteProperty
107+
}
108+
$versionHash | Add-Member -Name "release_url" -Value $release.html_url -MemberType NoteProperty
109+
$versionHash | Add-Member -Name "files" -Value $releaseAssets -MemberType NoteProperty
110+
111+
if ($versionsHash.ContainsKey($versionKey)) {
112+
# filter out filenames already in the versionsHash
113+
$releaseAssets = $releaseAssets | Where-Object { $versionsHash[$versionKey].files.filename -notcontains $_.filename }
114+
$versionsHash[$versionKey].files += $releaseAssets
115+
} else {
116+
$versionsHash.Add($versionKey, $versionHash)
117+
}
118+
$noGILversionsHash.Add($versionKey, $versionHash)
119+
}
120+
83121
# Sort versions by descending
84122
return $versionsHash.Values | Sort-Object -Property @{ Expression = { [Semver]$_.version }; Descending = $true }
85123
}

0 commit comments

Comments
 (0)