Skip to content

Commit 6528175

Browse files
committed
=>
1 parent 82d8289 commit 6528175

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,9 @@ jobs:
2828
- name: Calculate sha1
2929
run: echo "SHA1=$(sha1sum deployer.phar | awk '{print $1;}')" >> $GITHUB_ENV
3030

31-
- name: Update manifest
31+
- name: Release
3232
uses: deployphp/action@v1
3333
with:
3434
private-key: ${{ secrets.PRIVATE_KEY }}
3535
deployer-binary: bin/dep
36-
dep: -f deploy.yaml update_manifest -o sha1=${{ env.SHA1 }} -o url=https://github.com/deployphp/deployer/releases/download/v${{ env.RELEASE_VERSION }}/deployer.phar -o version=${{ env.RELEASE_VERSION }}
37-
38-
- name: Release dist
39-
uses: deployphp/action@v1
40-
with:
41-
private-key: ${{ secrets.PRIVATE_KEY }}
42-
deployer-binary: bin/dep
43-
dep: -f deploy.yaml release_dist
36+
dep: -f deploy.yaml release -o sha1=${{ env.SHA1 }} -o version=${{ env.RELEASE_VERSION }}

deploy.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import:
2+
- src/Support/update_manifest.php
3+
14
hosts:
25
deployer.org:
36
remote_user: anton
@@ -11,10 +14,9 @@ config:
1114
╰──────────────────────────────────────────────────────╯
1215
1316
tasks:
14-
update_manifest:
15-
- desc: Create a new record in manifest.json
16-
- cd: ~/deployer.org/artifacts
17-
run: "fx manifest.json '[...this, {name: `deployer.org`, sha1: `{{sha1}}`, url: `{{url}}`, version: `{{version}}`}]' save"
17+
release:
18+
- update_manifest
19+
- release_dist
1820

1921
release_dist:
2022
- desc: Release deployer/dist

src/Support/update_manifest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
namespace Deployer;
3+
4+
task('update_manifest', function () {
5+
$version = get('version');
6+
$manifestPath = '~/deployer.org/artifacts/manifest.json';
7+
$manifest = json_decode(run("cat $manifestPath"), true);
8+
9+
$newPharManifest = [
10+
'name' => 'deployer.phar',
11+
'sha1' => get('sha1'),
12+
'url' => "https://github.com/deployphp/deployer/releases/download/v$version/deployer.phar",
13+
'version' => $version,
14+
];
15+
16+
// Check if this version already in manifest.json.
17+
$alreadyExistVersion = null;
18+
foreach ($manifest as $i => $m) {
19+
if ($m['version'] === $version) {
20+
$alreadyExistVersion = $i;
21+
}
22+
}
23+
24+
// Save or update.
25+
if (empty($alreadyExistVersion)) {
26+
$manifest[] = $newPharManifest;
27+
} else {
28+
$manifest[$alreadyExistVersion] = $newPharManifest;
29+
}
30+
31+
// Write manifest to manifest.json.
32+
$content = json_encode($manifest, JSON_PRETTY_PRINT);
33+
run("echo '$content' > $manifestPath");
34+
});

0 commit comments

Comments
 (0)