Skip to content

Commit

Permalink
ci: Auto build MSI github action (#625)
Browse files Browse the repository at this point in the history
Issue #, if available:

*Description of changes:*
Introduce a new github action to generate MSI automatically and upload
to S3

*Testing done:*
Tested the action:
https://github.com/runfinch/finch/actions/runs/6498553990/job/17650135643


- [X] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: [email protected] <[email protected]>
Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
2 people authored and vsiravar committed Oct 17, 2023
1 parent a000b29 commit bfba107
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 11 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/build-and-test-msi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Build, test and upload .msi to S3

# TODO: add scheduler and tests
on:
workflow_dispatch:
workflow_call:
inputs:
ref_name:
required: true
type: string
env:
GO111MODULE: on

permissions:
# This is required for configure-aws-credentials to request an OIDC JWT ID token to access AWS resources later on.
# More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
id-token: write
contents: read # This is required for actions/checkout

jobs:
get-tag-name:
name: Get tag name
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.check-tag.outputs.tag }}
steps:
- name: Check tag from workflow input and github ref
id: check-tag
run: |
if [ -n "${{ inputs.ref_name }}" ]; then
tag=${{ inputs.ref_name }}
else
tag=${{ github.ref_name }}
fi
echo "tag=$tag" >> ${GITHUB_OUTPUT}
windows-msi-build:
needs: get-tag-name
runs-on: [self-hosted, windows, amd64, release]
timeout-minutes: 100
steps:
- name: Configure git CRLF settings
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Set up Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: '3.x'
- name: Install AWS CLI
run: |
python -m pip install --upgrade pip
pip install awscli
- name: Validate aws CLI
run: |
aws --version
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
ref: ${{ needs.get-tag-name.outputs.tag }}
fetch-depth: 0
persist-credentials: false
submodules: recursive
- name: Set output variables
id: vars
run: |
$has_creds="${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}"
echo "has_creds=$has_creds" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
exit 0 # if $has_creds is false, powershell will exit with code 1 and this step will fail
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
with:
role-to-assume: ${{ secrets.ROLE }}
role-session-name: windows-msi
aws-region: ${{ secrets.REGION }}
- name: Remove Finch VM
run: |
wsl --list --verbose
wsl --shutdown
wsl --unregister lima-finch
wsl --list --verbose
- name: Clean up previous files
run: |
Remove-Item C:\Users\Administrator\.finch -Recurse -ErrorAction Ignore
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse -ErrorAction Ignore
make clean
cd deps/finch-core && make clean
- name: Build project
run: |
make FINCH_ROOTFS_LOCATION_ROOT=/__INSTALLFOLDER__
- name: generate msi
run: |
$version="${{ needs.get-tag-name.outputs.tag }}"
$version=$version.TrimStart("v")
if ($version -match '^[0-9]+\.[0-9]+\.[0-9]+$') {
Write-Host "Version matches format: $version"
}
else {
Write-Host "Version $version doesn't match format. Using default: 0.0.0"
$version="0.0.0"
}
powershell .\msi-builder\BuildFinchMSI.ps1 -Version $version
aws s3 cp "./msi-builder/build/Finch-$version.msi" "s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/Finch-$version.msi" --no-progress
13 changes: 6 additions & 7 deletions msi-builder/FinchMSITemplate.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Finch">
<Component Id="Component_Resource" Guid="36bd6135-0759-40c7-bef7-1c7fa0189a42" Win64="yes">
<Component Id="Component_Resource" Guid="{36BD6135-0759-40C7-BEF7-1C7FA0189A42}" Win64="yes">
<File Id="config_yaml" Source="__SOURCE__\config.yaml" />
<File Id="finch_ico" Source="__SOURCE__\finch.ico" />
<File Id="LICENSE_rtf" Source="__SOURCE__\LICENSE.rtf" />
<File Id="postinstall_bat" Source="__SOURCE__\postinstall.bat" />
<File Id="uninstall_bat" Source="__SOURCE__\uninstall.bat" />
</Component>
<Directory Id="bincecd86bf" Name="bin">
<Component Id="Component_Finch" Guid="c0ced166-84de-4bd8-96ab-45db96fb20cf" Win64="yes">
<Component Id="Component_Finch" Guid="{C0CED166-84DE-4BD8-96AB-45DB96FB20CF}" Win64="yes">
<File Id="dpgo_exe" Source="__SOURCE__\bin\dpgo.exe" />
<File Id="finch_exe" Source="__SOURCE__\bin\finch.exe" KeyPath="yes">
<Shortcut
Expand All @@ -39,32 +39,31 @@
</Directory>
<Directory Id="lima63339460" Name="lima">
<Directory Id="bineb6dcfb9" Name="bin">
<Component Id="Component_Lima" Guid="cfc5e6f4-feec-4470-b7b5-5f3e9a5e483c" Win64="yes">
<Component Id="Component_Lima" Guid="{CFC5E6F4-FEEC-4470-B7B5-5F3E9A5E483C}" Win64="yes">
<File Id="limactl_exe" Source="__SOURCE__\lima\bin\limactl.exe" />
</Component>
</Directory>
<Directory Id="data76b01c5f" Name="data">
<Directory Id="_configb09d75e9" Name="_config">
<Component Id="Component_Data" Guid="d76243e1-c60f-4a7b-b3b2-3b3ae295b77e" Win64="yes">
<Component Id="Component_Data" Guid="{D76243E1-C60F-4A7B-B3B2-3B3AE295B77E}" Win64="yes">
<File Id="networks_yaml" Source="__SOURCE__\lima\data\_config\networks.yaml" />
</Component>
</Directory>
</Directory>
<Directory Id="share49fac817" Name="share">
<Directory Id="lima314b6ebf" Name="lima">
<Component Id="Component_Share" Guid="6859323f-b11b-455b-8ac7-21eebe8e3f71" Win64="yes">
<Component Id="Component_Share" Guid="{6859323F-B11B-455B-8AC7-21EEBE8E3F71}" Win64="yes">
<File Id="lima_guestagent_Linux_x86_64" Source="__SOURCE__\lima\share\lima\lima-guestagent.Linux-x86_64" />
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="osfa5c59e6" Name="os">
<Component Id="Component_Roofts" Guid="1616c052-615c-4edb-aabf-db76176fe0ee" Win64="yes">
<Component Id="Component_Roofts" Guid="{1616C052-615C-4EDB-AABF-DB76176FE0EE}" Win64="yes">
<File Id="finch_rootfs_production_amd64_tar_gz" Source="__SOURCE__\os\__ROOTFS__" />
<File Id="finch_yaml" Source="__SOURCE__\os\finch.yaml" />
</Component>
</Directory>

