Merge pull request #19 from mlocati/pwsh-named-params #38
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: Build | |
on: | |
pull_request: | |
paths: | |
- .github/workflows/build.yml | |
- build-exe/** | |
push: | |
branches: | |
- main | |
tags-ignore: | |
- "**" | |
paths: | |
- .github/workflows/build.yml | |
- build-exe/** | |
workflow_dispatch: | |
jobs: | |
exe: | |
name: Build executables ${{ matrix.link }} ${{ matrix.bits}} bits | |
runs-on: windows-2022 | |
strategy: | |
matrix: | |
bits: | |
- 32 | |
- 64 | |
link: | |
- shared | |
- static | |
env: | |
CLDR_VERSION: 45 | |
ICONV_VERSION: 1.17 | |
GETTEXT_VERSION: 0.22.5a | |
CYGWIN_NOWINPATH: 1 | |
CHERE_INVOKING: 1 | |
defaults: | |
run: | |
shell: C:\cygwin\bin\bash.exe --login -o igncr -o errexit -o pipefail {0} | |
steps: | |
- | |
name: Configure git | |
shell: cmd | |
run: git config --global core.autocrlf input | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Restore cache | |
id: restore-cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ matrix.link }}-${{ matrix.bits }} | |
path: | | |
C:\cygwin-packages | |
C:\cygwin\src\downloads | |
- | |
name: Set variables | |
id: vars | |
shell: pwsh | |
run: ./build-exe/vars.ps1 -Bits ${{ matrix.bits }} -Link ${{ matrix.link }} | |
- | |
name: Download Cygwin installer | |
shell: pwsh | |
run: Invoke-WebRequest -Uri https://cygwin.com/setup-x86_64.exe -OutFile C:\CygwinInstaller.exe | |
- | |
name: Install Cygwin | |
shell: cmd | |
run: > | |
C:\CygwinInstaller.exe | |
--root C:\cygwin | |
--local-package-dir C:\cygwin-packages | |
--packages ${{ steps.vars.outputs.cygwin-packages }} | |
--site http://mirrors.kernel.org/sourceware/cygwin/ | |
--only-site | |
--quiet-mode | |
--upgrade-also | |
--no-shortcuts | |
- | |
name: Setup Cygwin environment | |
id: setup-cygwin | |
working-directory: C:\cygwin | |
run: | | |
/bin/mkdir -p "$HOME" | |
printf '\nPATH=${{ steps.vars.outputs.cygwin-path }}\nexport PATH\n' >>$HOME/.bash_profile | |
/bin/mkdir -p /src/downloads | |
/bin/mkdir -p /installed | |
/bin/mkdir -p /output | |
/bin/perl -pe 's/\r\n|\n|\r/\r\n/g' < "$(/bin/cygpath "$GITHUB_WORKSPACE/build-exe/license-for-distribution.txt")" > /output/license.txt | |
- | |
name: Dump Cygwin PATH | |
run: | | |
IFS=: | |
for p in $PATH; do | |
printf '%s\n' "$p" | |
done | |
- | |
name: Download CLDR | |
working-directory: C:\cygwin\src\downloads | |
shell: pwsh | |
run: | | |
if (Test-Path -LiteralPath "cldr-$env:CLDR_VERSION.zip" -PathType Leaf) { | |
Write-Host -Object 'Already downloaded' | |
} else { | |
Invoke-WebRequest "https://unicode.org/Public/cldr/$env:CLDR_VERSION/core.zip" -OutFile "cldr-$env:CLDR_VERSION.zip" | |
Write-Host -Object 'Downloaded' | |
} | |
- | |
name: Extract CLDR | |
working-directory: C:\cygwin\installed | |
run: | | |
unzip -p /src/downloads/cldr-$CLDR_VERSION.zip LICENSE >cldr-license.txt | |
unzip -p /src/downloads/cldr-$CLDR_VERSION.zip common/supplemental/plurals.xml >cldr-plurals.xml | |
- | |
name: Download iconv | |
working-directory: C:\cygwin\src\downloads | |
shell: pwsh | |
run: | | |
if (Test-Path -LiteralPath "libiconv-$env:ICONV_VERSION.tar.gz" -PathType Leaf) { | |
Write-Host -Object 'Already downloaded' | |
} else { | |
Invoke-WebRequest "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$env:ICONV_VERSION.tar.gz" -OutFile "libiconv-$env:ICONV_VERSION.tar.gz" | |
Write-Host -Object 'Downloaded' | |
} | |
- | |
name: Extract iconv | |
working-directory: C:\cygwin\src | |
run: tar x -z -f downloads/libiconv-$ICONV_VERSION.tar.gz | |
- | |
name: Configure iconv | |
id: iconv-configure | |
working-directory: C:\cygwin\src\libiconv-${{ env.ICONV_VERSION }} | |
run: | | |
mkdir build | |
cd build | |
../configure \ | |
CPPFLAGS='${{ steps.vars.outputs.cpp-flags }}' \ | |
LDFLAGS='${{ steps.vars.outputs.ld-flags }}' \ | |
${{ steps.vars.outputs.configure-args }} \ | |
--prefix=/installed | |
- | |
name: Compile iconv | |
working-directory: C:\cygwin\src\libiconv-${{ env.ICONV_VERSION }}\build | |
run: make --jobs=$(nproc) | |
- | |
name: Check iconv | |
working-directory: C:\cygwin\src\libiconv-${{ env.ICONV_VERSION }}\build | |
run: make check --jobs=$(nproc) | |
- | |
name: Install iconv | |
working-directory: C:\cygwin\src\libiconv-${{ env.ICONV_VERSION }}\build | |
run: make install && cp ../COPYING /installed/iconv-license.txt | |
- | |
name: Download gettext | |
working-directory: C:\cygwin\src\downloads | |
shell: pwsh | |
run: | | |
if (Test-Path -LiteralPath "gettext-$env:GETTEXT_VERSION.tar.gz" -PathType Leaf) { | |
Write-Host -Object 'Already downloaded' | |
} else { | |
Invoke-WebRequest "${{ steps.vars.outputs.gettext-source-url }}" -OutFile "gettext-$env:GETTEXT_VERSION.tar.gz" | |
Write-Host -Object 'Downloaded' | |
} | |
- | |
name: Extract gettext | |
working-directory: C:\cygwin\src | |
run: tar x -z -f downloads/gettext-$GETTEXT_VERSION.tar.gz | |
- | |
name: Configure gettext | |
id: gettext-configure | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }} | |
run: | | |
mkdir build | |
cd build | |
../configure \ | |
CPPFLAGS='-I/installed/include ${{ steps.vars.outputs.cpp-flags }}' \ | |
LDFLAGS='-L/installed/lib ${{ steps.vars.outputs.ld-flags }}' \ | |
${{ steps.vars.outputs.configure-args }} \ | |
--prefix=/installed \ | |
--disable-java \ | |
--disable-native-java \ | |
--disable-csharp \ | |
--disable-openmp \ | |
--disable-curses \ | |
--without-emacs \ | |
--with-included-libxml \ | |
--without-bzip2 \ | |
--without-xz | |
- | |
name: Ignore gettext C tests | |
if: steps.vars.outputs.gettext-ignore-tests-c | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }} | |
run: for f in ${{ steps.vars.outputs.gettext-ignore-tests-c }}; do echo 'int main() { return 0; }' >$f; done | |
- | |
name: Install gettext license | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }} | |
run: cp COPYING /installed/gettext-license.txt | |
- | |
name: Compile gettext/gnulib-local | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gnulib-local | |
run: make --jobs=$(nproc) | |
- | |
name: Check gettext/gnulib-local | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gnulib-local | |
run: make --jobs=$(nproc) check | |
- | |
name: Install gettext/gnulib-local | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gnulib-local | |
run: make --jobs=$(nproc) install | |
- | |
name: Compile gettext/gettext-runtime | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-runtime | |
run: make --jobs=$(nproc) | |
- | |
name: Check gettext/gettext-runtime | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-runtime | |
run: make --jobs=$(nproc) check | |
- | |
name: Install gettext/gettext-runtime | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-runtime | |
run: make --jobs=$(nproc) install | |
- | |
name: Compile gettext/libtextstyle | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\libtextstyle | |
run: make --jobs=$(nproc) | |
- | |
name: Check gettext/libtextstyle | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\libtextstyle | |
run: make --jobs=$(nproc) check | |
- | |
name: Install gettext/libtextstyle | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\libtextstyle | |
run: make --jobs=$(nproc) install | |
- | |
name: Compile gettext/gettext-tools | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-tools | |
run: make --jobs=$(nproc) | |
- | |
name: Check gettext/gettext-tools | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-tools | |
run: XFAIL_TESTS='${{ steps.vars.outputs.gettext-xfail-gettext-tools }}' make --jobs=$(nproc) check | |
- | |
name: Install gettext/gettext-tools | |
working-directory: C:\cygwin\src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-tools | |
run: make --jobs=$(nproc) install | |
- | |
name: Prepare build log | |
id: prepare-build-log | |
if: (success() || failure()) && steps.iconv-configure.outcome == 'success' | |
run: | | |
mkdir /build-log | |
if [ -d /src/libiconv-$ICONV_VERSION/build ]; then | |
tar c -J -f /build-log/iconv.tar.xz /src/libiconv-$ICONV_VERSION/build | |
fi | |
if [ -d /src/gettext-$GETTEXT_VERSION/build ]; then | |
tar c -J -f /build-log/gettext.tar.xz /src/gettext-$GETTEXT_VERSION/build | |
fi | |
if [ -d /installed ]; then | |
tar c -J -f /build-log/installed.tar.xz /installed | |
fi | |
ls -al /build-log | |
- | |
name: Copy built assets | |
run: ./build-exe/create-output.sh /installed /output '${{ steps.vars.outputs.mingw-host }}' | |
- | |
name: Process dependencies | |
shell: pwsh | |
run: > | |
./build-exe/process-dependencies.ps1 | |
-Bits ${{ matrix.bits }} | |
-Link ${{ matrix.link }} | |
-OutputPath C:\cygwin\output | |
-MinGWPath C:\cygwin\usr\${{ steps.vars.outputs.mingw-host }} | |
- | |
name: Delete install directory | |
run: rm -rf /installed | |
- | |
name: Check if programs load translations correctly | |
shell: pwsh | |
run: | | |
$env:LANGUAGE = 'it' | |
$stdout = & C:\cygwin\output\bin\xgettext.exe --help | |
if (-not($?)) { | |
throw "xgettext.exe failed" | |
} | |
$stdout = $stdout -join "`n" | |
if (!$stdout.Contains('impostazione predefinita')) { | |
throw "xgettext.exe didn't load the translations.`nIts output is:`n$stdout" | |
} | |
Write-Host "xgettext.exe correctly loaded the translations when LANGUAGE=$env:LANGUAGE`nIts localized output is`n$stdout" | |
- | |
name: Create zip | |
working-directory: C:\cygwin\output | |
shell: cmd | |
run: 7z.exe a -bd -bt -r -sse -tzip C:\gettext${{ env.GETTEXT_VERSION }}-iconv${{ env.ICONV_VERSION }}-${{ matrix.link }}-${{ matrix.bits }}.zip | |
- | |
name: Upload zip | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.link }}-${{ matrix.bits }}-zip | |
path: C:\gettext${{ env.GETTEXT_VERSION }}-iconv${{ env.ICONV_VERSION }}-${{ matrix.link }}-${{ matrix.bits }}.zip | |
if-no-files-found: error | |
compression-level: 0 | |
- | |
name: Create installer | |
shell: pwsh | |
run: > | |
./build-exe/create-installer.ps1 | |
-Bits ${{ matrix.bits }} | |
-Link ${{ matrix.link }} | |
-SourceDirectory C:\cygwin\output | |
-OutputDirectory C:\ | |
- | |
name: Upload installer | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.link }}-${{ matrix.bits }}-exe | |
path: C:\gettext${{ env.GETTEXT_VERSION }}-iconv${{ env.ICONV_VERSION }}-${{ matrix.link }}-${{ matrix.bits }}.exe | |
if-no-files-found: error | |
compression-level: 0 | |
- | |
name: Upload build log | |
if: always() && steps.prepare-build-log.outcome == 'success' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.link }}-${{ matrix.bits }}-log | |
if-no-files-found: ignore | |
retention-days: 1 | |
include-hidden-files: true | |
compression-level: 0 | |
path: C:\cygwin\build-log | |
- | |
name: Persist cache | |
if: always() && steps.restore-cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
key: ${{ steps.restore-cache.outputs.cache-primary-key }} | |
path: | | |
C:\cygwin-packages | |
C:\cygwin\src\downloads |