Skip to content

Commit 8a02a7e

Browse files
authored
Build online installer (#1023)
* Build shared experimental sdk for x86 config * Remove wrong path * Add support for building the online flavor of the installer * Do not use quotes * if: matrix.os != 'Android' || inputs.build_android * Upload offline installer to release * Use the release domain name * Switch to using S3 to upload * Change variable name
1 parent 288c97e commit 8a02a7e

File tree

2 files changed

+140
-30
lines changed

2 files changed

+140
-30
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 43 additions & 22 deletions
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:
@@ -618,6 +623,9 @@ jobs:
618623
SYMBOL_SERVER_PAT: ${{ secrets.SYMBOL_SERVER_PAT }}
619624
CERTIFICATE: ${{ secrets.CERTIFICATE }}
620625
PASSPHRASE: ${{ secrets.PASSPHRASE }}
626+
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
627+
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
628+
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
621629

622630
mac-build:
623631
# TODO: Enable the mac build.
@@ -693,6 +701,9 @@ jobs:
693701
SYMBOL_SERVER_PAT: ${{ secrets.SYMBOL_SERVER_PAT }}
694702
CERTIFICATE: ${{ secrets.CERTIFICATE }}
695703
PASSPHRASE: ${{ secrets.PASSPHRASE }}
704+
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
705+
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
706+
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
696707

697708
snapshot:
698709
runs-on: ubuntu-latest
@@ -724,41 +735,51 @@ jobs:
724735
steps:
725736
- uses: actions/download-artifact@v4
726737
with:
727-
name: Windows-amd64-installer
728-
path: ${{ github.workspace }}/tmp/amd64
738+
name: Windows-amd64-installer-online
739+
path: ${{ github.workspace }}/tmp/online/amd64
729740

730741
- uses: actions/download-artifact@v4
731742
with:
732-
name: Windows-arm64-installer
733-
path: ${{ github.workspace }}/tmp/arm64
743+
name: Windows-arm64-installer-online
744+
path: ${{ github.workspace }}/tmp/online/arm64
745+
746+
- uses: actions/download-artifact@v4
747+
with:
748+
name: Windows-amd64-installer-offline
749+
path: ${{ github.workspace }}/tmp/offline/amd64
734750

751+
- uses: actions/download-artifact@v4
752+
with:
753+
name: Windows-arm64-installer-offline
754+
path: ${{ github.workspace }}/tmp/offline/arm64
755+
735756
- name: Create Release
736757
env:
737758
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
738759
run: |
760+
function upload_installer() {
761+
local input_file=$1
762+
local output_name=$2
763+
764+
mv "${input_file}" "${output_name}"
765+
gh release upload ${{ needs.context.outputs.swift_tag }} "${output_name}" -R ${{ github.repository }}
766+
767+
shasum -a 256 "${output_name}" > "${output_name}.sha256"
768+
gh release upload ${{ needs.context.outputs.swift_tag }} "${output_name}.sha256" -R ${{ github.repository }}
769+
}
770+
739771
branch_version_string=${{ inputs.swift_version || '0.0.0' }}
740772
if [[ $branch_version_string == "0.0.0" ]]; then
741773
latest="true"
742774
else
743775
latest="false"
744776
fi
777+
745778
# Create Release
746779
gh release create ${{ needs.context.outputs.swift_tag }} -R ${{ github.repository }} --latest=${latest}
747780
748-
# AMD64
749-
cd ${{ github.workspace }}/tmp/amd64
750-
751-
mv installer.exe installer-amd64.exe
752-
gh release upload ${{ needs.context.outputs.swift_tag }} installer-amd64.exe -R ${{ github.repository }}
753-
754-
shasum -a 256 installer-amd64.exe > installer-amd64.exe.sha256
755-
gh release upload ${{ needs.context.outputs.swift_tag }} installer-amd64.exe.sha256 -R ${{ github.repository }}
756-
757-
# ARM64
758-
cd ${{ github.workspace }}/tmp/arm64
759-
760-
mv installer.exe installer-arm64.exe
761-
gh release upload ${{ needs.context.outputs.swift_tag }} installer-arm64.exe -R ${{ github.repository }}
762-
763-
shasum -a 256 installer-arm64.exe > installer-arm64.exe.sha256
764-
gh release upload ${{ needs.context.outputs.swift_tag }} installer-arm64.exe.sha256 -R ${{ github.repository }}
781+
# Upload all installer variants
782+
upload_installer "${{ github.workspace }}/tmp/online/amd64/installer.exe" "installer-amd64.exe"
783+
upload_installer "${{ github.workspace }}/tmp/online/arm64/installer.exe" "installer-arm64.exe"
784+
upload_installer "${{ github.workspace }}/tmp/offline/amd64/installer.exe" "installer-offline-amd64.exe"
785+
upload_installer "${{ github.workspace }}/tmp/offline/arm64/installer.exe" "installer-offline-arm64.exe"

.github/workflows/swift-toolchain.yml

Lines changed: 97 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ on:
247247
required: true
248248
PASSPHRASE:
249249
required: true
250+
R2_ACCOUNT_ID:
251+
required: true
252+
R2_ACCESS_KEY_ID:
253+
required: true
254+
R2_SECRET_ACCESS_KEY:
255+
required: true
250256

251257
env:
252258
PINNED_BOOTSTRAP_TOOLCHAIN_VERSION: 6.1.2
@@ -5032,7 +5038,7 @@ jobs:
50325038
-p:ProductVersion=${{ inputs.swift_version }}-${{ inputs.swift_tag }} `
50335039
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/shared/shared.wixproj
50345040
5035-
- name: Build installer bundle
5041+
- name: Build installer bundle (offline)
50365042
run: |
50375043
$Platforms=@("windows")
50385044
if ("${{ inputs.build_android }}" -eq "true") {
@@ -5055,26 +5061,109 @@ jobs:
50555061
-p:ToolchainVariants="`"asserts;noasserts`"" `
50565062
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bundle/installer.wixproj
50575063
5058-
- if: ${{ inputs.release }}
5064+
- name: Generate Build Provenance (offline installer)
5065+
if: ${{ inputs.release }}
50595066
uses: actions/attest-build-provenance@v2
50605067
with:
50615068
subject-path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
50625069

5063-
- uses: actions/upload-artifact@v4
5070+
- name: Upload installer (offline)
5071+
uses: actions/upload-artifact@v4
5072+
with:
5073+
name: Windows-${{ matrix.arch }}-installer-offline
5074+
path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
5075+
5076+
- name: Generate online installer download URL
5077+
if: ${{ inputs.release }}
5078+
id: generate-base-release-download-subcomponent
5079+
run: |
5080+
$BaseReleaseDownloadUrlSubcomponent = "${{ inputs.swift_tag }}/${{ matrix.arch }}/${{ github.run_id }}"
5081+
echo "url_subcomponent=$BaseReleaseDownloadUrlSubcomponent" >> $env:GITHUB_OUTPUT
5082+
5083+
- name: Build installer bundle (online)
5084+
if: ${{ inputs.release }}
5085+
run: |
5086+
$Platforms=@("windows")
5087+
if ("${{ inputs.build_android }}" -eq "true") {
5088+
$Platforms=@("android") + $Platforms
5089+
}
5090+
$BaseReleaseDownloadUrl = "https://swift-toolchain.thebrowserco.com/${{ steps.generate-base-release-download-subcomponent.outputs.url_subcomponent }}"
5091+
5092+
msbuild -nologo -restore -maxCpuCount `
5093+
/t:rebuild `
5094+
-p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ `
5095+
-p:Configuration=Release `
5096+
-p:BuildProjectReferences=false `
5097+
-p:SignOutput=${{ inputs.signed }} `
5098+
-p:CERTIFICATE=${env:CERTIFICATE} `
5099+
-p:PASSPHRASE=${{ secrets.PASSPHRASE }} `
5100+
-p:BundleFlavor=online `
5101+
-p:BaseReleaseDownloadUrl=$BaseReleaseDownloadUrl `
5102+
-p:Platforms="`"$($Platforms -Join ';')`"" `
5103+
-p:AndroidArchitectures="`"aarch64;armv7;i686;x86_64`"" `
5104+
-p:WindowsArchitectures="`"aarch64;i686;x86_64`"" `
5105+
-p:ProductArchitecture=${{ matrix.arch }} `
5106+
-p:ProductVersion=${{ inputs.swift_version }}-${{ inputs.swift_tag }} `
5107+
-p:ToolchainVariants="`"asserts;noasserts`"" `
5108+
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bundle/installer.wixproj
5109+
5110+
- name: Prepare layout for upload
5111+
id: prepare-layout
5112+
if: ${{ inputs.release }}
5113+
run: |
5114+
# Create the target folder.
5115+
$SourceDir = "${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}"
5116+
$LayoutDir = "${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/layout"
5117+
New-Item -ItemType Directory -Path $LayoutDir -Force | Out-Null
5118+
5119+
# Copy all .txt files from src to the filtered directory
5120+
Copy-Item -Path "$SourceDir/installer.exe" -Destination "$LayoutDir" -Force
5121+
Copy-Item -Path "$SourceDir/*.cab" -Destination "$LayoutDir" -Force
5122+
Copy-Item -Path "$SourceDir/*.msi" -Destination "$LayoutDir" -Force
5123+
5124+
echo "LayoutDir=$LayoutDir"
5125+
echo "LayoutDir=$LayoutDir" >> $env:GITHUB_OUTPUT
5126+
5127+
- name: Generate Build Provenance (online installer)
5128+
if: ${{ inputs.release }}
5129+
uses: actions/attest-build-provenance@v2
50645130
with:
5065-
name: Windows-${{ matrix.arch }}-installer
5131+
subject-path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
5132+
5133+
- name: Upload installer (online)
5134+
if: ${{ inputs.release }}
5135+
uses: actions/upload-artifact@v4
5136+
with:
5137+
name: Windows-${{ matrix.arch }}-installer-online
50665138
path: ${{ github.workspace }}/BinaryCache/installer/Release/${{ matrix.arch }}/installer.exe
50675139

5140+
- name: Upload msi's and cab's
5141+
if: ${{ inputs.release }}
5142+
env:
5143+
SOURCE_DIR: ${{ steps.prepare-layout.outputs.LayoutDir }}
5144+
DESTINATION_PREFIX: ${{ steps.generate-base-release-download-subcomponent.outputs.url_subcomponent }}
5145+
R2_BUCKET: swift-toolchain
5146+
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
5147+
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
5148+
AWS_DEFAULT_REGION: auto
5149+
R2_ENDPOINT_URL: https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com
5150+
run: |
5151+
aws s3 sync "${env:SOURCE_DIR}" "s3://${env:R2_BUCKET}/${env:DESTINATION_PREFIX}/" `
5152+
--endpoint-url "${env:R2_ENDPOINT_URL}" `
5153+
--no-progress `
5154+
--acl private
5155+
50685156
smoke_test:
50695157
# TODO: Build this on macOS or make an equivalent Mac-only job
50705158
if: inputs.build_os == 'Windows'
50715159
needs: [installer]
50725160
runs-on: ${{ inputs.default_build_runner }}
50735161

50745162
steps:
5075-
- uses: actions/download-artifact@v4
5163+
- name: Download Swift SDK Installer (${{ inputs.release && 'online' || 'offline' }})
5164+
uses: actions/download-artifact@v4
50765165
with:
5077-
name: Windows-${{ inputs.build_arch }}-installer
5166+
name: Windows-${{ inputs.build_arch }}-installer-${{ inputs.release && 'online' || 'offline' }}
50785167
path: ${{ github.workspace }}/tmp
50795168

50805169
# TODO(compnerd): migrate this to compnerd/gha-setup-swift after the work that @mangini is doing is completed
@@ -5136,10 +5225,10 @@ jobs:
51365225
arch: [ x86_64, aarch64 ]
51375226

51385227
steps:
5139-
- name: Download Swift SDK
5228+
- name: Download Swift SDK Installer (${{ inputs.release && 'online' || 'offline' }})
51405229
uses: actions/download-artifact@v4
51415230
with:
5142-
name: Windows-${{ inputs.build_arch }}-installer
5231+
name: Windows-${{ inputs.build_arch }}-installer-${{ inputs.release && 'online' || 'offline' }}
51435232
path: ${{ github.workspace }}/tmp
51445233

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

0 commit comments

Comments
 (0)