chore: add publication scripts for brew, chocolatey and winget

fixes https://github.com/containers/podman-desktop/issues/445
fixes https://github.com/containers/podman-desktop/issues/449

Change-Id: I722b1c6061d1748209c1b4d25598cbc02b30476a
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
Florent Benoit 2022-09-05 13:54:41 +02:00 committed by Florent BENOIT
parent 8e2f7ebcf9
commit ecc7a5f5df
11 changed files with 420 additions and 3 deletions

1
.chocolatey/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.nupkg

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesnt appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>podman-desktop</id>
<version>0.0.5</version>
<title>Podman Desktop</title>
<authors>Florent Benoit</authors>
<owners>https://github.com/containers</owners>
<licenseUrl>https://github.com/containers/podman-desktop/blob/main/LICENSE</licenseUrl>
<projectUrl>http://www.podman-desktop.io/</projectUrl>
<iconUrl>https://github.com/containers/podman-desktop/raw/main/buildResources/icon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
## Containers and Kubernetes for application developers
### Build, run and manage containers:
- Build images from Containerfile or Dockerfile.
- Pull images from remote registries.
- Start, Stop, Restart containers and pods.
- Easily get a terminal in your container.
- Inspect container logs.
- Push images to OCI registries.
- Deploy and test images on Kubernetes.
### Multiple configuration options
- Manage OCI registries; add, edit, or delete registries.
- Configure your proxy settings (work in progress.)
- Configure CPU, memory, and disk of Podman machines (work in progress.)
- Handle multiple container engines at the same time (Podman, Docker, Lima...)
### You can also bring new features with Podman Desktop plug-ins or Docker Desktop extensions
</description>
<summary>Manage Podman and other container engines from a single UI and tray.</summary>
<releaseNotes>https://github.com/containers/podman-desktop/releases/latest</releaseNotes>
<copyright>2022 Red Hat, Inc</copyright>
<tags>podman desktop podman-machine containers ui</tags>
<packageSourceUrl>https://github.com/containers/podman-desktop/tree/main/.chocolatey</packageSourceUrl>
<projectSourceUrl>https://github.com/containers/podman-desktop</projectSourceUrl>
<docsUrl>https://podman-desktop.io/docs/intro</docsUrl>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>

View file

@ -0,0 +1,16 @@
$ErrorActionPreference = 'Stop'
$packageArgs = @{
packageName = 'podman-desktop'
fileType = 'exe'
softwareName = 'PodmanDesktop'
url64bit = 'https://github.com/containers/podman-desktop/releases/download/v0.0.5/podman-desktop-0.0.5-setup.exe'
checksumType = 'sha256'
checksum64 = '9e3190e43e742623e81fe49e80564ca7723ae73ca356a3623b83083d1a141a56'
silentArgs = '/S'
validExitCodes = @(0)
}
Install-ChocolateyPackage @packageArgs

View file

@ -0,0 +1,27 @@
$ErrorActionPreference = 'Stop';
$packageName = 'podman-desktop'
$uninstalled = $false
[array]$key = Get-UninstallRegistryKey -SoftwareName 'PodmanDesktop'
if ($key.Count -eq 1) {
$key | % {
$packageArgs = @{
packageName = $packageName
fileType = 'EXE'
silentArgs = '/S'
validExitCodes = @(0)
file = "$($_.UninstallString.Trim('"'))"
}
Uninstall-ChocolateyPackage @packageArgs
}
} elseif ($key.Count -eq 0) {
Write-Warning "$packageName has already been uninstalled by other means."
} elseif ($key.Count -gt 1) {
Write-Warning "$key.Count matches found!"
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
Write-Warning "Please alert package maintainer the following keys were matched:"
$key | % {Write-Warning "- $_.DisplayName"}
}

View file

