Run Windows CI on Github Actions #99
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: Windows | |
on: | |
pull_request: | |
paths: | |
- '**.c' | |
- '**.h' | |
- '**.sh' | |
- .github/workflows/windows.yml | |
- '**.am' | |
- '**.mak' | |
- configure.ac | |
push: | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
jobs: | |
build: | |
runs-on: ${{ matrix.image }} | |
strategy: | |
matrix: | |
platform: [x86, x64] | |
configuration: [Light, Release] | |
image: [windows-2019, windows-2022] | |
env: | |
OPENPACE_VER: 1.1.3 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Git describe | |
id: ghd | |
uses: proudust/gh-describe@v2 | |
- name: Package name | |
shell: bash | |
run: | | |
echo PACKAGE_NAME=OpenSC-${{ steps.ghd.outputs.tag }} >> $GITHUB_ENV | |
echo ARTIFACT=OpenSC-${{ steps.ghd.outputs.tag }}_${{ matrix.platform == 'x86' && 'win32' || 'win64' }}${{ matrix.configuration == 'Light' && '-Light' || '' }} >> $GITHUB_ENV | |
- name: Install CPDK | |
run: choco install windows-cryptographic-provider-development-kit -y > $null | |
- name: Install autotools | |
uses: msys2/setup-msys2@v2 | |
with: | |
install: autotools mingw-w64-x86_64-pkg-config | |
- name: Bootstrap | |
shell: msys2 {0} | |
run: | | |
if [[ "${{ github.event_name }}" == "push" ]]; then | |
if [[ "${{ github.ref_name }}" == "master" ]]; then | |
./bootstrap | |
else | |
./bootstrap.ci -s "-${{ github.ref_name }}" | |
fi | |
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
if [[ "${{ github.base_ref }}" == "master" ]]; then | |
./bootstrap.ci -s "-pr${{ github.event.number }}" | |
else | |
./bootstrap.ci -s "-${{ github.base_ref }}-pr${{ github.event.number }}" | |
fi | |
fi | |
- name: Configure | |
shell: bash | |
run: ./configure --disable-openssl --disable-readline --disable-zlib || cat config.log | |
- name: Setup dev env | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{ matrix.platform }} | |
- name: Prepare vcpkg | |
if: matrix.configuration == 'Release' | |
uses: lukka/run-vcpkg@v7 | |
with: | |
vcpkgArguments: zlib openssl | |
vcpkgGitCommitId: 511d74f695bd45959d12b50b00f1b68f69e8f0b0 | |
vcpkgTriplet: ${{ matrix.platform }}-windows-static | |
- name: Restore Cache | |
if: matrix.configuration == 'Release' | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: openpace-${{ env.OPENPACE_VER }} | |
key: OpenPACE-${{ env.OPENPACE_VER }}-${{ matrix.image }}-${{ matrix.platform }} | |
- name: Build OpenPACE | |
if: matrix.configuration == 'Release' && steps.cache.outputs.cache-hit != 'true' | |
run: | | |
Invoke-WebRequest "https://github.com/frankmorgner/openpace/archive/${env:OPENPACE_VER}.zip" -OutFile openpace.zip | |
tar xf openpace.zip | |
cd openpace-${env:OPENPACE_VER}\src | |
cl /nologo /O1 /Zi /W3 /GS /MT /I${env:RUNVCPKG_VCPKG_ROOT}\installed\${env:RUNVCPKG_VCPKG_TRIPLET}\include /I. ` | |
/DX509DIR=`"/`" /DCVCDIR=`"/`" /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN ` | |
/DHAVE_ASN1_STRING_GET0_DATA /DHAVE_DECL_OPENSSL_ZALLOC /DHAVE_DH_GET0_KEY /DHAVE_DH_GET0_PQG ` | |
/DHAVE_DH_SET0_KEY /DHAVE_DH_SET0_PQG /DHAVE_ECDSA_SIG_GET0 /DHAVE_ECDSA_SIG_SET0 ` | |
/DHAVE_EC_KEY_METHOD /DHAVE_RSA_GET0_KEY /DHAVE_RSA_SET0_KEY /DHAVE_EC_POINT_GET_AFFINE_COORDINATES ` | |
/DHAVE_EC_POINT_SET_AFFINE_COORDINATES /DHAVE_EVP_PKEY_DUP /c ` | |
ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c ` | |
eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c ` | |
pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c ssl_compat.c | |
lib /nologo /machine:${{ matrix.platform }} /out:libeac.lib ` | |
ca_lib.obj cv_cert.obj cvc_lookup.obj x509_lookup.obj eac_asn1.obj eac.obj eac_ca.obj eac_dh.obj ` | |
eac_ecdh.obj eac_kdf.obj eac_lib.obj eac_print.obj eac_util.obj misc.obj pace.obj pace_lib.obj ` | |
pace_mappings.obj ri.obj ri_lib.obj ta.obj ta_lib.obj objects.obj ssl_compat.obj | |
- name: Set NMake Variables | |
if: matrix.configuration == 'Release' | |
run: | | |
$VCPKG_DIR="${env:RUNVCPKG_VCPKG_ROOT}\installed\${env:RUNVCPKG_VCPKG_TRIPLET}" | |
$NMAKE_EXTRA="ZLIBSTATIC_DEF=/DENABLE_ZLIB_STATIC ZLIB_INCL_DIR=/I${VCPKG_DIR}\include ZLIB_LIB=${VCPKG_DIR}\lib\zlib.lib" | |
$NMAKE_EXTRA+=" OPENSSL_DEF=/DENABLE_OPENSSL OPENSSL_DIR=${VCPKG_DIR} OPENSSL_LIB=${VCPKG_DIR}\lib\libcrypto.lib OPENSSL_EXTRA_CFLAGS=/DOPENSSL_SECURE_MALLOC_SIZE=65536" | |
$NMAKE_EXTRA+=" OPENPACE_DEF=/DENABLE_OPENPACE OPENPACE_DIR=${env:GITHUB_WORKSPACE}\openpace-${env:OPENPACE_VER}" | |
echo "NMAKE_EXTRA=$NMAKE_EXTRA" >> $env:GITHUB_ENV | |
- name: Build OpenSC | |
run: nmake /f Makefile.mak ${{ env.NMAKE_EXTRA }} | |
- name: Build Installer | |
run: | | |
cd win32 && nmake /nologo /f Makefile.mak ${{ env.NMAKE_EXTRA }} OpenSC.msi | |
move OpenSC.msi "..\\OpenSC-${env:ARTIFACT}.msi" | |
- name: Debug symbols | |
run: | | |
Get-ChildItem -recurse . -exclude vc*.pdb *.pdb | % { | |
7z a -tzip ${env:ARTIFACT}-Debug.zip $_.FullName | |
} | |
- name: Archive artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: msi_${{ matrix.image }}_${{ matrix.platform }}_${{ matrix.configuration }} | |
path: | | |
./*.msi | |
./*-Debug.zip |