Skip to content

Commit

Permalink
Merge pull request #3939 from dokuwiki/auto-2023-04-04
Browse files Browse the repository at this point in the history
Release Preparations for 2023-04-04 "Jack Jackrum"
  • Loading branch information
splitbrain committed Apr 4, 2023
2 parents 1e4e476 + ebc5ef0 commit fbc36ac
Show file tree
Hide file tree
Showing 647 changed files with 38,119 additions and 22,094 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,yaml}]
indent_size = 2

[{vendor,inc/phpseclib}/**]
; Use editor default (possible autodetection).
indent_style =
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.ico binary
*.xcf binary

.git export-ignore
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
Expand Down
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
github: splitbrain
patreon: dokuwiki
custom:
- http://donate.dokuwiki.org/
- https://donate.lol/bitcoin:1Dokuw1Ki8dGk4p2hAWZv4TwGj8Ax1Vcqz
188 changes: 188 additions & 0 deletions .github/release.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?php

if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../');
require_once(DOKU_INC . 'vendor/autoload.php');
require_once DOKU_INC . 'inc/load.php';

/**
* Command Line utility to gather and check data for building a release
*/
class Release extends splitbrain\phpcli\CLI
{
const TYPES = ['stable', 'hotfix', 'rc'];

// base URL to fetch raw files from the stable branch
protected $BASERAW = 'https://raw.githubusercontent.com/dokuwiki/dokuwiki/stable/';

/** @inheritdoc */
public function __construct($autocatch = true)
{
parent::__construct($autocatch);

// when running on a clone, use the correct base URL
$repo = getenv('GITHUB_REPOSITORY');
if ($repo) {
$this->BASERAW = 'https://raw.githubusercontent.com/' . $repo . '/stable/';
}
}


protected function setup(\splitbrain\phpcli\Options $options)
{
$options->setHelp('This tool is used to gather and check data for building a release');

$options->registerCommand('new', 'Get environment for creating a new release');
$options->registerOption('type', 'The type of release to build', null, join('|', self::TYPES), 'new');
$options->registerOption('date', 'The date to use for the version. Defaults to today', null, 'YYYY-MM-DD', 'new');
$options->registerOption('name', 'The codename to use for the version. Defaults to the last used one', null, 'codename', 'new');

$options->registerCommand('current', 'Get environment of the current release');
}

protected function main(\splitbrain\phpcli\Options $options)
{
switch ($options->getCmd()) {
case 'new':
$this->prepareNewEnvironment($options);
break;
case 'current':
$this->prepareCurrentEnvironment($options);
break;
default:
echo $options->help();
}
}

/**
* Prepare environment for the current branch
*/
protected function prepareCurrentEnvironment(\splitbrain\phpcli\Options $options)
{
$current = $this->getLocalVersion();
// we name files like the string in the VERSION file, with rc at the front
$current['file'] = ($current['type'] === 'rc' ? 'rc' : '') . $current['date'] . $current['hotfix'];

// output to be piped into GITHUB_ENV
foreach ($current as $k => $v) {
echo "current_$k=$v\n";
}
}

/**
* Prepare environment for creating a new release
*/
protected function prepareNewEnvironment(\splitbrain\phpcli\Options $options)
{
$current = $this->getUpstreamVersion();

// continue if we want to create a new release
$next = [
'type' => $options->getOpt('type'),
'date' => $options->getOpt('date'),
'codename' => $options->getOpt('name'),
'hotfix' => '',
];
if (!$next['type']) $next['type'] = 'stable';
if (!$next['date']) $next['date'] = date('Y-m-d');
if (!$next['codename']) $next['codename'] = $current['codename'];
$next['codename'] = ucwords(strtolower($next['codename']));

if (!in_array($next['type'], self::TYPES)) {
throw new \splitbrain\phpcli\Exception('Invalid release type. Use one of ' . join(', ', self::TYPES));
}

if ($next['type'] === 'hotfix') {
$next['update'] = floatval($current['update']) + 0.1;
$next['codename'] = $current['codename'];
$next['date'] = $current['date'];
$next['hotfix'] = $this->increaseHotfix($current['hotfix']);
} else {
$next['update'] = intval($current['update']) + 1;
}

if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $next['date'])) {
throw new \splitbrain\phpcli\Exception('Invalid date format, use YYYY-MM-DD');
}

if ($current['date'] > $next['date']) {
throw new \splitbrain\phpcli\Exception('Date must be equal or later than the last release');
}

if ($current['type'] === 'rc' && $next['type'] === 'hotfix') {
throw new \splitbrain\phpcli\Exception(
'Cannot create hotfixes for release candidates, create a new RC instead'
);
}

if ($current['type'] === 'stable' && $next['type'] !== 'hotfix' && $current['codename'] === $next['codename']) {
throw new \splitbrain\phpcli\Exception('Codename must be different from the last release');
}

$next['version'] = $next['date'] . ($next['type'] === 'rc' ? 'rc' : $next['hotfix']);
$next['raw'] = ($next['type'] === 'rc' ? 'rc' : '') .
$next['date'] .
$next['hotfix'] .
' "' . $next['codename'] . '"';

// output to be piped into GITHUB_ENV
foreach ($current as $k => $v) {
echo "current_$k=$v\n";
}
foreach ($next as $k => $v) {
echo "next_$k=$v\n";
}
}