@ -0,0 +1,32 @@
import-module au
$version = $env:VERSION
$releases = 'https://github.com/containers/podman-desktop/releases/tag/v' + $version
function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(?i)(^\s*url64bit\s*=\s*)('.*')" = "`$1'$($Latest.URL64)'"
"(?i)(^\s*checksum64\s*=\s*)('.*')" = "`$1'$($Latest.Checksum64)'"
}
".\podman-desktop.nuspec" = @{
"\<version\>.+" = "<version>$($Latest.Version)</version>"
"\<releaseNotes\>.+" = "<releaseNotes>$($Latest.ReleaseNotes)</releaseNotes>"
}
}
}
function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases
$url64 = $download_page.links | ? href -match '-setup.exe$' | % href | select -First 1
$version = (Split-Path ( Split-Path $url64 ) -Leaf).Substring(1)
@{
URL64 = 'https://github.com' + $url64
Version = $version
ReleaseNotes = $releases
}
}
update -ChecksumFor 64

View file

@ -41,4 +41,13 @@
<id>io.podman_desktop.PodmanDesktop</id>
</provides>
<update_contact>fbenoit_at_redhat_com</update_contact>
<releases>
<release version="0.0.6" date="2022-08-10" />
<release version="0.0.5" date="2022-07-01" />
<release version="0.0.4" date="2022-06-08" />
<release version="0.0.3" date="2022-05-09" />
<release version="0.0.2" date="2022-04-14" />
<release version="0.0.1" date="2022-03-17" />
</releases>
</component>

9
.flatpak.desktop Normal file
View file

@ -0,0 +1,9 @@
[Desktop Entry]
Name=Podman Desktop
Exec=run.sh %U
Terminal=false
Type=Application
Icon=io.podman_desktop.PodmanDesktop
StartupWMClass=Podman Desktop
Categories=Utility;
X-Flatpak=io.podman_desktop.PodmanDesktop

58
.github/workflows/publish-to-brew.yaml vendored Normal file
View file

@ -0,0 +1,58 @@
#
# Copyright (C) 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: Publish update to Brew
on:
workflow_dispatch:
inputs:
version:
description: 'release version like 0.0.6'
required: true
repository_dispatch:
types: [ publish-to-brew ]
jobs:
publish-to-brew:
name: Publish Podman Desktop to Brew cask
runs-on: macos-11
steps:
- name: Set version
id: VERSION
run: |
version=""
if [ "${{ github.event_name }}" == "repository_dispatch" ]
then
version="${{ github.event.client_payload.version }}"
else
version="${{ github.event.inputs.version }}"
fi
# strip out the prefix v if it's there
if [[ $version == v* ]]; then
version="${version:1}"
fi
echo "::set-output name=desktopVersion::$version"
- name: Create Pull Request to update Brew
run: |
echo "Run the tool with version ${PODMAN_DESKTOP_VERSION}"
brew bump-cask-pr --version="${PODMAN_DESKTOP_VERSION}" podman-desktop
env:
TOKEN: ${{ secrets.PODMAN_DESKTOP_BOT_TOKEN }}
PODMAN_DESKTOP_VERSION: ${{ steps.VERSION.outputs.desktopVersion }}
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_ANALYTICS: 1

View file

