Skip to content

Commit 48aaffd

Browse files
committed
Invoke build command in the recipe
1 parent d293c98 commit 48aaffd

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.5.0] - 2023-02-15
8+
9+
### Added
10+
11+
* Enable to specify build command for each plugin
12+
13+
```
14+
mt-plugin-MTBlockEditor:
15+
location: git@github.com:movabletype/mt-plugin-MTBlockEditor
16+
branch: develop
17+
build:
18+
command:
19+
- docker-compose
20+
- run
21+
- builder
22+
- bash
23+
- -c
24+
- 'perl Makefile.PL && make build'
25+
```
26+
727
## [2.4.0] - 2023-11-25
828

929
### Changed

bin/setup-environment

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use lib "$FindBin::Bin/local/lib/perl5";
1010
use Cwd qw(realpath getcwd);
1111
use File::Path qw(mkpath);
1212
use IO::File;
13+
use IPC::Open3 qw(open3);
1314
use JSON::PP qw(encode_json);
1415
use Data::Dumper;
1516
use Digest::MD5;
@@ -158,6 +159,26 @@ sub handle_recipe {
158159
$res = `cd $dest_dir && git rev-parse HEAD 2>&1`;
159160
die "$res\nGot an error: git rev-parse HEAD" if $?;
160161
print STDERR "$k:$res";
162+
163+
my $build_cmd = $data->{$k}{build}{command};
164+
if ($build_cmd) {
165+
my $cur_dir = getcwd();
166+
chdir $dest_dir;
167+
my ($res, $build_cmd_str);
168+
if (ref $build_cmd eq 'ARRAY') {
169+
my $pid = open3( my $in, my $out, my $err, @$build_cmd );
170+
$res .= join('', <$out>) if $out;
171+
$res .= join('', <$err>) if $err;
172+
waitpid($pid, 0);
173+
$build_cmd_str = join(' ', @$build_cmd);
174+
}
175+
else {
176+
$res = `$build_cmd 2>&1`;
177+
$build_cmd_str = $build_cmd;
178+
}
179+
chdir $cur_dir;
180+
die "$res\nGot an error: $build_cmd_str" if $?;
181+
}
161182
}
162183

163184
push @volumes, " - '$dest_dir:/src/$basename:\${DOCKER_VOLUME_MOUNT_FLAG:-rw}'";

0 commit comments

Comments
 (0)