Skip to content
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
33 changes: 17 additions & 16 deletions .github/actions/windows/build/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: "Build DLL files for Windows"
description: "Prepares the PHP build environment for the MongoDB driver"
inputs:
version:
ref:
description: Git reference to build
required: false
php-version:
description: "PHP version to build for"
required: true
arch:
Expand All @@ -10,24 +13,22 @@ inputs:
ts:
description: "Thread-safety (nts or ts)"
required: true
outputs:
vs:
description: "The Visual Studio version"
value: ${{ steps.prepare-build-env.outputs.vs }}
build-dir:
description: "The build directory to be used"
value: ${{ steps.prepare-build-env.outputs.build-dir }}
run-tests:
description: "Whether to run tests after building"
required: false
default: "false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a string value instead of a bool?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inputs for composite actions are always strings, I wanted to make this explicit here.

runs:
using: composite
steps:
- name: Prepare build environment
id: prepare-build-env
uses: ./.github/actions/windows/prepare-build
- name: Build extension
uses: php/php-windows-builder/extension@1.6.0
with:
version: ${{ inputs.version }}
extension-ref: ${{ inputs.ref }}
php-version: ${{ inputs.php-version }}
arch: ${{ inputs.arch }}
ts: ${{ inputs.ts }}

- name: Build driver
shell: cmd
run: nmake /nologo
run-tests: ${{ inputs.run-tests == 'true' && true || false }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted that you just look for a string value here. What is && true || false accomplishing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a ternary since I don't trust type coercion in YAML. Could potentially be simplified but I didn't want to run the risk of it misbehaving

test-runner-args: "--show-diff"
args: "--enable-mongodb --with-mongodb-sasl=yes --with-mongodb-client-side-encryption=yes"
libs: "openssl"
test-workers: 1
57 changes: 0 additions & 57 deletions .github/actions/windows/prepare-build/action.yml

This file was deleted.

134 changes: 0 additions & 134 deletions .github/workflows/build-windows-package.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/build-windows-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: "Build Windows Packages"
run-name: "Build Windows Packages for ${{ inputs.ref }}"

on:
workflow_call:
inputs:
version:
description: "The version being built"
type: string
required: true
ref:
description: "The git reference to build"
type: string
required: true
upload_release_assets:
description: "Whether to upload assets to a GitHub release"
type: boolean
default: false

jobs:
build:
name: "Build DLL"
runs-on: ${{ matrix.os }}
defaults:
run:
shell: cmd

strategy:
fail-fast: false
matrix:
os: [ "windows-2022" ]
# Note: keep this in sync with the Windows matrix in tests.yml
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
arch: [ x64, x86 ]
ts: [ ts, nts ]

steps:
- uses: actions/checkout@v4
with:
submodules: true
ref: ${{ inputs.ref }}

- name: "Build Driver"
id: build-driver
uses: ./.github/actions/windows/build
with:
ref: ${{ inputs.ref }}
php-version: ${{ matrix.php-version }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
run-tests: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are passing a bool and overriding the default string value ("false").


sign-and-upload:
environment: release
name: "Sign and create package"
needs: build
runs-on: "ubuntu-latest"
permissions:
id-token: write

steps:
- name: "Generate token and checkout repository"
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
with:
app_id: ${{ vars.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
ref: ${{ inputs.ref }}

- name: "Set up drivers-github-tools"
uses: mongodb-labs/drivers-github-tools/setup@v2
with:
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
aws_region_name: ${{ vars.AWS_REGION_NAME }}
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}

- name: Get artifacts
uses: actions/download-artifact@v5
with:
path: artifacts
pattern: php_mongodb-*.zip
merge-multiple: true

- name: "Create detached signatures for packages"
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
with:
filenames: php_mongodb*.zip

- name: "Move signatures from release assets folder"
run: |
mv ${RELEASE_ASSETS}/php_mongodb*.sig artifacts/

- name: "Upload assets to release"
if: ${{ inputs.upload_release_assets }}
run: |
gh release upload ${{ inputs.version }} artifacts/php_mongodb* --clobber
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not necessary but you could restrict the extension to "zip" and "sig". I assume the directory starts empty, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does :)

14 changes: 2 additions & 12 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,9 @@ jobs:

build-windows:
name: "Create Windows packages"
uses: ./.github/workflows/build-windows-package.yml
uses: ./.github/workflows/build-windows-packages.yml
with:
version: ${{ inputs.version }}
ref: refs/tags/${{ inputs.version }}
php: ${{ matrix.php }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
upload_release_asset: true
upload_release_assets: true
secrets: inherit
strategy:
fail-fast: false
matrix:
# Note: keep this in sync with the Windows matrix in tests.yml
php: [ "8.1", "8.2", "8.3", "8.4" ]
arch: [ x64, x86 ]
ts: [ ts, nts ]
Loading
Loading