Skip to content

Commit

Permalink
Build translationproject.org versions dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Oct 17, 2024
1 parent 5674865 commit 1764a14
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 17 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ on:
env:
CLDR_VERSION: 45
ICONV_VERSION: 1.17
# The version slug of libiconv; leave empty to use the latest
# See https://translationproject.org/domain/libiconv.html
ICONV_TP_VERSION: ''
GETTEXT_VERSION: 0.22.5a
# The version slug of gettext; leave empty to use the latest
# See https://translationproject.org/domain/gettext-examples.html
# See https://translationproject.org/domain/gettext-runtime.html
# See https://translationproject.org/domain/gettext-tools.html
GETTEXT_TP_VERSION: ''
# To be used for testing: we'll only build iconv
#BUILD_ONLY_ICONV: y

Expand Down Expand Up @@ -248,22 +240,22 @@ jobs:
-
name: Update iconv translations
working-directory: src\libiconv-${{ env.ICONV_VERSION }}
run: ../../build-exe/update-po-files.sh po po/libiconv.pot libiconv '${{ env.ICONV_TP_VERSION }}'
run: ../../build-exe/update-po-files.sh po po/libiconv.pot libiconv '${{ steps.vars.outputs.iconv-tp-version }}'
-
name: Update gettext-examples translations
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}
run: ../../build-exe/update-po-files.sh gettext-tools/examples/po gettext-tools/examples/po/gettext-examples.pot gettext-examples '${{ env.GETTEXT_TP_VERSION }}'
run: ../../build-exe/update-po-files.sh gettext-tools/examples/po gettext-tools/examples/po/gettext-examples.pot gettext-examples '${{ steps.vars.outputs.gettext-tp-version }}'
-
name: Update gettext-runtime translations
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}
run: ../../build-exe/update-po-files.sh gettext-runtime/po gettext-runtime/po/gettext-runtime.pot gettext-runtime '${{ env.GETTEXT_TP_VERSION }}'
run: ../../build-exe/update-po-files.sh gettext-runtime/po gettext-runtime/po/gettext-runtime.pot gettext-runtime '${{ steps.vars.outputs.gettext-tp-version }}'
-
name: Update gettext-tools translations
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}
run: ../../build-exe/update-po-files.sh gettext-tools/po gettext-tools/po/gettext-tools.pot gettext-tools '${{ env.GETTEXT_TP_VERSION }}'
run: ../../build-exe/update-po-files.sh gettext-tools/po gettext-tools/po/gettext-tools.pot gettext-tools '${{ steps.vars.outputs.gettext-tp-version }}'
-
name: Uninstall gettext-develop
run: apt-cyg remove gettext-devel libgomp1
Expand Down
86 changes: 81 additions & 5 deletions build-exe/vars.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,87 @@ function Export-Variable()
"$Name=$Value" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
}

function Build-Version()
{
[OutputType([Version])]
param(
[Parameter(Mandatory = $true)]
[ValidateLength(1, [int]::MaxValue)]
[string] $Version
)
if ($Version -match '^[0-9]+(\.[0-9]+)+') {
return [Version]$matches[0]
}
throw "Invalid Version: '$Version'"
}

function Resolve-TPVersion()
{
[OutputType([string])]
param(
[Parameter(Mandatory = $true)]
[Version] $Version,
[Parameter(Mandatory = $true)]
[string[]] $TPVersions
)
foreach ($tpVersion in $TPVersions) {
$cmp = Build-Version -Version $tpVersion
if ($Version -le $cmp) {
if ($tpVersion -eq $TPVersions[-1]) {
return 'latest'
}
return $tpVersion
}
}
return 'latest'
}

if (-not($env:ICONV_VERSION)) {
throw 'Missing ICONV_VERSION environment variable'
}
$iconvVersion = Build-Version -Version $env:ICONV_VERSION
$iconvTPVersion = Resolve-TPVersion -Version $iconvVersion -TPVersions @(
'1.12',
'1.15-pre1',
'1.17-pre1'
)

if (-not($env:GETTEXT_VERSION)) {
throw 'Missing GETTEXT_VERSION environment variable'
}
$gettextVersionNumeric = $env:GETTEXT_VERSION -replace '[a-z]+$',''
$gettextVersionObject = [Version]$gettextVersionNumeric
$gettextVersion = Build-Version -Version $env:GETTEXT_VERSION
$gettextTPVersion = Resolve-TPVersion -Version $iconvVersion -TPVersions @(
'0.10.35',
'0.10.38',
'0.10.39',
'0.11.2',
'0.11.5',
'0.12-pre1',
'0.12.1',
'0.13-pre1',
'0.13.1',
'0.14',
'0.14.5',
'0.15-pre5',
'0.16',
'0.16.2-pre5',
'0.17',
'0.18',
'0.18.2',
'0.18.3',
'0.19-rc1',
'0.19.3',
'0.19.4-rc1',
'0.19.4.73',
'0.19.6.43',
'0.19.7-rc1',
'0.19.8-rc1',
'0.20-rc1',
'0.20.2',
'0.21',
'0.22',
'0.23-pre1'
)

$absoluteInstalledPath = [System.IO.Path]::Combine($(Get-Location), $InstalledPath)
$match = Select-String -InputObject $absoluteInstalledPath -Pattern '^([A-Za-z]):(\\.*?)\\?$'
Expand Down Expand Up @@ -128,17 +201,18 @@ switch ($Sign) {
$gettextIgnoreTestsC = @()
# see https://lists.gnu.org/archive/html/bug-gnulib/2024-09/msg00137.html
$gettextIgnoreTestsC += 'gettext-tools/gnulib-tests/test-asyncsafe-spin2.c'
if ($gettextVersionObject -le [Version]'0.22.5') {
if ($gettextVersion -le [Version]'0.22.5') {
# see https://lists.gnu.org/archive/html/bug-gnulib/2024-09/msg00137.html
$gettextIgnoreTestsC += 'gettext-tools/gnulib-tests/test-getopt-gnu.c gettext-tools/gnulib-tests/test-getopt-posix.c'
}

$gettextXFailTests = @()
if ($gettextVersionObject -le [Version]'0.22.5') {
if ($gettextVersion -le [Version]'0.22.5') {
# see https://savannah.gnu.org/bugs/?66232
$gettextXFailTests += 'msgexec-1 msgexec-3 msgexec-4 msgexec-5 msgexec-6 msgfilter-6 msgfilter-7 msginit-3'
}


class GnuUrlPrefixer
{
[string[]] $_releaseUrlPrefixes = @(
Expand Down Expand Up @@ -236,7 +310,9 @@ Export-Variable -Name 'gettext-ignore-tests-c' -Value $($gettextIgnoreTestsC -jo
Export-Variable -Name 'gettext-xfail-gettext-tools' -Value $($gettextXFailTests -join ' ')
Export-Variable -Name 'signpath-signing-policy' -Value $signpathSigningPolicy
Export-Variable -Name 'signatures-canbeinvalid' -Value $signaturesCanBeInvalid
Export-Variable -Name 'gettext-peversion-numeric' -Value $gettextVersionNumeric
Export-Variable -Name 'gettext-peversion-numeric' -Value $gettextVersion.ToString()
Export-Variable -Name 'iconv-tp-version' -Value $iconvTPVersion
Export-Variable -Name 'gettext-tp-version' -Value $gettextTPVersion

Write-Output '## Outputs'
Get-Content -LiteralPath $env:GITHUB_OUTPUT

0 comments on commit 1764a14

Please sign in to comment.