From fd5e97d48c3b9e9f1d05c1f002f08362ed2f6b43 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Wed, 15 Nov 2023 22:16:29 +0100 Subject: [PATCH] introduce nightly builds and nightly-update-channel Signed-off-by: Michael Kaufmann --- .github/workflows/build-mariadb.yml | 109 ++++++++++++++++++-------- actions/admin/settings/120.system.php | 3 +- lib/Froxlor/Api/Commands/Froxlor.php | 4 +- lib/Froxlor/Cli/UpdateCommand.php | 4 +- lib/Froxlor/Install/AutoUpdate.php | 12 ++- lng/en.lng.php | 1 + 6 files changed, 92 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build-mariadb.yml b/.github/workflows/build-mariadb.yml index 7e95b55909..c1b71cffb7 100644 --- a/.github/workflows/build-mariadb.yml +++ b/.github/workflows/build-mariadb.yml @@ -1,5 +1,5 @@ name: Froxlor-CI-MariaDB -on: ['push', 'pull_request', 'create'] +on: [ 'push', 'pull_request', 'create' ] jobs: froxlor: @@ -8,8 +8,8 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.4', '8.2'] - mariadb-version: [10.11, 10.5] + php-versions: [ '7.4', '8.2' ] + mariadb-version: [ 10.11, 10.5 ] steps: - name: Checkout uses: actions/checkout@v3 @@ -49,33 +49,76 @@ jobs: - name: Run testing run: ant quick-build -# - name: irc push -# uses: rectalogic/notify-irc@v1 -# if: github.event_name == 'push' -# with: -# channel: "#froxlor" -# server: "irc.libera.chat" -# nickname: froxlor-ci -# message: | -# ${{ github.actor }} pushed ${{ github.event.ref }} ${{ github.event.compare }} -# ${{ join(github.event.commits.*.message) }} - -# - name: irc pull request -# uses: rectalogic/notify-irc@v1 -# if: github.event_name == 'pull_request' -# with: -# channel: "#froxlor" -# server: "irc.libera.chat" -# nickname: froxlor-ci -# message: | -# ${{ github.actor }} opened PR ${{ github.event.pull_request.html_url }} - -# - name: irc tag created -# uses: rectalogic/notify-irc@v1 -# if: github.event_name == 'create' && github.event.ref_type == 'tag' -# with: -# channel: "#froxlor" -# server: "irc.libera.chat" -# nickname: froxlor-ci -# message: | -# ${{ github.actor }} tagged ${{ github.repository }} ${{ github.event.ref }} + nightly: + name: Create nightly/testing tarball + runs-on: ubuntu-latest + needs: froxlor + if: ${{ github.event_name == 'push' }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP with PECL extension + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + tools: composer:v2 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.x' + - name: Install npm dependencies + run: npm install + + - name: Build assets + run: npm run build + working-directory: . + + - name: Setting file/directory permissions + run: | + find -exec chmod ugo+r,u+w,go-w {} \; + find -type f -exec chmod ugo-x {} \; + find -type d -exec chmod ugo+x {} \; + chmod 0755 bin/froxlor-cli + + - name: Remove vcs and unneeded files + run: | + rm .gitignore + rm .editorconfig + rm -rf node_modules + rm composer.json + rm composer.lock + rm package.json + rm package-lock.json + rm *.xml + rm vite.config.js + + - name: Create empty index.html in built assets directory + run: | + touch templates/Froxlor/build/index.html + touch templates/Froxlor/build/assets/index.html + + - name: Set outputs + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Set nightly branding + run: | + sed -i "s/const BRANDING = '';/const BRANDING = '+nightly.${{steps.vars.outputs.sha_short}}';/" lib/Froxlor/Froxlor.php + zip -r froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip . -x "*.git*" + sha256sum froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip > froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip.sha256 + mkdir dist + mv froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip dist/ + mv froxlor-nightly.${{steps.vars.outputs.sha_short}}.zip.sha256 dist/ + + - name: Deploy nightly to server + uses: easingthemes/ssh-deploy@v3.4.3 + env: + ARGS: "-rltDzvO --chown=${{ secrets.WEB_USER }}:${{ secrets.WEB_USER }}" + SOURCE: "dist/" + SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + TARGET: "${{ secrets.REMOTE_TARGET }}" diff --git a/actions/admin/settings/120.system.php b/actions/admin/settings/120.system.php index 09f3da7daa..f7af4dbc58 100644 --- a/actions/admin/settings/120.system.php +++ b/actions/admin/settings/120.system.php @@ -130,7 +130,8 @@ 'default' => 'stable', 'select_var' => [ 'stable' => lng('serversettings.uc_stable'), - 'testing' => lng('serversettings.uc_testing') + 'testing' => lng('serversettings.uc_testing'), + 'nightly' => lng('serversettings.uc_nightly') ], 'save_method' => 'storeSettingField', 'advanced_mode' => true diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index eaa657c1b8..2ae0ab45e5 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -82,7 +82,7 @@ public function checkUpdate() if ($aucheck == 1) { // anzeige über version-status mit ggfls. formular // zum update schritt #1 -> download - $text = lng('update.uc_newinfo', [(Settings::Get('system.update_channel') == 'testing' ? 'testing ' : ''), AutoUpdate::getFromResult('version'), $this->version]); + $text = lng('update.uc_newinfo', [(Settings::Get('system.update_channel') != 'stable' ? Settings::Get('system.update_channel').' ' : ''), AutoUpdate::getFromResult('version'), $this->version]); $response = [ 'isnewerversion' => (int) !AutoUpdate::getFromResult('has_latest'), 'version' => $this->version, @@ -91,7 +91,7 @@ public function checkUpdate() 'additional_info' => AutoUpdate::getFromResult('info'), 'aucheck' => $aucheck ]; - } else if ($aucheck < 0 || $aucheck > 1) { + } elseif ($aucheck < 0 || $aucheck > 1) { // errors if ($aucheck < 0) { $errmsg = AutoUpdate::getLastError(); diff --git a/lib/Froxlor/Cli/UpdateCommand.php b/lib/Froxlor/Cli/UpdateCommand.php index 56efc4af8a..67e47beb3e 100644 --- a/lib/Froxlor/Cli/UpdateCommand.php +++ b/lib/Froxlor/Cli/UpdateCommand.php @@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } // there is a new version if ($input->getOption('check-only')) { - $text = lng('update.uc_newinfo', [(Settings::Get('system.update_channel') == 'testing' ? 'testing ' : ''), AutoUpdate::getFromResult('version'), Froxlor::VERSION]); + $text = lng('update.uc_newinfo', [(Settings::Get('system.update_channel') != 'stable' ? Settings::Get('system.update_channel').' ' : ''), AutoUpdate::getFromResult('version'), Froxlor::VERSION]); } else { $text = lng('admin.newerversionavailable') . ' ' . lng('admin.newerversiondetails', [AutoUpdate::getFromResult('version'), Froxlor::VERSION]); } @@ -199,7 +199,7 @@ private function mailNotify(InputInterface $input, OutputInterface $output) if ($input->getOption('mail-notify')) { $last_check_version = Settings::Get('system.update_notify_last'); if (Update::versionInUpdate($last_check_version, AutoUpdate::getFromResult('version'))) { - $text = lng('update.uc_newinfo', [(Settings::Get('system.update_channel') == 'testing' ? 'testing ' : ''), AutoUpdate::getFromResult('version'), Froxlor::VERSION]); + $text = lng('update.uc_newinfo', [(Settings::Get('system.update_channel') != 'stable' ? Settings::Get('system.update_channel').' ' : ''), AutoUpdate::getFromResult('version'), Froxlor::VERSION]); $mail = new Mailer(true); $mail->Body = $text; $mail->Subject = "[froxlor] " . lng('update.notify_subject'); diff --git a/lib/Froxlor/Install/AutoUpdate.php b/lib/Froxlor/Install/AutoUpdate.php index ce896b89da..88b10c4697 100644 --- a/lib/Froxlor/Install/AutoUpdate.php +++ b/lib/Froxlor/Install/AutoUpdate.php @@ -51,13 +51,13 @@ class AutoUpdate /** * returns status about whether there is a newer version - * + * * 0 = no new version available * 1 = new version available * -1 = remote error message * >1 = local error message * - * @return int + * @return int */ public static function checkVersion(): int { @@ -68,6 +68,12 @@ public static function checkVersion(): int $channel = ''; if (Settings::Get('system.update_channel') == 'testing') { $channel = '/testing'; + } elseif (Settings::Get('system.update_channel') == 'nightly') { + if (empty(Froxlor::BRANDING)) { + $channel = '/nightly.0000000'; + } else { + $channel = '/' . substr(Froxlor::BRANDING, 1); + } } $latestversion = HttpClient::urlGet(self::UPDATE_URI . Froxlor::VERSION . $channel, true, 3); } catch (Exception $e) { @@ -81,7 +87,7 @@ public static function checkVersion(): int if (!empty(self::$latestversion['error']) && self::$latestversion['error']) { $result = -1; self::$lasterror = self::$latestversion['message']; - } else if (isset(self::$latestversion['has_latest']) && self::$latestversion['has_latest'] == false) { + } elseif (isset(self::$latestversion['has_latest']) && self::$latestversion['has_latest'] == false) { $result = 1; } } diff --git a/lng/en.lng.php b/lng/en.lng.php index 5d86329ba9..6c726cb270 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -2210,6 +2210,7 @@ ], 'uc_stable' => 'stable', 'uc_testing' => 'testing', + 'uc_nightly' => 'nightly', 'traffictool' => [ 'toolselect' => 'Traffic analyzer', 'webalizer' => 'Webalizer',