diff --git a/.github/scripts/update-updater-server.sh b/.github/scripts/update-updater-server.sh index d6974679126..5e215e4e444 100755 --- a/.github/scripts/update-updater-server.sh +++ b/.github/scripts/update-updater-server.sh @@ -467,9 +467,12 @@ ${NEW_SIG_BLOCK} SCENARIO # Update latest.feature - # Find current latest stable version and replace + # Find current latest stable version and replace. + # head -1: latest.feature may hold several "latest stable" scenarios + # (e.g. a PHP-version-pinned one); only the first is the primary entry. + # Without it the var goes multiline and breaks the sed below. CURRENT_LATEST_STABLE=$(grep -A4 'latest stable release' "$LATEST_FEATURE" \ - | grep 'Version "' | grep -oP 'Version "\K[^"]+') + | grep 'Version "' | grep -oP 'Version "\K[^"]+' | head -1) CURRENT_LATEST_STABLE_URL=$(echo "$CURRENT_LATEST_STABLE" | sed 's/ //g' | tr '[:upper:]' '[:lower:]') if [[ -n "$CURRENT_LATEST_STABLE" ]]; then @@ -541,8 +544,9 @@ ${NEW_SIG_BLOCK} SCENARIO # Update latest.feature — beta now points to this pre-release + # head -1: see CURRENT_LATEST_STABLE note — guard against multiline. CURRENT_LATEST_BETA=$(grep -A4 'latest beta release' "$LATEST_FEATURE" \ - | grep 'Version "' | grep -oP 'Version "\K[^"]+') + | grep 'Version "' | grep -oP 'Version "\K[^"]+' | head -1) CURRENT_LATEST_BETA_URL=$(echo "$CURRENT_LATEST_BETA" | sed 's/ //g' | tr '[:upper:]' '[:lower:]') if [[ -n "$CURRENT_LATEST_BETA" ]]; then @@ -582,10 +586,32 @@ if [[ "$DEPLOY" -ne 100 ]]; then COMMIT_MSG="${COMMIT_MSG} (${DEPLOY}% rollout)" fi +# Ensure a git identity exists (CI runners have none by default). +# Derive it from the token owner (GH_TOKEN == RELEASE_TOKEN) so commits +# are authored by the bot the token belongs to. Fall back to +# github-actions[bot] if the token isn't a user token (e.g. github.token). +if [[ -z "$(git config user.email)" ]]; then + BOT_LOGIN=$(gh api user --jq '.login' 2>/dev/null || true) + if [[ -n "$BOT_LOGIN" ]]; then + BOT_ID=$(gh api user --jq '.id' 2>/dev/null || true) + git config user.name "$BOT_LOGIN" + git config user.email "${BOT_ID}+${BOT_LOGIN}@users.noreply.github.com" + else + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + fi +fi + git checkout -b "$BRANCH" git add config/ tests/ git commit --signoff -m "$COMMIT_MSG" -git push -u origin "$BRANCH" + +# Route git's github.com auth through gh (GH_TOKEN == RELEASE_TOKEN); +# the gh-cloned remote has no push credentials on its own. +gh auth setup-git +# Force-push so re-runs for the same release overwrite a stale branch +# (each run produces a fresh commit, so a leftover branch is non-ff). +git push --force -u origin "$BRANCH" BODY="Automated PR from the release pipeline. @@ -599,6 +625,7 @@ Generated by \`update-updater-server.sh ${TAG}\`." gh pr create \ --repo "$UPDATER_REPO" \ --base master \ + --head "$BRANCH" \ --title "$COMMIT_MSG" \ --body "$BODY" diff --git a/tests/updater-script/base/tests/integration/features/latest.feature b/tests/updater-script/base/tests/integration/features/latest.feature index 0ab7f5422bb..7c03cc5912e 100644 --- a/tests/updater-script/base/tests/integration/features/latest.feature +++ b/tests/updater-script/base/tests/integration/features/latest.feature @@ -13,3 +13,32 @@ Feature: Testing the latest endpoint Then The JSON response is non-empty And Version "34.0.0 RC5" is the latest release And URL to download is "https://download.nextcloud.com/server/prereleases/nextcloud-34.0.0rc5.zip" + + Scenario: Get latest stable version with PHP 8.0 + Given I want to know the latest stable release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest beta version with PHP 8.0 + Given I want to know the latest beta release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest version with invalid PHP version + Given I want to know the latest beta release + And I use PHP "test" + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid PHP version provided" + + Scenario: Get latest version with invalid channel + Given I want to know the latest whatever release + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid channel provided" diff --git a/tests/updater-script/scenarios/first-beta/expected/tests/integration/features/latest.feature b/tests/updater-script/scenarios/first-beta/expected/tests/integration/features/latest.feature index b8fd4f2f394..8f576f09dc1 100644 --- a/tests/updater-script/scenarios/first-beta/expected/tests/integration/features/latest.feature +++ b/tests/updater-script/scenarios/first-beta/expected/tests/integration/features/latest.feature @@ -13,3 +13,32 @@ Feature: Testing the latest endpoint Then The JSON response is non-empty And Version "35.0.0 beta 1" is the latest release And URL to download is "https://download.nextcloud.com/server/prereleases/nextcloud-35.0.0beta1.zip" + + Scenario: Get latest stable version with PHP 8.0 + Given I want to know the latest stable release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest beta version with PHP 8.0 + Given I want to know the latest beta release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest version with invalid PHP version + Given I want to know the latest beta release + And I use PHP "test" + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid PHP version provided" + + Scenario: Get latest version with invalid channel + Given I want to know the latest whatever release + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid channel provided" diff --git a/tests/updater-script/scenarios/first-stable/expected/tests/integration/features/latest.feature b/tests/updater-script/scenarios/first-stable/expected/tests/integration/features/latest.feature index 42d01adbb07..2c2f41869ff 100644 --- a/tests/updater-script/scenarios/first-stable/expected/tests/integration/features/latest.feature +++ b/tests/updater-script/scenarios/first-stable/expected/tests/integration/features/latest.feature @@ -13,3 +13,32 @@ Feature: Testing the latest endpoint Then The JSON response is non-empty And Version "34.0.0" is the latest release And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-34.0.0.zip" + + Scenario: Get latest stable version with PHP 8.0 + Given I want to know the latest stable release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest beta version with PHP 8.0 + Given I want to know the latest beta release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest version with invalid PHP version + Given I want to know the latest beta release + And I use PHP "test" + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid PHP version provided" + + Scenario: Get latest version with invalid channel + Given I want to know the latest whatever release + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid channel provided" diff --git a/tests/updater-script/scenarios/patch-release-01/expected/tests/integration/features/latest.feature b/tests/updater-script/scenarios/patch-release-01/expected/tests/integration/features/latest.feature index 059d74d7f42..d493e841611 100644 --- a/tests/updater-script/scenarios/patch-release-01/expected/tests/integration/features/latest.feature +++ b/tests/updater-script/scenarios/patch-release-01/expected/tests/integration/features/latest.feature @@ -13,3 +13,32 @@ Feature: Testing the latest endpoint Then The JSON response is non-empty And Version "34.0.0 RC5" is the latest release And URL to download is "https://download.nextcloud.com/server/prereleases/nextcloud-34.0.0rc5.zip" + + Scenario: Get latest stable version with PHP 8.0 + Given I want to know the latest stable release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest beta version with PHP 8.0 + Given I want to know the latest beta release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest version with invalid PHP version + Given I want to know the latest beta release + And I use PHP "test" + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid PHP version provided" + + Scenario: Get latest version with invalid channel + Given I want to know the latest whatever release + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid channel provided" diff --git a/tests/updater-script/scenarios/patch-release-02/expected/tests/integration/features/latest.feature b/tests/updater-script/scenarios/patch-release-02/expected/tests/integration/features/latest.feature index 00317b1d8bb..c71d4577b4f 100644 --- a/tests/updater-script/scenarios/patch-release-02/expected/tests/integration/features/latest.feature +++ b/tests/updater-script/scenarios/patch-release-02/expected/tests/integration/features/latest.feature @@ -13,3 +13,32 @@ Feature: Testing the latest endpoint Then The JSON response is non-empty And Version "34.0.0 RC5" is the latest release And URL to download is "https://download.nextcloud.com/server/prereleases/nextcloud-34.0.0rc5.zip" + + Scenario: Get latest stable version with PHP 8.0 + Given I want to know the latest stable release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest beta version with PHP 8.0 + Given I want to know the latest beta release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest version with invalid PHP version + Given I want to know the latest beta release + And I use PHP "test" + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid PHP version provided" + + Scenario: Get latest version with invalid channel + Given I want to know the latest whatever release + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid channel provided" diff --git a/tests/updater-script/scenarios/patch-release/expected/tests/integration/features/latest.feature b/tests/updater-script/scenarios/patch-release/expected/tests/integration/features/latest.feature index f55e0f0f27d..b13123ddc59 100644 --- a/tests/updater-script/scenarios/patch-release/expected/tests/integration/features/latest.feature +++ b/tests/updater-script/scenarios/patch-release/expected/tests/integration/features/latest.feature @@ -13,3 +13,32 @@ Feature: Testing the latest endpoint Then The JSON response is non-empty And Version "34.0.0 RC5" is the latest release And URL to download is "https://download.nextcloud.com/server/prereleases/nextcloud-34.0.0rc5.zip" + + Scenario: Get latest stable version with PHP 8.0 + Given I want to know the latest stable release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest beta version with PHP 8.0 + Given I want to know the latest beta release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest version with invalid PHP version + Given I want to know the latest beta release + And I use PHP "test" + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid PHP version provided" + + Scenario: Get latest version with invalid channel + Given I want to know the latest whatever release + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid channel provided" diff --git a/tests/updater-script/scenarios/rc-bump/expected/tests/integration/features/latest.feature b/tests/updater-script/scenarios/rc-bump/expected/tests/integration/features/latest.feature index 0f012d8181e..61be4844ebb 100644 --- a/tests/updater-script/scenarios/rc-bump/expected/tests/integration/features/latest.feature +++ b/tests/updater-script/scenarios/rc-bump/expected/tests/integration/features/latest.feature @@ -13,3 +13,32 @@ Feature: Testing the latest endpoint Then The JSON response is non-empty And Version "34.0.0 RC6" is the latest release And URL to download is "https://download.nextcloud.com/server/prereleases/nextcloud-34.0.0rc6.zip" + + Scenario: Get latest stable version with PHP 8.0 + Given I want to know the latest stable release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest beta version with PHP 8.0 + Given I want to know the latest beta release + And I use PHP "8.0" + When I send a request latest.php + Then The JSON response is non-empty + And Version "29.0.16" is the latest release + And URL to download is "https://download.nextcloud.com/server/releases/nextcloud-29.0.16.zip" + + Scenario: Get latest version with invalid PHP version + Given I want to know the latest beta release + And I use PHP "test" + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid PHP version provided" + + Scenario: Get latest version with invalid channel + Given I want to know the latest whatever release + When I send a request latest.php + Then The JSON response is non-empty + And I get error "Invalid channel provided"