Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Add ability for the upgrader to self-update #153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
90dd872
NEW Auto compute version number on build.
maxime-rainville Jan 30, 2019
b3fb2a0
UPdate release repo for testing
maxime-rainville Jan 30, 2019
2b73000
Disable al ltest
maxime-rainville Jan 30, 2019
0d5bf00
Load the correct .env file
maxime-rainville Jan 30, 2019
109f4ab
Suppress warning about dependency casing.
maxime-rainville Jan 30, 2019
aad33cc
Restore all the matrix entries and force installation of composer 1.8.0
maxime-rainville Jan 30, 2019
6fedb76
Signed PHAR file.
maxime-rainville Jan 30, 2019
e02d6a0
Remove the signing logic from the build script.
maxime-rainville Jan 30, 2019
fc39e9e
Add a self-update command.
maxime-rainville Jan 30, 2019
10ae28c
Update the "releasing doc" to reflect that its automated now
maxime-rainville Jan 30, 2019
a9ba3c6
Test commit for release.
maxime-rainville Jan 30, 2019
b1a1aae
Update travis config to produce an md5 hash of the phar and keep olde…
maxime-rainville Jan 30, 2019
f3e3cae
Test commit.
maxime-rainville Jan 30, 2019
97c5402
Correct typo in travis config
maxime-rainville Jan 30, 2019
a575c84
fix if statement in travis config
maxime-rainville Jan 30, 2019
2f8429c
Getting the if statement working.
maxime-rainville Jan 30, 2019
ed96383
Tweak logic to generate MD5 hash
maxime-rainville Jan 30, 2019
ad6f191
Tweak the way we generate the md5 hash
maxime-rainville Jan 31, 2019
72a99d2
tweak travis config.
maxime-rainville Jan 31, 2019
c68c782
checkout the right branch
maxime-rainville Jan 31, 2019
2bc4935
Remove debug code.
maxime-rainville Jan 31, 2019
2619569
Tweak self-update to display a message after the first run.
maxime-rainville Jan 31, 2019
6aa86ce
Re-enable the test matrix
maxime-rainville Jan 31, 2019
5f66620
Correct doc.
maxime-rainville Jan 31, 2019
cd10158
Implement feedback from peer review.
maxime-rainville Feb 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
@@ -0,0 +1 @@
UPGRADER_VERSION=1.3.0
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
/vendor/
upgrade-code.phar
.env
.idea
14 changes: 10 additions & 4 deletions .travis.yml
Expand Up @@ -19,7 +19,7 @@ matrix:
- php: 7.3
env:
- SYMFONY="^4"
- php: 7.2
- php: 7.1
env:
- RELEASE=1

Expand All @@ -43,9 +43,15 @@ script:
- if [[ $LINT_TEST ]]; then composer run-script lint; fi

before_deploy:
- if [[ ! -f ./release/upgrade-code.phar ]]; then php build.php; fi
- mkdir -p ./release
- if [[ -f ./upgrade-code.phar ]]; then mv upgrade-code.phar ./release/; fi
- if [ -d "release" ]; then rm -rf release ; fi
- git clone --single-branch --branch gh-pages https://github.com/$TRAVIS_REPO_SLUG.git release
- echo "UPGRADER_VERSION=$TRAVIS_TAG" > .env
bergice marked this conversation as resolved.
Show resolved Hide resolved
- php build.php
- if [[ ! -f ./upgrade-code.phar ]]; then exit 1; fi
- mv upgrade-code.phar ./release/
- mkdir release/$TRAVIS_TAG
- cp release/upgrade-code.phar release/$TRAVIS_TAG/upgrade-code.phar
- (cd release && md5sum upgrade-code.phar */upgrade-code.phar > MD5SUM)

deploy:
- provider: releases
Expand Down
22 changes: 21 additions & 1 deletion bin/upgrade-code
Expand Up @@ -18,11 +18,30 @@ foreach ($paths as $path) {
}

use SilverStripe\Upgrader\Console as Upgrader;
use SilverStripe\Upgrader\Util\UpdateChecker;
use Symfony\Component\Console\Application;
use M1\Env\Parser;

// Get Upgrader version from environment file
$version = '1.4.0';
bergice marked this conversation as resolved.
Show resolved Hide resolved
$dotEnvPath = __DIR__ . '/../.env';
if (file_exists($dotEnvPath)) {
$env = new Parser(file_get_contents($dotEnvPath));
$envVars = $env->getContent();
if (isset($envVars['UPGRADER_VERSION'])) {
$version = $envVars['UPGRADER_VERSION'];
}
}