</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" />
Expand Down
19 changes: 15 additions & 4 deletions msi-builder/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# FinchWindowsMSI
Finch Windows MSI Tool
Finch Windows MSI Tool to generate MSI installer from Finch build

Run the following command to generate the MSI installer:
`.\BuildFinchMSI.ps1 -SourcePath "<SourcePath, e.g., C:/Users/Administrator/Code/finch/_output/>" -Version <Version, e.g., 0.9.0>`
The Finch-<Version>.msi will be generated to the /build folder
## Instructions:
[1] Build finch: `make FINCH_ROOTFS_LOCATION_ROOT=/__INSTALLFOLDER__`
- It will inject the placeholder `__INSTALLFOLDER__` into `os\finch.yaml` for the rootfs location

[2] Run the following command to generate the MSI installer:
`.\BuildFinchMSI.ps1 -SourcePath "<SourcePath>" -Version <Version>`

**Parameters:**

- SourcePath: Refers to the finch build _output folder, e.g., C:\Users\<UserName>\Repo\finch\_output\. It's an optional parameter. If not provided, the default path is finch's _output folder. (You need to build finch before running the MSI tool).

- Version: A required parameter that should match the version format, e.g., 0.10.2.

[3] The Finch-<Version>.msi will be generated to the `msi-builder\build` folder

0 comments on commit bfba107

Please sign in to comment.