Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: "Release"

on:
push:
tags:
- "*"

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist"

jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl"
ini-values: "memory_limit=-1"
php-version: "7.4"

- name: "Install dependencies from composer.lock using composer binary provided by system"
run: "composer install ${{ env.COMPOSER_FLAGS }}"

- name: "Run install again using composer binary from source"
run: "bin/composer install ${{ env.COMPOSER_FLAGS }}"

- name: "Validate composer.json"
run: "bin/composer validate"

- name: Build phar file
run: "php -d phar.readonly=0 bin/compile"

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
body: TODO

- name: Upload phar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./composer.phar
asset_name: composer.phar
asset_content_type: application/octet-stream

# This step requires a secret token with `pull` access to composer/docker. The default
# secrets.GITHUB_TOKEN is scoped to this repository only which is not sufficient.
- name: "Open issue @ Docker repository"
uses: actions/github-script@v2
with:
github-token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
script: |
// github.ref value looks like 'refs/tags/TAG', cleanup
const tag = "${{ github.ref }}".replace(/refs\/tags\//, '');
// create new issue on Docker repository
github.issues.create({
owner: "${{ github.repository_owner }}",
repo: "docker",
title: `New Composer tag: ${ tag }`,
body: `https://github.com/${{ github.repository }}/releases/tag/${ tag }`,
});
42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on:
push:
pull_request:

jobs:
tests:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04

strategy:
matrix:
php:
- "5.3"
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: none
coverage: none

- name: Install box
run: make box.phar

- name: Make PHAR
run: make phar

# vim:ft=yaml:et:ts=2:sw=2
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ REV="$2"

## Git


* Setup in your git repo `hooks/post-receive`:

```sh
Expand Down
2 changes: 1 addition & 1 deletion eventum-cvs-hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function main($context)
$commit_msg = cvs_commit_msg($context['stdin']);

// parse the commit message and get all issue numbers we can find
$issues = match_issues($commit_msg);
$issues = match_issues($commit_msg, $context['eventum_url']);
if (!$issues) {
return;
}
Expand Down
23 changes: 18 additions & 5 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,27 @@ function fileparts($abspath)
* parse the commit message and get all issue numbers we can find
*
* @param string $commit_msg
* @param string|null $eventum_url
* @return array
*/
function match_issues($commit_msg)
function match_issues($commit_msg, $eventum_url = null)
{
preg_match_all('/(?:issue|bug) ?:? ?#?(\d+)/i', $commit_msg, $matches);

if (count($matches[1]) > 0) {
return $matches[1];
$url_quoted = $eventum_url ? preg_quote($eventum_url, '/') : '';

preg_match_all("/
(?:
# match issue xxx and bug xxx
(?i:issue|bug)\s*:?\s*#?
|
# match url
{$url_quoted}/view\.php\?id=
)

(?P<issue_id>\d+)
/x", $commit_msg, $matches);

if (count($matches['issue_id']) > 0) {
return $matches['issue_id'];
}

return null;
Expand Down