Skip to content

Commit f5e870b

Browse files
committed
chore: auto sync min desktop version with last supported version
Signed-off-by: skjnldsv <[email protected]>
1 parent 7bab703 commit f5e870b

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: MIT
3+
name: Update min supported desktop version
4+
5+
on:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "0 0 * * 1"
9+
10+
jobs:
11+
update-minimum-supported-desktop-version:
12+
runs-on: ubuntu-latest-low
13+
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
16+
with:
17+
submodules: true
18+
19+
- name: Download desktop client version file from 5 years ago
20+
id: download
21+
run: |
22+
# Create a temporary directory for the downloaded file
23+
mkdir -p tmp
24+
25+
# Download the version file from the provided URL
26+
VERSION_FILE_URL="https://github.com/nextcloud/desktop/raw/@%7B5.years.ago%7D/VERSION.cmake"
27+
28+
# Download the file using curl
29+
curl -s -L "$VERSION_FILE_URL" -o tmp/VERSION.cmake
30+
31+
if [ ! -f "tmp/VERSION.cmake" ]; then
32+
echo "Failed to download VERSION.cmake file"
33+
exit 1
34+
fi
35+
36+
echo "VERSION_FILE=tmp/VERSION.cmake" >> $GITHUB_OUTPUT
37+
echo "Downloaded version file to tmp/VERSION.cmake"
38+
39+
- name: Extract version info
40+
id: extract-version
41+
run: |
42+
# Path to the downloaded version file
43+
VERSION_FILE="${{ steps.download.outputs.VERSION_FILE }}"
44+
45+
# Extract major, minor, patch versions
46+
MAJOR=$(grep "VERSION_MAJOR" $VERSION_FILE | grep -o '[0-9]\+')
47+
MINOR=$(grep "VERSION_MINOR" $VERSION_FILE | grep -o '[0-9]\+')
48+
PATCH=$(grep "VERSION_PATCH" $VERSION_FILE | grep -o '[0-9]\+')
49+
50+
# Construct the version string
51+
VERSION="$MAJOR.$MINOR.$PATCH"
52+
53+
# Validate format: xx.xx.xx where each x is a digit
54+
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
55+
echo "Error: Extracted version '$VERSION' does not match required format (xx.xx.xx)"
56+
exit 1
57+
fi
58+
59+
rm -rf tmp
60+
61+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
62+
echo "Extracted Version: $VERSION"
63+
64+
- name: Update files with new version ${{ steps.extract-version.outputs.VERSION }}
65+
id: update-files
66+
run: |
67+
VERSION="${{ steps.extract-version.outputs.VERSION }}"
68+
69+
# Define the files to update
70+
DAV_FILE="apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php"
71+
CONFIG_FILE="config/config.sample.php"
72+
73+
# Check if files exist
74+
if [ ! -f "$DAV_FILE" ]; then
75+
echo "Error: DAV file not found at $DAV_FILE"
76+
exit 1
77+
fi
78+
79+
if [ ! -f "$CONFIG_FILE" ]; then
80+
echo "Error: Config file not found at $CONFIG_FILE"
81+
exit 1
82+
fi
83+
84+
# Update the DAV file - replace the version in the specific line
85+
sed -i "s/\('minimum\.supported\.desktop\.version', '\)[0-9]\+\.[0-9]\+\.[0-9]\+'/\1$VERSION'/g" "$DAV_FILE"
86+
echo "Updated $DAV_FILE"
87+
88+
# Update the config sample file
89+
PREV_VERSION=$(grep "'minimum.supported.desktop.version'" "$CONFIG_FILE" | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
90+
sed -i "s/Defaults to \`\`$PREV_VERSION\`\`/Defaults to \`\`$VERSION\`\`/" "$CONFIG_FILE"
91+
sed -i "s/'minimum\.supported\.desktop\.version' => '[0-9]\+\.[0-9]\+\.[0-9]\+'/'minimum.supported.desktop.version' => '$VERSION'/g" "$CONFIG_FILE"
92+
echo "Updated $CONFIG_FILE"
93+
94+
# Check if any changes were made
95+
if [ -n "$(git diff "$DAV_FILE" "$CONFIG_FILE")" ]; then
96+
echo "CHANGES_MADE=true" >> $GITHUB_OUTPUT
97+
echo "Changes were made to the files"
98+
git diff "$DAV_FILE" "$CONFIG_FILE"
99+
else
100+
echo "CHANGES_MADE=false" >> $GITHUB_OUTPUT
101+
echo "No changes were needed (versions might already be up to date)"
102+
fi
103+
104+
- name: Create Pull Request
105+
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f
106+
if: steps.update-files.outputs.CHANGES_MADE == 'true'
107+
with:
108+
token: ${{ secrets.COMMAND_BOT_PAT }}
109+
commit-message: "chore: Update minimum supported desktop version"
110+
committer: GitHub <[email protected]>
111+
author: nextcloud-command <[email protected]>
112+
signoff: true
113+
branch: "automated/noid/${{ matrix.branches }}-update-min-supported-desktop-version"
114+
title: "chore: Update minimum supported desktop version to ${{ steps.extract-version.outputs.VERSION }}"
115+
base: "master"
116+
body: |
117+
Auto-generated update of the minimum supported desktop version using last supported version.
118+
https://github.com/nextcloud/desktop/blob/@%7B5.years.ago%7D/VERSION.cmake
119+
labels: |
120+
client: 💻 desktop
121+
automated
122+
3. to review
123+
reviewers: tobiasKaminsky, camilasan, claucambra

config/config.sample.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2176,7 +2176,7 @@
21762176
* this server instance. All connections made from later clients will be denied
21772177
* by the server.
21782178
*
2179-
* Defaults to 99.99.99
2179+
* Defaults to ``99.99.99``
21802180
*/
21812181
'maximum.supported.desktop.version' => '99.99.99',
21822182

0 commit comments

Comments
 (0)