/**
* Get current version info from local VERSION file
*
* @return string[]
*/
protected function getLocalVersion()
{
$versioninfo = \dokuwiki\Info::parseVersionString(trim(file_get_contents('VERSION')));
$doku = file_get_contents('doku.php');
if (!preg_match('/\$updateVersion = "(\d+(\.\d+)?)";/', $doku, $m)) {
throw new \Exception('Could not find $updateVersion in doku.php');
}
$versioninfo['update'] = floatval($m[1]);
return $versioninfo;
}

/**
* Get current version info from stable branch
*
* @return string[]
* @throws Exception
*/
protected function getUpstreamVersion()
{
// basic version info
$versioninfo = \dokuwiki\Info::parseVersionString(trim(file_get_contents($this->BASERAW . 'VERSION')));

// update version grepped from the doku.php file
$doku = file_get_contents($this->BASERAW . 'doku.php');
if (!preg_match('/\$updateVersion = "(\d+(\.\d+)?)";/', $doku, $m)) {
throw new \Exception('Could not find $updateVersion in doku.php');
}
$versioninfo['update'] = floatval($m[1]);

return $versioninfo;
}

/**
* Increase the hotfix letter
*
* (max 26 hotfixes)
*
* @param string $hotfix
* @return string
*/
protected function increaseHotfix($hotfix)
{
if (empty($hotfix)) return 'a';
return substr($hotfix, 0, -1) . chr(ord($hotfix) + 1);
}
}

(new Release())->run();
52 changes: 0 additions & 52 deletions .github/version.php

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/deletedFiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow updates the list of deleted files based on the recent changes and creates a pull request.
# It compares the current master with the stable branch and adds all deleted files to the data/deleted.files file
# unless they are already listed there or are excluded from the release archives (export-ignore in .gitattributes).

name: "Update deleted files"
on:
push:
branches:
- master

jobs:
update:
name: Update deleted files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Update deleted files
run: |
for F in $(git diff origin/stable..HEAD --summary | awk '/^ delete/ && $4 !~ /^(VERSION)/ {print $4}'); do
if grep -q "^$F export-ignore" .gitattributes; then
continue
fi
if grep -q "^$F" data/deleted.files; then
continue
fi
echo "$F" >> data/deleted.files
done
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: "Update deleted files"
title: "Update deleted files"
body: "This updates the list of deleted files based on the recent changes."
delete-branch: true
3 changes: 3 additions & 0 deletions .github/workflows/phpCS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- old-stable
pull_request:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
phpcs:
name: PHP CodeSniffer
Expand Down

0 comments on commit fbc36ac

Please sign in to comment.