Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit ea2d71b

Browse files
authored
Add releasing instructions and build the ext/package.xml from a template (#29)
1 parent 082650b commit ea2d71b

6 files changed

Lines changed: 193 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Currently implemented reporters:
6060

6161
### Sampling Rate
6262

63-
By default we attempt to trace all requests. This is not ideal as a little bit of
64-
latency and require more memory for requests that are traced. To trace a sampling
63+
By default we attempt to trace all requests. This is not ideal as it adds a little bit of
64+
latency and require more memory for requests that are traced. To trace only a sampling
6565
of requests, configure a sampler.
6666

6767
The preferred sampler is the `QpsSampler` (Queries Per Second). This sampler implementation
@@ -168,6 +168,10 @@ Contributions to this library are always welcome and highly encouraged.
168168

169169
See [CONTRIBUTING](CONTRIBUTING.md) for more information on how to get started.
170170

171+
## Releasing
172+
173+
See [RELEASING](RELEASING.md) for more information on releasing new versions.
174+
171175
## License
172176

173177
Apache 2.0 - See [LICENSE](LICENSE) for more information.

RELEASING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Releasing OpenCensus PHP
2+
3+
The PHP library and extension are released independently of each other.
4+
5+
## Packagist Package
6+
7+
1. Create a GitHub release.
8+
9+
1. Click `Update` from the admin view of the [opencensus/opencensus][packagist] package.
10+
11+
## PECL Extension
12+
13+
1. Update the `PHP_OPENCENSUS_VERSION` package version constant in `php_opencensus.h`.
14+
15+
1. Update the `releases.yaml` file with a new release and description.
16+
17+
1. Run the extension release script:
18+
19+
`php ext_release.php > ext/package.xml`
20+
21+
1. Go to the extension directory:
22+
23+
`cd ext`
24+
25+
1. Build a PEAR package archive.
26+
27+
`pear package`
28+
29+
1. Upload the new release to PECL from the [admin console][pecl-upload].
30+
31+
[packagist]: https://packagist.org/packages/opencensus/opencensus
32+
[pecl-upload]: https://pecl.php.net/release-upload.php

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"require-dev": {
2121
"phpunit/phpunit": "4.8.*",
2222
"squizlabs/php_codesniffer": "2.*",
23-
"google/cloud-trace": "^0.3"
23+
"google/cloud-trace": "^0.3",
24+
"twig/twig": "~2.0",
25+
"symfony/yaml": "~3.3"
2426
},
2527
"suggest": {
2628
"ext-opencensus": "Enable tracing arbitrary functions.",

ext/releases.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
releases:
2+
- date: '2017-08-14'
3+
time: 16:47:07
4+
version: 0.0.1
5+
stability: devel
6+
notes: First dev release
7+
8+
- date: '2017-08-15'
9+
time: 16:27:07
10+
version: 0.0.2
11+
stability: devel
12+
notes: |-
13+
- Fix builds for 32-bit architecture (#15)
14+
- Fix windows builds (#17)

scripts/ext_release.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright 2017 OpenCensus Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
require(__DIR__ . '/../vendor/autoload.php');
18+
19+
use Symfony\Component\Yaml\Yaml;
20+
21+
class ReleaseBuilder
22+
{
23+
private $releases;
24+
private $template;
25+
26+
public function __construct($yamlPath)
27+
{
28+
$loader = new Twig_Loader_Filesystem(__DIR__ . '/templates');
29+
$twig = new Twig_Environment($loader);
30+
$this->template = $twig->load('package.xml');
31+
$this->releases = Yaml::parse(file_get_contents($yamlPath))['releases'];
32+
}
33+
34+
public function toXml()
35+
{
36+
$lastRelease = $this->releases[count($this->releases) - 1];
37+
38+
$srcfiles = [
39+
'config.m4',
40+
'config.w32'
41+
];
42+
$srcfiles += array_map('basename', glob(__DIR__ . '/../ext/*.{c,h}', GLOB_BRACE));
43+
44+
// this file is generated by autoconf, skip it
45+
$srcfiles = array_diff($srcfiles, ['config.h']);
46+
47+
$testfiles = [
48+
'common.phpt'
49+
];
50+
$testfiles += array_map('basename', glob(__DIR__ . '/../ext/tests/*.phpt'));
51+
52+
return $this->template->render([
53+
'releases' => $this->releases,
54+
'testfiles' => $testfiles,
55+
'srcfiles' => $srcfiles,
56+
'lastRelease' => $lastRelease
57+
]);
58+
}
59+
}
60+
61+
$releaseBuilder = new ReleaseBuilder(__DIR__ . '/../ext/releases.yaml');
62+
echo $releaseBuilder->toXml();
63+
64+
?>

scripts/templates/package.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package packagerversion="1.9.5" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
3+
<name>opencensus</name>
4+
<channel>pecl.php.net</channel>
5+
<summary>A stats collection and distributed tracing framework</summary>
6+
<description>OpenCensus is a open source, distributed tracing system that allows you to collect latency data and report it to any trace aggregation system such as Zipkin or Stackdriver Trace.
7+
8+
This extension allows you to easily gather latency and other metadata by watching for targeted function and method invocations without needing to inject code into the libraries.</description>
9+
<lead>
10+
<name>Jeff Ching</name>
11+
<user>chingor</user>
12+
<email>chingor@google.com</email>
13+
<active>yes</active>
14+
</lead>
15+
<date>{{ lastRelease.date }}</date>
16+
<time>{{ lastRelease.time }}</time>
17+
<version>
18+
<release>{{ lastRelease.version }}</release>
19+
<api>{{ lastRelease.version }}</api>
20+
</version>
21+
<stability>
22+
<release>{{ lastRelease.stability }}</release>
23+
<api>{{ lastRelease.stability }}</api>
24+
</stability>
25+
<license>Apache 2.0</license>
26+
<notes>{{ lastRelease.notes }}</notes>
27+
<contents>
28+
<dir baseinstalldir="/" name="/">
29+
{% for srcfile in srcfiles %}
30+
<file baseinstalldir="/" name="{{srcfile}}" role="src" />
31+
{% endfor %}
32+
33+
<file name="README.md" role="doc" />
34+
<file name="LICENSE" role="doc" />
35+
36+
<dir name="tests">
37+
{% for testfile in testfiles %}
38+
<file name="{{ testfile }}" role="test" />
39+
{% endfor %}
40+
</dir>
41+
</dir>
42+
</contents>
43+
<dependencies>
44+
<required>
45+
<php>
46+
<min>7.0.0</min>
47+
</php>
48+
<pearinstaller>
49+
<min>1.4.0</min>
50+
</pearinstaller>
51+
</required>
52+
</dependencies>
53+
<providesextension>opencensus</providesextension>
54+
<extsrcrelease />
55+
<changelog>
56+
{% for release in releases %}
57+
<release>
58+
<version>
59+
<release>{{ release.version }}</release>
60+
<api>{{ release.version }}</api>
61+
</version>
62+
<stability>
63+
<release>{{ release.stability }}</release>
64+
<api>{{ release.stability }}</api>
65+
</stability>
66+
<date>{{ release.date }}</date>
67+
<license>Apache 2.0</license>
68+
<notes>
69+
{{ release.notes }}
70+
</notes>
71+
</release>
72+
{% endfor %}
73+
</changelog>
74+
</package>

0 commit comments

Comments
 (0)