Skip to content

Commit 5f4d1be

Browse files
Add s3 upload of Patch for automatic updates and polish
* Fix patch version number and filename * Trigger base build on chron job or manual (not on each push)
1 parent 42b889e commit 5f4d1be

2 files changed

Lines changed: 65 additions & 11 deletions

File tree

.github/workflows/base-installer-cd.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Base Installer
22
on:
3-
push:
4-
branches: ["release/9.3", "feature/gha-cd"]
3+
schedule:
4+
# Runs every day at 02:30 UTC (which is 6:30pm PST / 7:30pm PDT)
5+
- cron: "30 2 * * *"
56
workflow_dispatch:
67
inputs:
78
fw_ref:
@@ -42,15 +43,13 @@ jobs:
4243
name: Build Debug and run Tests
4344
runs-on: windows-latest
4445
steps:
45-
- name: Compute build number for archival
46+
- name: Compute build number
4647
id: build_number
4748
run: |
4849
$lastJenkins = 1097 # The last base build from jenkins
4950
$githubRun = $env:GITHUB_RUN_NUMBER
5051
$combined = $lastJenkins + $githubRun
51-
echo "Last Jenkins build: $lastJenkins"
52-
echo "GitHub run number: $githubRun"
53-
echo "Combined build number: $combined"
52+
echo "Calculated build number: $combined"
5453
echo "RELEASE_BASE_BUILD_NUMBER=$combined" >> $env:GITHUB_ENV
5554
5655
- name: Checkout Files

.github/workflows/patch-installer-cd.yml

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ on:
2424
description: 'Commit-ish for liblcm repository'
2525
required: false
2626
default: 'master'
27+
# default should be changed to the most recent base release for the release cycle
2728
base_release:
2829
description: 'The github release for the base build artifacts'
2930
default: 'FieldWorks9.3.0'
31+
base_build_number:
32+
description: 'The base build number (only for bootstrapping, should be removed after 9.3 is the stable)'
33+
required: false
34+
default: ''
3035
make_release:
31-
description: 'Should the build archive a release, false by default, should be set to true on a release build.'
36+
description: 'Should the release be pushed to s3 - use false for test builds'
3237
required: false
3338
default: 'true'
3439

@@ -54,10 +59,8 @@ jobs:
5459
$lastJenkins = 1976 # The last patch build from jenkins
5560
$githubRun = $env:GITHUB_RUN_NUMBER
5661
$combined = $lastJenkins + $githubRun
57-
echo "Last Jenkins build: $lastJenkins"
58-
echo "GitHub run number: $githubRun"
59-
echo "Combined build number: $combined"
60-
echo "RELEASE_BASE_BUILD_NUMBER=$combined" >> $env:GITHUB_ENV
62+
echo "Calculated build number: $combined"
63+
echo "BuildVersionSegment=$combined" >> $env:GITHUB_ENV
6164
6265
- name: Checkout Files
6366
uses: actions/checkout@v4
@@ -213,6 +216,7 @@ jobs:
213216
Write-Host "No errors found" -ForegroundColor green
214217
exit 0
215218
}
219+
216220
- name: Find patch installer
217221
id: find_patch
218222
shell: pwsh
@@ -233,6 +237,57 @@ jobs:
233237
description: 'FieldWorks Patch Installer'
234238
description-url: 'https://software.sil.org/fieldworks/'
235239

240+
- name: Configure AWS credentials
241+
if: ${{ inputs.make_release == 'true' }}
242+
uses: aws-actions/configure-aws-credentials@v4
243+
with:
244+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
245+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
246+
aws-region: us-east-1
247+
248+
- name: Upload Patch to S3
249+
if: ${{ inputs.make_release == 'true' }}
250+
shell: pwsh
251+
env:
252+
BASE_RELEASE: ${{ inputs.base_release }}
253+
BASE_BUILD_NUMBER: ${{ inputs.base_build_number }}
254+
BUILD_VERSION_SEGMENT: ${{ env.BuildVersionSegment }}
255+
run: |
256+
# --- Decide baseBuildNumber (_b###) ---
257+
if ($env:BASE_BUILD_NUMBER -and $env:BASE_BUILD_NUMBER.Trim() -ne "") {
258+
$baseBuildNumber = "_b$($env:BASE_BUILD_NUMBER)"
259+
} elseif ($env:BASE_RELEASE -and $env:BASE_RELEASE.Trim() -ne "") {
260+
if ($env:BASE_RELEASE -notmatch '^build-\d+$') {
261+
throw "BASE_RELEASE must start with 'build-' (got '$env:BASE_RELEASE')"
262+
}
263+
$baseBuildNumber = "_b$($env:BASE_RELEASE -replace '^build-','')"
264+
} else {
265+
throw "Must have a base_build_number nor a valid base_release to support automatic updating"
266+
}
267+
268+
# --- Locate patch file ---
269+
$patchPath = "${{ steps.find_patch.outputs.patch_file }}"
270+
if (-not (Test-Path $patchPath)) {
271+
throw "Patch file not found at $patchPath"
272+
}
273+
274+
$patchFile = Split-Path $patchPath -Leaf
275+
$patchDir = Split-Path $patchPath -Parent
276+
277+
# --- Insert baseBuildNumber before _x64.msp necessary for Automatic Update code Src\Common\FwUtils\FwUpdater.cs---
278+
if ($patchFile -notmatch '^(.*)(_x64\.msp)$') {
279+
throw "Unexpected patch filename format: $patchFile"
280+
}
281+
$patchWithBaseInName = "$($Matches[1])${baseBuildNumber}$($Matches[2])"
282+
283+
Write-Host "Renaming $patchFile -> $patchWithBaseInName"
284+
285+
# --- Upload to S3 ---
286+
$s3Key = "flex-updates/jobs/FieldWorks-Win-all-Release-Patch/$($env:BUILD_VERSION_SEGMENT)/$patchWithBaseInName"
287+
aws s3 cp $patchPath "s3://flex-updates/$s3Key"
288+
289+
Write-Host "Uploaded to s3://flex-updates/$s3Key"
290+
236291
- name: Upload Build Logs
237292
uses: actions/upload-artifact@v4
238293
if: always()

0 commit comments

Comments
 (0)