forked from podman-desktop/podman-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (105 loc) · 4.19 KB
/
publish-to-chocolatey.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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-24.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 "desktopVersion=$version" >> ${GITHUB_OUTPUT}
winget-bump:
name: Update Chocolatey
needs: version
runs-on: windows-2022
defaults:
run:
shell: powershell
steps:
- uses: actions/checkout@v4
- name: Install the Chocolatey Automatic Package Updater Module
run: choco install au -y
- 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 "[email protected]"
$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 }}