Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: windows binaries on windows-2022 #249

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,34 +172,36 @@ jobs:
target/debug/libckms_pkcs11.so

windows-tests:
uses: ./.github/workflows/build_generic.yml
uses: ./.github/workflows/build_windows.yml
with:
toolchain: ${{ inputs.toolchain }}
distribution: ubuntu-20.04
archive-name: windows_tests
commands: |
sudo apt-get install --no-install-recommends -qq libclang-dev gcc-mingw-w64-x86-64
rustup target add x86_64-pc-windows-gnu
rustup target add x86_64-pc-windows-msvc

# build only `ckms`
cd crate/cli
cargo build --target x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-msvc

# build pkcs11 provider
cd ../pkcs11/provider
cargo build --release --target x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-msvc
cd ../../..

sudo mkdir -p /usr/local/openssl
sudo chown -R $USER /usr/local/openssl
bash ./scripts/local_ossl_instl.sh /usr/local/openssl cross-compile-windows
$env:VCPKG_INSTALLATION_ROOT
dir $env:VCPKG_INSTALLATION_ROOT
vcpkg install openssl[fips]

vcpkg integrate install
set VCPKGRS_DYNAMIC=1
$env:OPENSSL_DIR="$env:VCPKG_INSTALLATION_ROOT\packages\openssl_x64-windows"

cd crate/server
cargo build --target x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-msvc
artifacts: |
target/x86_64-pc-windows-gnu/debug/ckms.exe
target/x86_64-pc-windows-gnu/debug/cosmian_kms_server.exe
target/x86_64-pc-windows-gnu/release/ckms_pkcs11.dll
target/x86_64-pc-windows-msvc/debug/ckms.exe
target/x86_64-pc-windows-msvc/debug/cosmian_kms_server.exe
target/x86_64-pc-windows-msvc/debug/ckms_pkcs11.dll

mac-tests:
uses: ./.github/workflows/build_generic.yml
Expand Down
28 changes: 15 additions & 13 deletions .github/workflows/build_all_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,34 +160,36 @@ jobs:
target/release/libckms_pkcs11.so

windows:
uses: ./.github/workflows/build_generic.yml
uses: ./.github/workflows/build_windows.yml
with:
toolchain: ${{ inputs.toolchain }}
distribution: ubuntu-20.04
archive-name: windows
commands: |
sudo apt-get install --no-install-recommends -qq libclang-dev gcc-mingw-w64-x86-64
rustup target add x86_64-pc-windows-gnu
rustup target add x86_64-pc-windows-msvc

# build only `ckms`
cd crate/cli
cargo build --release --target x86_64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-msvc

# build pkcs11 provider
cd ../pkcs11/provider
cargo build --release --target x86_64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-msvc
cd ../../..

sudo mkdir -p /usr/local/openssl
sudo chown -R $USER /usr/local/openssl
bash ./scripts/local_ossl_instl.sh /usr/local/openssl cross-compile-windows
$env:VCPKG_INSTALLATION_ROOT
dir $env:VCPKG_INSTALLATION_ROOT
vcpkg install openssl[fips]

vcpkg integrate install
set VCPKGRS_DYNAMIC=1
$env:OPENSSL_DIR="$env:VCPKG_INSTALLATION_ROOT\packages\openssl_x64-windows"

cd crate/server
cargo build --release --target x86_64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-msvc
artifacts: |
target/x86_64-pc-windows-gnu/release/ckms.exe
target/x86_64-pc-windows-gnu/release/cosmian_kms_server.exe
target/x86_64-pc-windows-gnu/release/ckms_pkcs11.dll
target/x86_64-pc-windows-msvc/release/ckms.exe
target/x86_64-pc-windows-msvc/release/cosmian_kms_server.exe
target/x86_64-pc-windows-msvc/release/ckms_pkcs11.dll

mac:
uses: ./.github/workflows/build_generic.yml
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: KMS cargo build - windows

on:
workflow_call:
inputs:
toolchain:
required: true
type: string
archive-name:
required: true
type: string
commands:
required: true
type: string
artifacts:
required: true
type: string

jobs:
kms-build:
name: ${{ inputs.archive-name }}
runs-on: windows-2022
steps:
- name: Print ENV
run: printenv

- uses: actions/checkout@v3

- name: Set up cargo cache
id: cargo_cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
$VCPKG_INSTALLATION_ROOT
key: ${{ runner.os }}-cargo-windows-2022-${{ inputs.archive-name }}-kms-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-windows-2022-${{ inputs.archive-name }}-kms-${{ hashFiles('**/Cargo.lock') }}

- uses: dtolnay/rust-toolchain@master
if: steps.cargo_cache.outputs.cache-hit != 'true'
with:
toolchain: ${{ inputs.toolchain }}
components: rustfmt, clippy

- name: Build
if: steps.cargo_cache.outputs.cache-hit != 'true'
shell: pwsh
run: ${{ inputs.commands }}
env:
# Google variables
TEST_GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.TEST_GOOGLE_OAUTH_CLIENT_ID }}
TEST_GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.TEST_GOOGLE_OAUTH_CLIENT_SECRET }}
TEST_GOOGLE_OAUTH_REFRESH_TOKEN: ${{ secrets.TEST_GOOGLE_OAUTH_REFRESH_TOKEN }}

- name: Upload KMS for windows-2022
if: inputs.artifacts != ''
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.archive-name }}
path: ${{ inputs.artifacts }}
retention-days: 1
if-no-files-found: error
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
kms_path: .
os: macos-12
- archive_name: windows_tests
kms_path: debug
os: windows-2019
kms_path: .
os: windows-2022

steps:
- uses: actions/download-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
os: macos-12
- archive_name: windows
kms_path: .
os: windows-2019
os: windows-2022

steps:
- uses: actions/download-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions scripts/local_ossl_instl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [[ ! "${1}" = /* ]]; then
exit 1
fi

echo "Setup for OpenSSL version 3.1.0 with FIPS module"
echo "Setup for OpenSSL version 3.2.0 with FIPS module"
echo "Installing OpenSSL to ${1}..."

OPENSSL_DIR="${1}"
Expand All @@ -20,7 +20,7 @@ OPENSSL_DIR="${1}"
rm -rf "${OPENSSL_DIR}/ssl"
mkdir -p "${OPENSSL_DIR}/ssl"

# Downloading and installing OpenSSL 3.1.0.
# Downloading and installing OpenSSL 3.2.0.
cd "$(mktemp -d)"
VERSION=openssl-3.2.0
URL_PREFIX=${VERSION}
Expand Down
Loading