forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (111 loc) · 4.69 KB
/
update-podmanio.yml
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
112
113
114
115
116
117
118
119
120
121
name: Update Podman version on Podman.io
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Release version to build and upload (e.g. "v9.8.7")'
required: true
jobs:
bump:
name: Bump
runs-on: ubuntu-24.04
steps:
- name: Get version
id: getversion
run: |
if [[ -z "${{ inputs.version }}" ]]
then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=${{ inputs.version }}
fi
# strip out the prefix v if it's there
if [[ $VERSION == v* ]]; then
VERSION="${VERSION:1}"
fi
echo "Bump to ${VERSION}"
if [[ $VERSION != *-rc* ]] && [[ $VERSION != *-dev ]]; then
echo "notRC=true" >> "$GITHUB_OUTPUT"
else
echo "SKIPPING: Version is a RC or a dev, no need to update."
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Check open PRs
if: steps.getversion.outputs.notRC == 'true'
id: checkpr
run: |
prs=$(gh pr list \
--repo containers/podman.io \
--head bump-podmanv${{ steps.getversion.outputs.version }} \
--state open \
--json title \
--jq 'length')
if ((prs > 0)); then
echo "SKIPPING: PR already exists to update to v${{ steps.getversion.outputs.version }}."
else
echo "prexists=false" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.PODMANBOT_TOKEN }}
- uses: actions/checkout@v4
if: >-
steps.getversion.outputs.notRC == 'true' &&
steps.checkpr.outputs.prexists == 'false'
with:
repository: containers/podman.io
ref: refs/heads/main
token: ${{ secrets.PODMANBOT_TOKEN }}
- name: Check version
if: >-
steps.getversion.outputs.notRC == 'true' &&
steps.checkpr.outputs.prexists == 'false'
id: checkversion
run: |
# Check if version is actually higher than one on podman.io
prevversion=`grep -P "(?<=export const LATEST_VERSION = ')(\d.\d.\d)" -o static/data/global.ts`
echo "Version currently on site: ${prevversion}"
echo "Version to update to: ${{ steps.getversion.outputs.version }}"
# sort -V -C returns 0 if args are ascending version order
if echo "${prevversion},${{ steps.getversion.outputs.version }}" | tr ',' '\n' | sort -V -C && [[ ${prevversion} != ${{ steps.getversion.outputs.version }} ]]
then
echo "needsUpdate=true" >> $GITHUB_OUTPUT
echo "This release is a higher version, so we need to update podman.io"
else
echo "SKIPPING: This release is not a higher version, no need to update."
fi
- name: Bump version
if: >-
steps.getversion.outputs.notRC == 'true' &&
steps.checkversion.outputs.needsUpdate == 'true' &&
steps.checkpr.outputs.prexists == 'false'
run: |
# Replace the version in static/data/global.ts file
sed -i "s/export const LATEST_VERSION = '.*';/export const LATEST_VERSION = '${{ steps.getversion.outputs.version }}';/g" static/data/global.ts
echo "Updated file:"
cat static/data/global.ts
- name: Open PR
if: >-
steps.getversion.outputs.notRC == 'true' &&
steps.checkversion.outputs.needsUpdate == 'true' &&
steps.checkpr.outputs.prexists == 'false'
run: |
# Make committer the user who triggered the action, either through cutting a release or manual trigger
# GitHub gives everyone a noreply email associated with their account, use that email for the sign-off
git config --local user.name ${{ github.actor }}
git config --local user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
bumpbranch="bump-podmanv${{ steps.getversion.outputs.version }}"
git checkout -b $bumpbranch
git add static/data/global.ts
git commit --signoff -m "Bump Podman to v${{ steps.getversion.outputs.version }}"
git remote -v
git remote add podmanbot https://github.com/podmanbot/podman.io
git push podmanbot "+$bumpbranch"
gh pr create \
--title "Bump Podman to v${{ steps.getversion.outputs.version }}" \
--body "Bump Podman to v${{ steps.getversion.outputs.version }}" \
--head "podmanbot:$bumpbranch" \
--base "main" -R "containers/podman.io"
env:
GH_TOKEN: ${{ secrets.PODMANBOT_TOKEN }}