$nextVersion = UpdateChecker::getShowNewVersion($version);
if ($nextVersion && $nextVersion != $version) {
echo "A new version of the silverstripe upgrader is available. " .
"Run the `self-update` command to get version $nextVersion. \n\n";
}

$application = new Application();
$application->setName("SilverStripe Upgrader");
$application->setVersion('1.3.0');
$application->setVersion($version);
$application->add(new Upgrader\UpgradeCommand());
$application->add(new Upgrader\AddNamespaceCommand());
$application->add(new Upgrader\DoctorCommand());
Expand All @@ -32,4 +51,5 @@ $application->add(new Upgrader\RecomposeCommand());
$application->add(new Upgrader\ReorganiseCommand());
$application->add(new Upgrader\WebrootCommand());
$application->add(new Upgrader\AllInOneCommand());
$application->add(new Upgrader\SelfUpdateCommand());
$application->run();
2 changes: 2 additions & 0 deletions build.php
Expand Up @@ -26,6 +26,7 @@
$fs->mirror(PACKAGE_ROOT . 'src', BUILD_FOLDER . '/src');
$fs->copy(PACKAGE_ROOT . 'composer.json', BUILD_FOLDER . '/composer.json');
$fs->copy(PACKAGE_ROOT . 'composer.lock', BUILD_FOLDER . '/composer.lock');
$fs->copy(PACKAGE_ROOT . '.env', BUILD_FOLDER . '/.env');

// Install dependencies
$composerStatement = sprintf(
Expand All @@ -38,6 +39,7 @@
// Compile the executable
$compiler = new Compiler(BUILD_FOLDER);
$compiler->addIndexFile('bin/upgrade-code');
$compiler->addFile('.env');
$compiler->addDirectory('src');
$compiler->addDirectory('vendor');

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -21,14 +21,15 @@
"composer/semver": "^1.4",
"guzzlehttp/guzzle": "^6.3",
"symfony/process": "^3.2 || ^4",
"symfony/filesystem": "^3.2 || ^4"
"symfony/filesystem": "^3.2 || ^4",
"padraic/phar-updater": "^1.0"
},
"bin": [
"bin/upgrade-code"
],
"require-dev": {
"phpunit/phpunit": "^7",
"mikey179/vfsStream": "^1.6",
"mikey179/vfsstream": "^1.6",
"secondtruth/phar-compiler": "^1.1",
"roave/security-advisories": "dev-master"
},
Expand Down
201 changes: 189 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions doc/en/releasing.md
@@ -1,12 +1,15 @@
# Releasing a new verison of the upgrader
# Releasing a new version of the upgrader

This document is aimed for internal consumption. To release a new version of the upgrader follow these steps.
This document is aimed for internal consumption.

Upgrader releases are now automated with a travis build. When the tag gets built on travis, the build script will automatically run and build a PHAR executable. The PHAR executable will be attached back to the release in GitHub and publish to this repo's github pages.


To release a new version of the upgrader follow these steps:

1. On your local system, clone the upgrader codebase. You need to work of the `master` branch from this point.
2. Increment the version number in `src/upgrade-code`, commit your changes and push them back up to GitHub.
3. Call `php build.php` on the command line. This will build the upgrader as a PHAR file.
4. Move `upgrade-code.phar` to a temporary folder.
5. Switch to the `gh-pages` branch. e.g.: `git checkout gh-pages`
6. Overwrite the existing `upgrade-code.phar` with the one you built in step 3.
7. Commit your changes to the `gh-pages` branch and push them up to GitHub.
8. Create a new release on GitHub and attach `upgrade-code.phar` to it.
2. Increment the version number in `src/upgrade-code`, commit your changes and push them back up to GitHub. This will only be used for people installing the upgrader with Composer. The PHAR executable gets its version number from an environment file built into it.
bergice marked this conversation as resolved.
Show resolved Hide resolved
3. In GitHub create a new release. You should provide detail about what has changed since the last release, referencing PRs ideally.
4. The release won't have a PHAR executable attached to it initially. You'll have to do wait for travis to complete its build. If that build fails for whatever reason, you can delete the release and unset the tag. Fix the issue and re-release the tag.

Note that we don't do patch releases for older minor releases. People are expected to always use the latest version.