Skip to content

Commit f506042

Browse files
committed
Add support for building the online flavor of the installer
1 parent 7617e48 commit f506042

File tree

2 files changed

+102
-7
lines changed

2 files changed

+102
-7
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ on:
145145
required: true
146146
PASSPHRASE:
147147
required: true
148-
148+
R2_ACCOUNT_ID:
149+
required: true
150+
R2_ACCESS_KEY_ID:
151+
required: true
152+
R2_SECRET_ACCESS_KEY:
153+
required: true
149154

150155
jobs:
151156
context:
@@ -871,6 +876,9 @@ jobs:
871876
SYMBOL_SERVER_PAT: ${{ secrets.SYMBOL_SERVER_PAT }}
872877
CERTIFICATE: ${{ secrets.CERTIFICATE }}
873878
PASSPHRASE: ${{ secrets.PASSPHRASE }}
879+
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
880+
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
881+
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
874882

875883
mac-build:
876884
# TODO: Enable the mac build.
@@ -955,6 +963,9 @@ jobs:
955963
SYMBOL_SERVER_PAT: ${{ secrets.SYMBOL_SERVER_PAT }}
956964
CERTIFICATE: ${{ secrets.CERTIFICATE }}
957965
PASSPHRASE: ${{ secrets.PASSPHRASE }}
966+
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
967+
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
968+
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
958969

959970
snapshot:
960971
runs-on: ubuntu-latest
@@ -998,6 +1009,7 @@ jobs:
9981009
env:
9991010
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10001011
run: |
1012+
# TODO: Upload the offline installer as well.
10011013
branch_version_string=${{ inputs.swift_version || '0.0.0' }}
10021014
if [[ $branch_version_string == "0.0.0" ]]; then
10031015
latest="true"

.github/workflows/swift-toolchain.yml

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ on:
283283
required: true
284284
PASSPHRASE:
285285
required: true
286+
R2_ACCOUNT_ID:
287+
required: true
288+
R2_ACCESS_KEY_ID:
289+
required: true
290+
R2_SECRET_ACCESS_KEY:
291+
required: true
286292

287293
env:
288294
PINNED_BOOTSTRAP_TOOLCHAIN_VERSION: 6.1.2
@@ -2169,7 +2175,7 @@ jobs:
21692175
run: |
21702176
cd ${{ github.workspace }}/SourceCache/swift/Runtimes
21712177
cmake -P Resync.cmake
2172-
2178+
21732179
- name: Configure Dispatch (C parts only)
21742180
if: matrix.os != 'Android' || inputs.build_android
21752181
uses: ./SourceCache/ci-build/.github/actions/configure-cmake-project
@@ -5068,7 +5074,7 @@ jobs:
50685074
-p:ProductVersion=${{ inputs.swift_version }}-${{ inputs.swift_tag }} `
50695075
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/shared/shared.wixproj
50705076
5071-
- name: Build installer bundle
5077+
- name: Build installer bundle (offline)
50725078
run: |
50735079
$Platforms=@("windows")
50745080
if ("${{ inputs.build_android }}" -eq "true") {
@@ -5091,16 +5097,93 @@ jobs:
50915097
-p:ToolchainVariants="`"asserts;noasserts`"" `
50925098
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bundle/installer.wixproj
50935099
5094-
- if: ${{ inputs.release }}
5100+
- name: Generate Build Provenance (offline installer)
5101+
if: ${{ inputs.release }}
50955102
uses: actions/attest-build-provenance@v2
50965103
with:
50975104
subject-path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
50985105

