Skip to content

Commit

Permalink
introduce nightly builds and nightly-update-channel
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Nov 15, 2023
1 parent 64a9fb1 commit fd5e97d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 41 deletions.
109 changes: 76 additions & 33 deletions .github/workflows/build-mariadb.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Froxlor-CI-MariaDB
on: ['push', 'pull_request', 'create']
on: [ 'push', 'pull_request', 'create' ]

jobs:
froxlor:
Expand All @@ -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
Expand Down Expand Up @@ -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/[email protected]
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 }}"
3 changes: 2 additions & 1 deletion actions/admin/settings/120.system.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/Froxlor/Api/Commands/Froxlor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions lib/Froxlor/Cli/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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');
Expand Down
12 changes: 9 additions & 3 deletions lib/Froxlor/Install/AutoUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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) {
Expand All @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions lng/en.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -2210,6 +2210,7 @@
],
'uc_stable' => 'stable',
'uc_testing' => 'testing',
'uc_nightly' => 'nightly',
'traffictool' => [
'toolselect' => 'Traffic analyzer',
'webalizer' => 'Webalizer',
Expand Down

0 comments on commit fd5e97d

Please sign in to comment.