summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamtamtam <[email protected]>2020-12-07 21:51:18 +0500
committerparamtamtam <[email protected]>2020-12-07 21:51:35 +0500
commit5d62c5508e820248fe150aeda23b85225bc23d04 (patch)
tree1ff6b04cc014918bf8ee0e5fba0d7fdc971217a9
parentb22078ce707d21ac17ea1727a4174c44ef57ae69 (diff)
GitHub action added, /bin/rr updated
-rw-r--r--.github/workflows/ci-release.yml109
-rw-r--r--.github/workflows/codeql-analysis.yml2
-rwxr-xr-xbin/rr25
-rw-r--r--composer.json3
4 files changed, 123 insertions, 16 deletions
diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml
new file mode 100644
index 00000000..7a15a083
--- /dev/null
+++ b/.github/workflows/ci-release.yml
@@ -0,0 +1,109 @@
+name: release
+
+on:
+ release: # Docs: <https://help.github.com/en/articles/events-that-trigger-workflows#release-event-release>
+ types: [published]
+
+jobs:
+ build:
+ name: Build for ${{ matrix.os }} (${{ matrix.arch }}, ${{ matrix.compiler }})
+ runs-on: ubuntu-20.04
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [linux, freebsd, darwin]
+ compiler: [gcc]
+ archiver: [tar]
+ arch: [amd64]
+ include:
+ - os: windows # include build for windows directly
+ compiler: gcc
+ archiver: zip
+ arch: amd64
+ - compiler: musl-gcc # more info: <https://musl.libc.org/>
+ archiver: tar
+ arch: amd64
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: 1.15.5
+
+ - name: Check out code
+ uses: actions/checkout@v2
+
+ - name: Install musl
+ if: matrix.compiler == 'musl-gcc'
+ run: sudo apt-get install -y musl-tools
+
+ - name: Download dependencies
+ run: go mod download # `-x` means "verbose" mode
+
+ - name: Generate compiler values
+ id: values
+ run: |
+ echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`"
+ echo "::set-output name=timestamp::`date +%FT%T%z`"
+ echo "::set-output name=binary-name::rr`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`"
+
+ - name: Compile binary file
+ env:
+ GOOS: ${{ matrix.os }}
+ GOARCH: ${{ matrix.arch }}
+ CC: ${{ matrix.compiler }}
+ LDFLAGS: >-
+ -s
+ -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${{ steps.values.outputs.version }}
+ -X github.com/spiral/roadrunner/cmd/rr/cmd.BuildTime=${{ steps.values.outputs.timestamp }}
+ run: |
+ go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/rr/main.go
+ stat "./${{ steps.values.outputs.binary-name }}"
+
+ - name: Generate distributive directory name
+ id: dist-dir
+ run: >
+ echo "::set-output name=name::roadrunner-${{ steps.values.outputs.version }}-$(
+ [ ${{ matrix.os }} != '' ] && echo '${{ matrix.os }}' || echo 'unknown'
+ )$(
+ [ ${{ matrix.compiler }} = 'musl-gcc' ] && echo '-musl'
+ )-${{ matrix.arch }}"
+
+ - name: Generate distributive archive name
+ id: dist-arch
+ run: >
+ echo "::set-output name=name::${{ steps.dist-dir.outputs.name }}.$(
+ case ${{ matrix.archiver }} in
+ zip) echo 'zip';;
+ tar) echo 'tar.gz';;
+ *) exit 10;
+ esac
+ )"
+
+ - name: Create distributive
+ run: |
+ mkdir ${{ steps.dist-dir.outputs.name }}
+ mv "./${{ steps.values.outputs.binary-name }}" ./${{ steps.dist-dir.outputs.name }}/
+ cp ./README.md ./CHANGELOG.md ./LICENSE ./${{ steps.dist-dir.outputs.name }}/
+
+ - name: Pack distributive using tar
+ if: matrix.archiver == 'tar'
+ run: tar -zcf "${{ steps.dist-arch.outputs.name }}" "${{ steps.dist-dir.outputs.name }}"
+
+ - name: Pack distributive using zip
+ if: matrix.archiver == 'zip'
+ run: zip -r -q "${{ steps.dist-arch.outputs.name }}" "${{ steps.dist-dir.outputs.name }}"
+
+ - uses: actions/upload-artifact@v2
+ with:
+ name: ${{ steps.dist-dir.outputs.name }}
+ path: ${{ steps.dist-arch.outputs.name }}
+ if-no-files-found: error
+ retention-days: 30
+
+ - name: Upload binaries to release
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: ${{ steps.dist-arch.outputs.name }}
+ asset_name: ${{ steps.dist-arch.outputs.name }}
+ tag: ${{ github.ref }}
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 1c90e4a4..75e40110 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -47,7 +47,7 @@ jobs:
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
- # By default, queries listed here will override any specified in a config file.
+ # By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
diff --git a/bin/rr b/bin/rr
index e3e2c1d0..68e38591 100755
--- a/bin/rr
+++ b/bin/rr
@@ -11,7 +11,8 @@ declare(strict_types=1);
foreach ([
__DIR__ . '/../../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
- __DIR__ . '/vendor/autoload.php'
+ __DIR__ . '/vendor/autoload.php',
+ __DIR__ . '/../vendor_php/autoload.php'
] as $file) {
if (file_exists($file)) {
define('RR_COMPOSER_INSTALL', $file);
@@ -51,28 +52,24 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
+use function Couchbase\defaultDecoder;
class RRHelper
{
/**
- * Returns version of RoadRunner based on build.sh file
+ * Returns version of RoadRunner based on current package version.
*
- * @return string Version of RoadRunner
- * @throws Exception
+ * @return string Version of RoadRunner (eg.: `1.8.0`)
*/
public static function getVersion(): string
{
- $file = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'build.sh';
- $fileResource = fopen($file, 'r') or die(1);
- while (!feof($fileResource)) {
- $line = fgets($fileResource, 4096);
- $matches = [];
- if (preg_match("/^RR_VERSION=(.*)/", $line, $matches)) {
- return trim($matches[1]);
- }
+ $version = \PackageVersions\Versions::getVersion('spiral/roadrunner');
+
+ if (\is_int($delimiter_position = \mb_strpos($version, '@'))) {
+ $version = \mb_substr($version, 0, (int) $delimiter_position);
}
- fclose($fileResource);
- throw new Exception("Can't find version of RoadRunner");
+
+ return \ltrim($version, 'vV');
}
/**
diff --git a/composer.json b/composer.json
index 3ce86754..17f8beee 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,8 @@
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"symfony/console": "^2.5.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
- "laminas/laminas-diactoros": "^1.3 || ^2.0"
+ "laminas/laminas-diactoros": "^1.3 || ^2.0",
+ "ocramius/package-versions": "^1.5"
},
"config": {
"vendor-dir": "vendor_php"