CI: upload release #359
Workflow file for this run
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: wget-for-windows CI | |
on: [push, pull_request] | |
jobs: | |
# Customize the env and configure args | |
# windows-2022 installs only pure MSYS2: https://github.com/actions/virtual-environments/issues/1572#issuecomment-908941444 | |
# https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Install-Msys2.ps1 | |
# https://github.com/actions/virtual-environments/tree/main/images/win/toolsets | |
build: | |
# https://docs.github.com/en/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
strategy: | |
matrix: | |
#os: [ubuntu-latest, windows-latest] # run native test | |
bits: [32, 64] | |
ftype: [shared-full, static-lite] | |
fail-fast: false | |
# https://github.com/actions/virtual-environments | |
name: mingw${{matrix.bits}}-wintls-winhashes-${{matrix.ftype}} | |
runs-on: windows-latest | |
env: | |
mingw: mingw${{matrix.bits}} | |
build_type: wintls-winhashes-${{matrix.ftype}} | |
defaults: | |
run: | |
shell: msys2 {0} | |
steps: | |
- name: Set up ENVs for MSYS2 to inherit | |
shell: bash | |
run: | | |
# Explicitly enable year2038: | |
# gnulib requires `-D__MINGW_USE_VC2005_COMPAT` for `time_t` from `year2038.m4` and `largefile.m4`. | |
# gnulib/doc/posix-headers/sys_time.texi | |
case "${mingw}" in | |
mingw32) arch="i686"; echo CFLAGS="-D__MINGW_USE_VC2005_COMPAT=1" >> $GITHUB_ENV ;; | |
mingw64) arch="x86_64" ;; | |
*) exit 1 ;; | |
esac | |
BRoot="${PWD}" | |
BDir="build/${build_type}/${mingw}" | |
CDir="${BDir}-config" | |
echo arch="$arch" >> $GITHUB_ENV | |
echo BRoot="$BRoot" >> $GITHUB_ENV | |
echo BDir="$BDir" >> $GITHUB_ENV | |
echo CDir="$CDir" >> $GITHUB_ENV | |
# https://github.com/msys2/setup-msys2 | |
- name: Set up MSYS2 | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: ${{env.mingw}} | |
release: false | |
#path-type: inherit | |
# `AX_CODE_COVERAGE` requires autoconf-archive: https://github.com/google/oss-fuzz/pull/5379/files | |
# gpgme for metalink, but depends on many others, that's not preferred on windows | |
# gettext for NLS, expat for metalink, libidn2 and libunistring for libpsl | |
# mingw-w64-${{env.arch}}-libmetalink is removed from MSYS2 repo, compile and install it ourself. | |
# pacman group: https://packages.msys2.org/group/ | |
install: >- | |
base-devel | |
gperf | |
autoconf | |
automake | |
autoconf-archive | |
git | |
python | |
libcares-devel | |
mingw-w64-${{env.arch}}-gcc | |
mingw-w64-${{env.arch}}-expat | |
mingw-w64-${{env.arch}}-gpgme | |
mingw-w64-${{env.arch}}-libpsl | |
mingw-w64-${{env.arch}}-libidn2 | |
mingw-w64-${{env.arch}}-libunistring | |
mingw-w64-${{env.arch}}-gettext | |
# In here, test requires linux flavor python! | |
- name: Hack python | |
run: | | |
python -V | |
python -c "import sys; print(sys.executable)" | |
python3 -V | |
python3 -c "import sys; print(sys.executable)" | |
rm /$mingw/bin/python* 2>/dev/null | |
#pacman -R -dd --noconfirm mingw-w64-${{env.arch}}-python 2>/dev/null | |
python.exe -V | |
python.exe -c "import sys; print(sys.executable)" | |
# MinGW-w64 pre-installed | |
- name: Show setup result | |
run: | | |
echo "ls /" | |
ls / | |
echo "bash --version" | |
bash --version | |
echo "gcc -v" | |
gcc -v | |
git --version | |
python -V | |
python -c "import sys; print(sys.executable)" | |
python3 -V | |
python3 -c "import sys; print(sys.executable)" | |
perl -e 'print $^O . "\n"' | |
pwd | |
echo "PATH" | |
echo "$PATH" | |
echo "$BRoot" | |
echo "$BDir" | |
echo "$CDir" | |
- uses: actions/checkout@v4 | |
# Shallow fetch makes version unknown: git describe --abbrev=4 --match="$prefix*" HEAD | |
with: | |
fetch-depth: 0 | |
# gettext-0.20 issue: https://github.com/coreutils/gnulib/blob/master/build-aux/po/Makefile.in.in#L11 | |
# gettext and gettext-devel v0.20 is not available on MSYS2 | |
# wget => gnulib_po => gnulib/build-aux/po/Makefile.in.in, po/Makefile.in.in from MSYS2 gettext | |
- name: Generate configure | |
run: | | |
loc_ver=$(gettext -V | sed -n "s/gettext[^0-9]\+\([0-9.]\+\).*/\1/p") | |
req_ver=$(sed -n "s/^\gettext\s\+\([0-9.]\+\)$/\1/mp" bootstrap.conf) | |
if [ -n "${req_ver}" ] && [ ${loc_ver} \< ${req_ver} ]; then | |
echo "Reset gettext version: bootstrap.conf requires "${req_ver}", local is "${loc_ver} | |
sed -i "s/^\(gettext\s\+\)[0-9.]\+$/\1${loc_ver}/gm" bootstrap.conf | |
fi | |
req_ver=$(sed -n "s/^AM_GNU_GETTEXT_VERSION(\[\([0-9.]\+\)\])$/\1/mp" configure.ac) | |
if [ -n "${req_ver}" ] && [ ${loc_ver} \< ${req_ver} ]; then | |
echo "Reset gettext version: configure.ac requires "${req_ver}", local is "${loc_ver} | |
sed -i "s/^\(AM_GNU_GETTEXT_VERSION(\[\)[0-9.]\+\(\])\)$/\1${loc_ver}\2/gm" configure.ac | |
fi | |
./bootstrap --skip-po | |
sed -i "s/-dirty\b//p" configure | |
# --> | |
- name: Install extra dependencies | |
run: | | |
if [ "${{matrix.ftype}}" = "shared-full" ]; then | |
wget https://github.com/metalink-dev/libmetalink/releases/download/release-0.1.3/libmetalink-0.1.3.tar.gz | |
tar -xvzf libmetalink-0.1.3.tar.gz | |
cd libmetalink-0.1.3 | |
./configure --disable-xmltest | |
make install | |
elif [ "${{matrix.ftype}}" = "static-lite" ]; then | |
wget https://github.com/win-iconv/win-iconv/archive/refs/tags/v0.0.8.tar.gz | |
tar -xvzf v0.0.8.tar.gz | |
cd win-iconv-0.0.8 | |
make -E CFLAGS=-Os -E prefix=/$mingw install | |
fi | |
- name: configure | |
run: | | |
mkdir -p $BDir | |
mkdir -p $CDir | |
cd $CDir | |
pwd | |
export CFLAGS+=" -Wall -D_WIN32_WINNT=0x0600 -DGNULIB_defined_ESOCK -DSite=https://github.com/lifenjoiner/wget-for-windows" | |
if [ "${{matrix.ftype}}" = "shared-full" ]; then | |
CFLAGS+=" -O2" $BRoot/configure --prefix=$BRoot/$BDir --disable-rpath --with-cares --with-winidn --enable-threads=windows | |
elif [ "${{matrix.ftype}}" = "static-lite" ]; then | |
CFLAGS+=" -Os" LDFLAGS="-static -s" $BRoot/configure --prefix=$BRoot/$BDir --disable-debug --disable-rpath --disable-nls --without-libpsl --without-metalink --disable-pcre --disable-pcre2 --with-winidn --enable-threads=windows | |
fi | |
# <-- | |
# gnulib_po gettext requires gettext version 0.20 higher env can have! | |
- name: Build | |
run: | | |
cd $CDir | |
echo -e "all:\n\n" > gnulib_po/Makefile | |
make | |
- name: Show compiled wget info | |
run: | | |
ls -l $CDir/src/wget.exe | |
SHA=$(sha1sum $CDir/src/wget.exe | cut -b 1-40) | |
echo SHA="$SHA" >> $GITHUB_ENV | |
$CDir/src/wget -V | |
- name: fuzz | |
run: | | |
cd $CDir/fuzz | |
make check | |
- name: testenv | |
if: ${{success()}} || ${{failure()}} | |
run: | | |
cd $CDir/testenv | |
make check | |
timeout-minutes: 5 # in case of stuck | |
- name: tests | |
if: ${{success()}} || ${{failure()}} | |
run: | | |
cd $CDir/tests | |
make check | |
timeout-minutes: 5 # in case of stuck | |
- name: Upload wget | |
uses: actions/upload-artifact@v4 | |
if: ${{success()}} || ${{failure()}} | |
with: | |
name: wget-${{env.mingw}}-${{env.build_type}}_${{github.head_ref || github.ref_name}}_${{env.SHA}} | |
path: | | |
${{env.CDir}}/src/wget.exe | |
- name: Upload logs | |
uses: actions/upload-artifact@v4 | |
if: ${{failure()}} | |
with: | |
name: wget-${{env.mingw}}-${{env.build_type}}-logs | |
# Previous steps can be stuck and then timeout, so all `.log` files and sub-folders. | |
path: | | |
${{env.CDir}}/config.log | |
${{env.CDir}}/lib/libgnu.a | |
${{env.CDir}}/src/libunittest.a | |
${{env.CDir}}/fuzz/*.log | |
${{env.CDir}}/fuzz/Makefile | |
${{env.CDir}}/testenv/ | |
${{env.CDir}}/tests/*.log | |
${{env.CDir}}/tests/Makefile | |
${{env.CDir}}/tests/**/ | |
!${{env.CDir}}/tests/.deps/ | |
!${{env.CDir}}/tests/*.exe | |
!${{env.CDir}}/tests/*.o | |
- name: Package release assets | |
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.ftype == 'static-lite' }} | |
run: | | |
7z a wget-${{env.mingw}}-${{env.build_type}}_${{github.head_ref || github.ref_name}}_${{env.SHA}} ${{env.CDir}}/src/wget.exe | |
- name: Upload release assets | |
uses: softprops/action-gh-release@v2 | |
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.ftype == 'static-lite' }} | |
with: | |
draft: true | |
files: | | |
wget-${{env.mingw}}-${{env.build_type}}_${{github.head_ref || github.ref_name}}_${{env.SHA}}.7z |