@ -0,0 +1,111 @@
#
# Copyright (C) 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: Publish update to Chocolatey
on:
workflow_dispatch:
inputs:
version:
description: 'release version like 0.0.6'
required: true
force:
description: 'Force the push of the package'
required: false
default: 'false'
repository_dispatch:
types: [ publish-to-chocolatey ]
jobs:
version:
name: Extracting version
runs-on: ubuntu-20.04
outputs:
desktopVersion: ${{ steps.VERSION.outputs.desktopVersion}}
steps:
- name: set version
id: VERSION
run: |
version=""
if [ "${{ github.event_name }}" == "repository_dispatch" ]
then
version="${{ github.event.client_payload.version }}"
else
version="${{ github.event.inputs.version }}"
fi
# strip out the prefix v if it's there
if [[ $version == v* ]]; then
version="${version:1}"
fi
echo "::set-output name=desktopVersion::$version"
winget-bump:
name: Update Chocolatey
needs: version
runs-on: windows-2022
defaults:
run:
shell: powershell
steps:
- uses: actions/checkout@v2
- name: Install the Chocolatey Automatic Package Updater Module
run: cinst au
- name: Build the Podman Desktop chocolatey Package by making sure we're using the latest release
working-directory: ./.chocolatey/podman-desktop
run: |
if ($env:automaticUpdateForce -eq 'true') {
$au_Force = $true; ./update.ps1
} else {
./update.ps1
}
cat podman-desktop.nuspec
env:
au_Push: ${{ github.event.inputs.force }}
automaticUpdateForce: ${{ github.event.inputs.force }}
VERSION: ${{ needs.version.outputs.desktopVersion }}
- name: Create the PR to bump the version in the main branch
run: |
git config --local user.name ${{ github.actor }}
git config --local user.email "fbenoit@redhat.com"
$bumpedBranchName = "update-chocolatey-for-${{ needs.version.outputs.desktopVersion }}"
git checkout -b $bumpedBranchName
git add .chocolatey
git commit --signoff -m "chore: Update chocolatey packages for ${{ needs.version.outputs.desktopVersion }}"
git push origin "$bumpedBranchName"
New-Item -Path . -Name "pr-title" -ItemType "file" -Value "${{ needs.version.outputs.desktopVersion }} has been released`n`nUpdate Chocolatey packages for ${{ needs.version.outputs.desktopVersion }}"
$pullRequestUrl = gh pr create --title "chore: Update Chocolatey package to ${{ needs.version.outputs.desktopVersion }}" --body-file ./pr-title --head "$bumpedBranchName" --base "main" -R "containers/podman-desktop"
echo "📢 Pull request created: $pullRequestUrl"
echo "➡️ Flag the PR as being ready for review"
gh pr ready "$pullRequestUrl"
echo "🔅 Mark the PR as being ok to be merged automatically"
gh pr merge "$pullRequestUrl" --auto --rebase
env:
GH_TOKEN: ${{ secrets.PODMAN_DESKTOP_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PODMAN_DESKTOP_BOT_TOKEN }}
- name: Publish Package to Chocolatey
run: |
if ($env:automaticUpdateForce -eq 'true') {
$au_Force = $true; Push-Package
} else {
Push-Package
}
working-directory: ./.chocolatey/podman-desktop
env:
api_key: ${{ secrets.CHOCOLATEY_API_KEY }}
automaticUpdateForce: ${{ github.event.inputs.force }}

View file

@ -0,0 +1,69 @@
#
# Copyright (C) 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: Publish update to Winget
on:
workflow_dispatch:
inputs:
version:
description: 'release version like 0.0.6'
required: true
repository_dispatch:
types: [ publish-to-winget ]
jobs:
version:
name: Extracting version
runs-on: ubuntu-20.04
outputs:
desktopVersion: ${{ steps.VERSION.outputs.desktopVersion}}
steps:
- name: set version
id: VERSION
run: |
version=""
if [ "${{ github.event_name }}" == "repository_dispatch" ]
then
version="${{ github.event.client_payload.version }}"
else
version="${{ github.event.inputs.version }}"
fi
# strip out the prefix v if it's there
if [[ $version == v* ]]; then
version="${version:1}"
fi
echo "::set-output name=desktopVersion::$version"
winget-bump:
name: Update Winget
needs: version
runs-on: windows-2022
defaults:
run:
shell: powershell
steps:
- name: Create winget PR
run: |
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe update RedHat.Podman-Desktop -u $Env:URL -v $Env:VERSION -t $Env:TOKEN --submit
env:
TOKEN: ${{ secrets.PODMAN_DESKTOP_BOT_TOKEN }}
VERSION: ${{ needs.version.outputs.desktopVersion }}
URL: ${{ format('https://github.com/containers/podman-desktop/releases/download/v{0}/podman-desktop-{0}-setup.exe|x64', needs.version.outputs.desktopVersion) }}

View file

