Skip to content

Commit 080587c

Browse files
authored
Add support for automatic signing (#805)
* Add support for automatic signing * Add composer install * Fetch depth * Update release * Do not build on PR
1 parent 370487b commit 080587c

4 files changed

Lines changed: 50 additions & 10 deletions

File tree

.github/workflows/release-phar.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,46 @@ jobs:
1212
steps:
1313
- name: Checkout code
1414
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
1517

1618
- name: Set PHP 7.3
1719
uses: shivammathur/setup-php@v2
1820
with:
1921
php-version: '7.3'
2022

23+
-
24+
name: "Composer install"
25+
uses: "ramsey/composer-install@v1"
26+
with:
27+
composer-options: "--no-scripts --no-dev"
28+
2129
- name: Compile phpbench.phar
22-
run: |
23-
composer install
24-
wget https://github.com/box-project/box/releases/download/3.9.1/box.phar
25-
php box.phar compile -c box.json.gh-release
30+
run: bin/build-phar.sh
31+
env:
32+
GPG_SIGNING: 1
33+
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
34+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
2635

2736
- name: Check existence of compiled .phar
28-
run: test -e phpbench.phar && exit 0 || exit 10
37+
run: test -e build/phpbench.phar && exit 0 || exit 10
2938

30-
- name: Upload to Release
39+
- name: "Upload PHAR to Release"
3140
uses: actions/upload-release-asset@v1
3241
env:
3342
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3443
with:
3544
upload_url: ${{ github.event.release.upload_url }}
36-
asset_path: ./phpbench.phar
45+
asset_path: ./build/phpbench.phar
3746
asset_name: phpbench.phar
3847
asset_content_type: application/octet-stream
48+
49+
- name: "Attach signature to Release"
50+
uses: actions/upload-release-asset@v1
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
upload_url: ${{ steps.create-release.outputs.upload_url }}
55+
asset_path: ./build/phpbench.phar.asc
56+
asset_name: phpbench.phar.asc
57+
asset_content_type: application/pgp-signature

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/composer.lock
22
/vendor
33
/docs/build
4+
/build
45
/.phpbench.sqlite
56
/phpunit.xml
67
/.travis/phpbench-phar-private.pem

bin/build-phar.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
mkdir -p build
6+
cd build
7+
8+
wget -O box.phar https://github.com/box-project/box/releases/download/3.11.1/box.phar
9+
php box.phar compile -c ../box.json.gh-release
10+
11+
if [[ "$GPG_SIGNING" != '' ]] ; then
12+
if [[ "$GPG_SECRET_KEY" != '' ]] ; then
13+
echo "Load secret key into gpg"
14+
echo "$GPG_SECRET_KEY" | gpg --import --no-tty --batch --yes
15+
fi
16+
17+
echo "Sign Phar"
18+
19+
echo "$GPG_PASSPHRASE" | gpg --command-fd 0 --passphrase-fd 0 --pinentry-mode loopback -u 15E1F8E2B149E6F5 --batch --detach-sign --armor --output phpbench.phar.asc phpbench.phar
20+
fi
21+
22+
cd -

box.json.gh-release

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"chmod": "0755",
32
"compression": "GZ",
43
"directories": [
54
"lib",
@@ -21,6 +20,5 @@
2120
"git-tag": "git_tag",
2221
"intercept": true,
2322
"main": "bin/phpbench.php",
24-
"output": "phpbench.phar",
25-
"stub": true
23+
"output": "build/phpbench.phar"
2624
}

0 commit comments

Comments
 (0)