-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1052 from nextcloud/chore/update-built-in-Talk
chore: update Build-in Talk script and CI
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
name: Update Built-in Talk | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-built-in-talk: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
|
||
- name: Run update-built-in-talk.mjs | ||
id: update | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Execute the script and capture the output | ||
stdout=$(npx -y zx ./scripts/update-built-in-talk.mjs) | ||
# Pass the result to the next steps | ||
echo "stdout<<EOF" >> $GITHUB_OUTPUT | ||
echo "$stdout" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Print result | ||
run: echo "${{ steps.update.outputs.stdout }}" | ||
|
||
- name: Create Pull Request | ||
if: steps.update.outcome == 'success' | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
commit-message: 'build: update built-in Talk version' | ||
signoff: true | ||
branch: 'build/update-built-in-talk-version' | ||
delete-branch: true | ||
title: 'build: update built-in Talk versions' | ||
body: | | ||
## Update Built-in Talk Version | ||
${{ steps.update.outputs.stdout }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
/** | ||
* Is version A greater than version B? | ||
* @param {string} versionA - Version A | ||
* @param {string} versionB - Version B | ||
* @return {boolean} - Whether version A greater than version B | ||
*/ | ||
export function semverGt(versionA, versionB) { | ||
const parse = (v) => [...v.split('-')[0].split('.').map((v) => parseInt(v)), v.split('-')[1] || 'z'] | ||
const a = parse(versionA) | ||
const b = parse(versionB) | ||
for (let i = 0; i < a.length; i++) { | ||
if (a[i] > b[i]) { | ||
return true | ||
} else if (a[i] < b[i]) { | ||
return false | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { semverGt } from './semver.utils.mjs' | ||
|
||
if (os.platform() === 'win32') { | ||
usePwsh() | ||
} | ||
|
||
// Verify that GitHub CLI is available and authenticated | ||
await $`gh auth status` | ||
|
||
// Read the current version | ||
const packageJsonPath = path.join(__dirname, '../package.json') | ||
const packageJson = await fs.readJson(packageJsonPath) | ||
|
||
const currentBeta = packageJson.talk.beta | ||
const currentStable = packageJson.talk.stable | ||
|
||
// Check the latest releases | ||
const latestStable = (await $`gh release list -R nextcloud-releases/spreed --json tagName --limit=1 --exclude-drafts --exclude-pre-releases`.json())[0].tagName | ||
const latestBeta = (await $`gh release list -R nextcloud-releases/spreed --json tagName --limit=1 --exclude-drafts`.json())[0].tagName | ||
|
||
echo`Stable:` | ||
echo`- Current: ${currentStable}` | ||
echo`- Latest: ${latestStable}` | ||
echo`` | ||
echo`Beta:` | ||
echo`- Current: ${currentBeta}` | ||
echo`- Latest: ${latestBeta}` | ||
echo`` | ||
|
||
// Update the version if necessary | ||
if (semverGt(latestStable, currentStable)) { | ||
echo`Updating stable from ${currentStable} to ${latestStable}` | ||
packageJson.talk.stable = latestStable | ||
} | ||
|
||
if (semverGt(latestBeta, currentBeta)) { | ||
echo`Updating beta from ${currentBeta} to ${latestBeta}` | ||
packageJson.talk.beta = latestBeta | ||
} | ||
|
||
// Write package.json | ||
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 }) |