Skip to content

Commit 256b8c4

Browse files
authored
Merge pull request #12 from serbangeorge-m/add-windows-msi-installer
ci: add podman msi installer option
2 parents 15cb93f + 5a1fd94 commit 256b8c4

3 files changed

Lines changed: 57 additions & 11 deletions

File tree

.github/actions/fetch-latest-podman-version-windows/action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ inputs:
2727
required: false
2828
default: 'amd64'
2929
file_type:
30-
description: 'File type for Windows (setup.exe, installer.exe, remote.zip)'
30+
description: 'File type for Windows (setup.exe, installer.exe, remote.zip, msi)'
3131
required: false
32-
default: 'setup.exe'
32+
default: 'msi'
3333
github_token:
3434
description: 'GitHub token to make authenticated API requests'
3535
required: false
@@ -152,9 +152,12 @@ runs:
152152
"remote.zip")
153153
DOWNLOAD_URL="https://github.com/containers/podman/releases/download/${LATEST_VERSION}/podman-remote-release-windows_${ARCHITECTURE}.zip"
154154
;;
155+
"msi")
156+
DOWNLOAD_URL="https://github.com/containers/podman/releases/download/${LATEST_VERSION}/podman-installer-windows-${ARCHITECTURE}.msi"
157+
;;
155158
*)
156159
echo "Error: Unsupported Windows file type: $FILE_TYPE"
157-
echo "Supported types: setup.exe, installer.exe, remote.zip"
160+
echo "Supported types: setup.exe, installer.exe, remote.zip, msi"
158161
exit 1
159162
;;
160163
esac

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This composite action installs Podman on GitHub-hosted runners for both Linux (U
66

77
The action is cross-platform, working for both ubuntu-latest and windows-latest runners.
88

9-
On Windows, it features a smart installer that automatically fetches the latest Podman version by default. However, you can also specify a specific version if your CI needs to be pinned to an older release. After installation, the action automatically runs podman machine init --now to ensure the Podman machine is running and ready for use in subsequent steps.
9+
On Windows, it uses the official Podman MSI installer, automatically fetching the latest version. You can specify a specific Podman version if your CI needs to be pinned. After installation, the action automatically runs podman machine init --now to ensure the Podman machine is running and ready for use in subsequent steps.
1010

1111
On Linux, the action installs Podman v5.x and its key dependencies (like CRIU) from the openSUSE Kubic repository, ensuring you get a modern version.
1212

action.yml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
description: "Podman version for Windows. Use 'latest' or a specific version (e.g. '5.6.2')."
2929
required: false
3030
default: "latest"
31+
install-scope:
32+
description: "Installation scope for Windows MSI installer. Use 'user' for user-scope (no admin required) or 'machine' for machine-scope (requires admin privileges)."
33+
required: false
34+
default: "user"
3135
github-token:
3236
description: "GitHub token to make authenticated API requests and avoid rate limiting."
3337
required: false
@@ -73,7 +77,6 @@ runs:
7377
uses: redhat-actions/podman-install/.github/actions/fetch-latest-podman-version-windows@6b757b792b67ec663765a4f2ca36226e12b2f4cd
7478
with:
7579
version_input: ${{ inputs.podman-version-input || 'latest' }}
76-
file_type: 'setup.exe'
7780
github_token: ${{ inputs.github-token }}
7881

7982
- name: Install Podman on Windows
@@ -82,23 +85,63 @@ runs:
8285
run: |
8386
$downloadUrl = "${{ steps.fetch-podman-url.outputs.download_url }}"
8487
$podmanVersion = "${{ steps.fetch-podman-url.outputs.version }}"
88+
$installScope = "${{ inputs.install-scope }}"
8589
86-
$versionNumber = $podmanVersion -replace '^v'
87-
$fileName = "podman-$versionNumber-setup.exe"
90+
$uri = [System.Uri]$downloadUrl
91+
$fileName = Split-Path -Leaf $uri.AbsolutePath
8892
8993
echo "Installing Podman version $podmanVersion..."
90-
echo "Downloading from $downloadUrl file $fileName"
94+
echo "Installation scope: $installScope"
95+
echo "Downloading from $downloadUrl to $fileName"
9196
curl --output $fileName -L $downloadUrl
9297
93-
Start-Process -FilePath ".\$fileName" -ArgumentList "/install", "/passive", "/norestart", "/log podman-logs.txt" -Wait
94-
Get-Content podman-logs.txt
98+
if ($fileName -match '\.msi$') {
99+
$msiArgs = @("/package", "$PWD\$fileName", "/quiet", "/norestart", "/l*v", "podman-msi.log")
100+
if ($installScope -eq "machine") {
101+
echo "Installing at machine-scope (requires admin privileges)..."
102+
$msiArgs += "ALLUSERS=1"
103+
} else {
104+
echo "Installing at user-scope (no admin required)..."
105+
}
106+
Start-Process msiexec -ArgumentList $msiArgs -Wait
107+
} else {
108+
Start-Process -FilePath ".\$fileName" -ArgumentList "/install", "/passive", "/norestart", "/log podman-logs.txt" -Wait
109+
}
110+
if ($fileName -match '\.msi$' -and (Test-Path podman-msi.log)) {
111+
Get-Content podman-msi.log
112+
} elseif (Test-Path podman-logs.txt) {
113+
Get-Content podman-logs.txt
114+
}
95115
96116
- name: Initialize Podman Machine on Windows
97117
if: runner.os == 'Windows'
98118
shell: pwsh
99119
run: |
120+
$installScope = "${{ inputs.install-scope }}"
121+
100122
echo "Adding Podman to PATH for this session..."
101-
$env:PATH += ";C:\Program Files\RedHat\Podman"
123+
# New MSI installer locations (user-scope and machine-scope)
124+
$userScopePath = "$env:LOCALAPPDATA\Programs\Podman"
125+
$machineScopePath = "$env:ProgramFiles\Podman"
126+
# Legacy installer location (for backward compatibility)
127+
$legacyPath = "$env:ProgramFiles\RedHat\Podman"
128+
129+
# Check based on install scope first, then fall back to other locations
130+
if ($installScope -eq "machine" -and (Test-Path $machineScopePath)) {
131+
$env:PATH += ";$machineScopePath"
132+
} elseif ($installScope -eq "user" -and (Test-Path $userScopePath)) {
133+
$env:PATH += ";$userScopePath"
134+
} elseif (Test-Path $userScopePath) {
135+
$env:PATH += ";$userScopePath"
136+
} elseif (Test-Path $machineScopePath) {
137+
$env:PATH += ";$machineScopePath"
138+
} elseif (Test-Path $legacyPath) {
139+
$env:PATH += ";$legacyPath"
140+
}
141+
142+
$podmanPath = (Get-Command podman).Path
143+
echo "Podman installed at: $podmanPath"
144+
102145
podman --version
103146
echo "Initializing Podman machine..."
104147
podman machine init --now

0 commit comments

Comments
 (0)