Skip to content

Commit 77f26f6

Browse files
Merge v1.19 into master (#1585)
2 parents 8cb3acb + 9f0789f commit 77f26f6

File tree

7 files changed

+285
-224
lines changed

7 files changed

+285
-224
lines changed

.github/actions/windows/prepare-build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ runs:
4141
- name: Enable Developer Command Prompt
4242
uses: ilammy/msvc-dev-cmd@v1
4343
with:
44-
arch: ${{ matrix.arch }}
44+
arch: ${{ inputs.arch }}
4545
toolset: ${{ steps.setup-php.outputs.toolset }}
4646

4747
- name: phpize
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: "Build Windows Package"
2+
run-name: "Build Windows Package for ${{ inputs.ref }} (PHP ${{ inputs.php }} ${{ inputs.arch }} ${{ inputs.ts }})"
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
version:
8+
description: "The version being built"
9+
type: string
10+
required: true
11+
ref:
12+
description: "The git reference to build"
13+
type: string
14+
required: true
15+
php:
16+
description: "The PHP version to build for"
17+
type: string
18+
required: true
19+
arch:
20+
description: "The architecture to build for (x64 or x86)"
21+
type: string
22+
required: true
23+
ts:
24+
description: "Thread safety (ts or nts)"
25+
type: string
26+
required: true
27+
upload_release_asset:
28+
description: "Whether to upload a release asset"
29+
type: boolean
30+
default: false
31+
32+
jobs:
33+
build:
34+
name: "Build DLL"
35+
# windows-latest is required to use enableCrossOsArchive with Ubuntu in the
36+
# next step. See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache
37+
runs-on: windows-latest
38+
defaults:
39+
run:
40+
shell: cmd
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
with:
45+
submodules: true
46+
ref: ${{ inputs.ref }}
47+
48+
- name: "Build Driver"
49+
id: build-driver
50+
uses: ./.github/actions/windows/build
51+
with:
52+
version: ${{ inputs.php }}
53+
arch: ${{ inputs.arch }}
54+
ts: ${{ inputs.ts }}
55+
56+
- name: "Copy DLL and PDB files to CWD"
57+
run: |
58+
cp %BUILD_DIR%\php_mongodb.dll .
59+
cp %BUILD_DIR%\php_mongodb.pdb .
60+
env:
61+
BUILD_DIR: ${{ steps.build-driver.outputs.build-dir }}
62+
63+
- name: "Cache build artifacts for subsequent builds"
64+
uses: actions/cache/save@v4
65+
with:
66+
key: ${{ github.sha }}-${{ inputs.php }}-${{ inputs.ts }}-${{ inputs.arch }}
67+
enableCrossOsArchive: true
68+
path: |
69+
php_mongodb.dll
70+
php_mongodb.pdb
71+
72+
sign-and-package:
73+
environment: release
74+
name: "Sign and create package"
75+
needs: build
76+
# ubuntu-latest is required to use enableCrossOsArchive
77+
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache
78+
runs-on: "ubuntu-latest"
79+
permissions:
80+
id-token: write
81+
82+
steps:
83+
- name: "Generate token and checkout repository"
84+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
85+
with:
86+
app_id: ${{ vars.APP_ID }}
87+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
88+
ref: ${{ inputs.ref }}
89+
90+
- name: "Set up drivers-github-tools"
91+
uses: mongodb-labs/drivers-github-tools/setup@v2
92+
with:
93+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
94+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
95+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
96+
97+
- name: Restore cached build artifacts
98+
id: cache-build-artifacts
99+
uses: actions/cache/restore@v4
100+
with:
101+
fail-on-cache-miss: true
102+
key: ${{ github.sha }}-${{ inputs.php }}-${{ inputs.ts }}-${{ inputs.arch }}
103+
enableCrossOsArchive: true
104+
path: |
105+
php_mongodb.dll
106+
php_mongodb.pdb
107+
108+
- name: "Create detached DLL signature"
109+
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
110+
with:
111+
filenames: php_mongodb.dll
112+
113+
# Copy the signature file from the release asset directory to avoid directory issues in the ZIP file
114+
- name: "Copy signature file"
115+
run: cp ${RELEASE_ASSETS}/php_mongodb.dll.sig .
116+
117+
- name: "Create and upload release asset"
118+
if: ${{ inputs.upload_release_asset }}
119+
run: |
120+
ARCHIVE=php_mongodb-${{ inputs.version }}-${{ inputs.php }}-${{ inputs.ts }}-${{ inputs.arch }}.zip
121+
zip ${ARCHIVE} php_mongodb.dll php_mongodb.dll.sig php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES
122+
gh release upload ${{ inputs.version }} ${ARCHIVE}

.github/workflows/commit-and-tag.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/package-release.yml

Lines changed: 35 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
name: "Package Release"
2-
run-name: "Package Release ${{ github.ref_name }}"
2+
run-name: "Package Release ${{ inputs.version }}"
33

44
on:
5-
push:
6-
tags:
7-
- "*"
5+
workflow_call:
6+
inputs:
7+
version:
8+
description: "The version being built"
9+
type: string
10+
required: true
11+
ref:
12+
description: "The git reference to build"
13+
type: string
14+
required: true
815

916
jobs:
1017
build-pecl:
@@ -13,25 +20,15 @@ jobs:
1320
runs-on: "ubuntu-latest"
1421
permissions:
1522
id-token: write
23+
contents: write
1624

1725
steps:
18-
- name: "Create temporary app token"
19-
uses: actions/create-github-app-token@v1
20-
id: app-token
26+
- name: "Generate token and checkout repository"
27+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
2128
with:
22-
app-id: ${{ vars.APP_ID }}
23-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
24-
25-
- name: "Store GitHub token in environment"
26-
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
27-
shell: bash
28-
29-
- name: "Checkout"
30-
uses: "actions/checkout@v4"
31-
with:
32-
# Manually specify a ref. When actions/checkout is run for a tag without a ref, it looks up the underlying
33-
# commit and specifically fetches this to the refs/tags/<tag> ref, which denies us access to the tag message
34-
ref: ${{ github.ref }}
29+
app_id: ${{ vars.APP_ID }}
30+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
31+
ref: ${{ inputs.ref }}
3532
submodules: true
3633

3734
- name: "Set up drivers-github-tools"
@@ -47,7 +44,13 @@ jobs:
4744
version: "8.3"
4845

4946
- name: "Write changelog file for packaging"
50-
run: git tag -l ${{ github.ref_name }} --format='%(contents)' > changelog
47+
run: |
48+
gh api \
49+
--method POST \
50+
-H "Accept: application/vnd.github+json" \
51+
-H "X-GitHub-Api-Version: 2022-11-28" \
52+
/repos/${{ github.repository }}/releases/generate-notes \
53+
-f "tag_name=${{ inputs.version }}" --jq '.body' > changelog
5154
5255
# This will fill in the release notes from the previously generated changelog
5356
- name: "Build package.xml"
@@ -77,142 +80,24 @@ jobs:
7780
- name: "Copy signature file"
7881
run: cp ${RELEASE_ASSETS}/${{ env.PACKAGE_FILE }}.sig .
7982

80-
- name: "Upload artifacts"
81-
uses: actions/upload-artifact@v4
82-
with:
83-
name: ${{ env.PACKAGE_FILE }}
84-
path: |
85-
${{ env.PACKAGE_FILE }}
86-
${{ env.PACKAGE_FILE }}.sig
87-
retention-days: 3
88-
8983
- name: "Upload release artifacts"
90-
run: gh release upload ${{ github.ref_name }} ${{ env.PACKAGE_FILE }} ${{ env.PACKAGE_FILE }}.sig
91-
continue-on-error: true
84+
run: gh release upload ${{ inputs.version }} ${{ env.PACKAGE_FILE }} ${{ env.PACKAGE_FILE }}.sig
9285

9386
build-windows:
94-
name: "Create Windows package"
95-
# windows-latest is required to use enableCrossOsArchive with Ubuntu in the
96-
# next step. See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache
97-
runs-on: windows-latest
98-
defaults:
99-
run:
100-
shell: cmd
101-
87+
name: "Create Windows packages"
88+
uses: ./.github/workflows/build-windows-package.yml
89+
with:
90+
version: ${{ inputs.version }}
91+
ref: refs/tags/${{ inputs.version }}
92+
php: ${{ matrix.php }}
93+
arch: ${{ matrix.arch }}
94+
ts: ${{ matrix.ts }}
95+
upload_release_asset: true
96+
secrets: inherit
10297
strategy:
10398
fail-fast: false
10499
matrix:
105100
# Note: keep this in sync with the Windows matrix in windows-tests.yml
106101
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
107102
arch: [ x64, x86 ]
108103
ts: [ ts, nts ]
109-
110-
steps:
111-
- uses: actions/checkout@v4
112-
with:
113-
submodules: true
114-
115-
- name: "Build Driver"
116-
id: build-driver
117-
uses: ./.github/actions/windows/build
118-
with:
119-
version: ${{ matrix.php }}
120-
arch: ${{ matrix.arch }}
121-
ts: ${{ matrix.ts }}
122-
123-
- name: "Copy DLL and PDB files to CWD"
124-
run: |
125-
cp %BUILD_DIR%\php_mongodb.dll .
126-
cp %BUILD_DIR%\php_mongodb.pdb .
127-
env:
128-
BUILD_DIR: ${{ steps.build-driver.outputs.build-dir }}
129-
130-
- name: "Cache build artifacts for subsequent builds"
131-
uses: actions/cache/save@v4
132-
with:
133-
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
134-
enableCrossOsArchive: true
135-
path: |
136-
php_mongodb.dll
137-
php_mongodb.pdb
138-
139-
sign-and-publish-windows:
140-
environment: release
141-
name: "Sign and Publish Windows package"
142-
needs: [build-windows]
143-
# ubuntu-latest is required to use enableCrossOsArchive
144-
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache
145-
runs-on: "ubuntu-latest"
146-
permissions:
147-
id-token: write
148-
149-
strategy:
150-
fail-fast: false
151-
matrix:
152-
# Note: keep this in sync with the Windows matrix in windows-tests.yml
153-
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
154-
arch: [ x64, x86 ]
155-
ts: [ ts, nts ]
156-
157-
steps:
158-
- name: "Create temporary app token"
159-
uses: actions/create-github-app-token@v1
160-
id: app-token
161-
with:
162-
app-id: ${{ vars.APP_ID }}
163-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
164-
165-
- name: "Store GitHub token in environment"
166-
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
167-
shell: bash
168-
169-
- uses: actions/checkout@v4
170-
171-
- name: "Set up drivers-github-tools"
172-
uses: mongodb-labs/drivers-github-tools/setup@v2
173-
with:
174-
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
175-
aws_region_name: ${{ vars.AWS_REGION_NAME }}
176-
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
177-
178-
- name: Restore cached build artifacts
179-
id: cache-build-artifacts
180-
uses: actions/cache/restore@v4
181-
with:
182-
fail-on-cache-miss: true
183-
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
184-
enableCrossOsArchive: true
185-
path: |
186-
php_mongodb.dll
187-
php_mongodb.pdb
188-
189-
- name: "Create detached DLL signature"
190-
uses: mongodb-labs/drivers-github-tools/gpg-sign@v2
191-
with:
192-
filenames: php_mongodb.dll
193-
194-
# Copy the signature file from the release asset directory to avoid directory issues in the ZIP file
195-
- name: "Copy signature file"
196-
run: cp ${RELEASE_ASSETS}/php_mongodb.dll.sig .
197-
198-
- name: "Upload DLL and PDB files as build artifacts"
199-
uses: actions/upload-artifact@v4
200-
with:
201-
name: php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
202-
path: |
203-
php_mongodb.dll
204-
php_mongodb.dll.sig
205-
php_mongodb.pdb
206-
CREDITS
207-
CONTRIBUTING.md
208-
LICENSE
209-
README.md
210-
THIRD_PARTY_NOTICES
211-
retention-days: 3
212-
213-
- name: "Create and upload release artifact"
214-
run: |
215-
ARCHIVE=php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}.zip
216-
zip ${ARCHIVE} php_mongodb.dll php_mongodb.dll.sig php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES
217-
gh release upload ${{ github.ref_name }} ${ARCHIVE}
218-
continue-on-error: true

0 commit comments

Comments
 (0)