5099-
- uses: actions/upload-artifact@v4
5106+
- name: Upload installer (offline)
5107+
uses: actions/upload-artifact@v4
5108+
with:
5109+
name: Windows-${{ matrix.arch }}-installer-offline
5110+
path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
5111+
5112+
- name: Generate online installer download URL
5113+
if: ${{ inputs.release }}
5114+
id: generate-base-release-download-prefix
5115+
run: |
5116+
$BaseReleaseDownloadUrlPrefix = "${{ inputs.swift_tag }}/${{ matrix.arch }}/${{ github.run_id }}"
5117+
echo "url_prefix=$BaseReleaseDownloadUrlPrefix" >> $env:GITHUB_OUTPUT
5118+
5119+
- name: Build installer bundle (online)
5120+
if: ${{ inputs.release }}
5121+
run: |
5122+
$Platforms=@("windows")
5123+
if ("${{ inputs.build_android }}" -eq "true") {
5124+
$Platforms=@("android") + $Platforms
5125+
}
5126+
$BaseReleaseDownloadUrl = "https://pub-3a06d9ae9ab6469198a3cf59c7d6bdce.r2.dev/${{ steps.generate-base-release-download-prefix.outputs.url_prefix }}"
5127+
5128+
msbuild -nologo -restore -maxCpuCount `
5129+
/t:rebuild `
5130+
-p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ `
5131+
-p:Configuration=Release `
5132+
-p:BuildProjectReferences=false `
5133+
-p:SignOutput=${{ inputs.signed }} `
5134+
-p:CERTIFICATE=${env:CERTIFICATE} `
5135+
-p:PASSPHRASE=${{ secrets.PASSPHRASE }} `
5136+
-p:BundleFlavor=online `
5137+
-p:BaseReleaseDownloadUrl=`"$BaseReleaseDownloadUrl`" `
5138+
-p:Platforms="`"$($Platforms -Join ';')`"" `
5139+
-p:AndroidArchitectures="`"aarch64;armv7;i686;x86_64`"" `
5140+
-p:WindowsArchitectures="`"aarch64;i686;x86_64`"" `
5141+
-p:ProductArchitecture=${{ matrix.arch }} `
5142+
-p:ProductVersion=${{ inputs.swift_version }}-${{ inputs.swift_tag }} `
5143+
-p:ToolchainVariants="`"asserts;noasserts`"" `
5144+
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bundle/installer.wixproj
5145+
5146+
- name: Prepare layout for upload
5147+
id: prepare-layout
5148+
if: ${{ inputs.release }}
5149+
run: |
5150+
# Create the target folder.
5151+
$SourceDir = "${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}"
5152+
$LayoutDir = "${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/layout"
5153+
New-Item -ItemType Directory -Path $LayoutDir -Force | Out-Null
5154+
5155+
# Copy all .txt files from src to the filtered directory
5156+
Copy-Item -Path "$SourceDir/installer.exe" -Destination "$LayoutDir" -Force
5157+
Copy-Item -Path "$SourceDir/*.cab" -Destination "$LayoutDir" -Force
5158+
Copy-Item -Path "$SourceDir/*.msi" -Destination "$LayoutDir" -Force
5159+
5160+
echo "LayoutDir=$LayoutDir"
5161+
echo "LayoutDir=$LayoutDir" >> $env:GITHUB_OUTPUT
5162+
5163+
- name: Generate Build Provenance (online installer)
5164+
if: ${{ inputs.release }}
5165+
uses: actions/attest-build-provenance@v2
5166+
with:
5167+
subject-path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
5168+
5169+
- name: Upload installer (online)
5170+
if: ${{ inputs.release }}
5171+
uses: actions/upload-artifact@v4
51005172
with:
51015173
name: Windows-${{ matrix.arch }}-installer
51025174
path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
51035175

5176+
- name: Upload msi's and cab's
5177+
if: ${{ inputs.release }}
5178+
uses: ryand56/r2-upload-action@b801a390acbdeb034c5e684ff5e1361c06639e7c # v1.4
5179+
with:
5180+
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
5181+
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
5182+
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
5183+
r2-bucket: swift-toolchain
5184+
source-dir: ${{ steps.prepare-layout.outputs.LayoutDir }}
5185+
destination-dir: ${{ steps.generate-base-release-download-prefix.outputs.url_prefix }}
5186+
51045187
smoke_test:
51055188
# TODO: Build this on macOS or make an equivalent Mac-only job
51065189
if: inputs.build_os == 'Windows'
@@ -5110,7 +5193,7 @@ jobs:
51105193
steps:
51115194
- uses: actions/download-artifact@v4
51125195
with:
5113-
name: Windows-${{ inputs.build_arch }}-installer
5196+
name: Windows-${{ inputs.build_arch }}-installer-offline
51145197
path: ${{ github.workspace }}/tmp
51155198

51165199
# TODO(compnerd): migrate this to compnerd/gha-setup-swift after the work that @mangini is doing is completed
@@ -5175,7 +5258,7 @@ jobs:
51755258
- name: Download Swift SDK
51765259
uses: actions/download-artifact@v4
51775260
with:
5178-
name: Windows-${{ inputs.build_arch }}-installer
5261+
name: Windows-${{ inputs.build_arch }}-installer-offline
51795262
path: ${{ github.workspace }}/tmp
51805263

51815264
# TODO(compnerd): migrate this to compnerd/gha-setup-swift after the work that @mangini is doing is completed

0 commit comments

Comments
 (0)