@ -48,10 +48,31 @@ jobs:
- name: tag
run: |
git config --local user.name ${{ github.actor }}
# Add the new version in package.json file
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.desktopVersion }}\",#g" package.json
cat package.json
git add package.json
git commit -m "chore: tag ${{ steps.TAG_UTIL.outputs.githubTag }}"
# Update the issue template with the new version and move old version below
nextVersionLineNumber=$(grep -n "next (development version)" .github/ISSUE_TEMPLATE/bug_report.yml | cut -d ":" -f 1 | head -n 1)
currentVersionItem=$(sed "$(expr ${nextVersionLineNumber} - 1)q;d" .github/ISSUE_TEMPLATE/bug_report.yml)
newVersionItem=$(echo "$currentVersionItem" | sed -r -e "s|\".*\"|\"${{ steps.TAG_UTIL.outputs.desktopVersion }}\"|")
# delete the lines before the next version line
sed -i "$(expr ${nextVersionLineNumber} - 1)d" .github/ISSUE_TEMPLATE/bug_report.yml
# insert the version being tagged
sed -i "$(expr ${nextVersionLineNumber} - 1)i\\${newVersionItem}" .github/ISSUE_TEMPLATE/bug_report.yml
sed -i "$(expr ${nextVersionLineNumber} + 1)i\\${currentVersionItem}" .github/ISSUE_TEMPLATE/bug_report.yml
# add the changes
git add .github/ISSUE_TEMPLATE/bug_report.yml
# Add the new version in the appdata.xml file
xmlReleasesLineNumber=$(grep -n "<releases>" .flatpak-appdata.xml | cut -d ":" -f 1 | head -n 1)
newFlatpakReleaseItem=" <release version=\"${{ steps.TAG_UTIL.outputs.desktopVersion }}\" date=\"$(date +%Y-%m-%d)\"/>"
sed -i "$(expr ${xmlReleasesLineNumber} + 1)i\\${newFlatpakReleaseItem}" .flatpak-appdata.xml
git add .flatpak-appdata.xml
# commit the changes
git commit -m "chore: 🥁 tagging ${{ steps.TAG_UTIL.outputs.githubTag }} 🥳"
echo "Tagging with ${{ steps.TAG_UTIL.outputs.githubTag }}"
git tag ${{ steps.TAG_UTIL.outputs.githubTag }}
git push origin ${{ steps.TAG_UTIL.outputs.githubTag }}
@ -65,7 +86,26 @@ jobs:
release_name: ${{ steps.TAG_UTIL.outputs.githubTag }}
draft: true
prerelease: false
- name: Create the PR to bump the version in the main branch
run: |
git config --local user.name ${{ github.actor }}
git config --local user.email "fbenoit@redhat.com"
bumpedVersion=$(echo "${{ steps.TAG_UTIL.outputs.desktopVersion }}" | awk -F. -v OFS=. '{$NF += 1 ; print}')
bumpedBranchName="bump-to-${bumpedVersion}"
git checkout -b "${bumpedBranchName}"
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" package.json
git add package.json
git commit -s --amend -m "chore: bump version to ${bumpedVersion}"
git push origin "${bumpedBranchName}"
echo -e "📢 Bump version to ${bumpedVersion}\n\n${{ steps.TAG_UTIL.outputs.desktopVersion }} has been released.\n\n Time to switch to the new ${bumpedVersion} version 🥳" > /tmp/pr-title
pullRequestUrl=$(gh pr create --title "chore: 📢 Bump version to ${bumpedVersion}" --body-file /tmp/pr-title --head "${bumpedBranchName}" --base "main")
echo "📢 Pull request created: ${pullRequestUrl}"
echo "➡️ Flag the PR as being ready for review"
gh pr ready "${pullRequestUrl}"
echo "🔅 Mark the PR as being ok to be merged automatically"
gh pr merge "${pullRequestUrl}" --auto --rebase
env:
GITHUB_TOKEN: ${{ secrets.PODMAN_DESKTOP_BOT_TOKEN }}
build:
name: Build / ${{ matrix.os }}