Compare commits

..

1 Commits

Author SHA1 Message Date
Jerry Ma
d622a12101 Enhance release-build.yml with release deployment step
Added a deployment step for release tags to the self-hosted OSS workflow.
2026-02-13 13:21:25 +08:00
3 changed files with 21 additions and 30 deletions

View File

@@ -120,7 +120,7 @@ jobs:
with: with:
files: dist/${{ matrix.operating-system.filename }} files: dist/${{ matrix.operating-system.filename }}
- name: "Deploy to self-hosted OSS" - name: "Deploy to self-hosted OSS (nightly)"
# only run this step if the repository is static-php-cli and the branch is main # only run this step if the repository is static-php-cli and the branch is main
if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main' if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main'
uses: static-php/upload-s3-action@v1.0.0 uses: static-php/upload-s3-action@v1.0.0
@@ -132,6 +132,18 @@ jobs:
destination_dir: static-php-cli/spc-bin/nightly/ destination_dir: static-php-cli/spc-bin/nightly/
endpoint: ${{ secrets.AWS_ENDPOINT }} endpoint: ${{ secrets.AWS_ENDPOINT }}
- name: "Deploy to self-hosted OSS (release)"
# only run this step if the repository is static-php-cli and release tag
if: github.repository == 'crazywhalecc/static-php-cli' && startsWith(github.ref, 'refs/tags/')
uses: static-php/upload-s3-action@v1.0.0
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: "dist/"
destination_dir: static-php-cli/spc-bin/${{ github.event.release.tag_name }}/
endpoint: ${{ secrets.AWS_ENDPOINT }}
- name: "Upload Artifact" - name: "Upload Artifact"
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

View File

@@ -411,17 +411,10 @@ abstract class UnixBuilderBase extends BuilderBase
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
$frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp'; $frankenphpSourceDir = getenv('FRANKENPHP_SOURCE_PATH') ?: SOURCE_PATH . '/frankenphp';
FileSystem::replaceFileStr(
$frankenphpSourceDir . '/caddy/php-server.go',
'config, _, err := caddycmd.LoadConfig',
'config, _, _, err := caddycmd.LoadConfig'
);
$xcaddyModules = preg_replace('#--with github.com/dunglas/frankenphp\S*#', '', $xcaddyModules); $xcaddyModules = preg_replace('#--with github.com/dunglas/frankenphp\S*#', '', $xcaddyModules);
$xcaddyModules = "--with github.com/dunglas/frankenphp={$frankenphpSourceDir} " . $xcaddyModules = "--with github.com/dunglas/frankenphp={$frankenphpSourceDir} " .
"--with github.com/dunglas/frankenphp/caddy={$frankenphpSourceDir}/caddy " . "--with github.com/dunglas/frankenphp/caddy={$frankenphpSourceDir}/caddy {$xcaddyModules}";
"--with github.com/caddyserver/caddy/v2=github.com/henderkes/caddy/v2@master " .
"{$xcaddyModules}";
if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) {
logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.'); logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.');
$xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules);
@@ -460,7 +453,7 @@ abstract class UnixBuilderBase extends BuilderBase
'CGO_ENABLED' => '1', 'CGO_ENABLED' => '1',
'CGO_CFLAGS' => clean_spaces($cflags), 'CGO_CFLAGS' => clean_spaces($cflags),
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}", 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie -trimpath ' . 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . "v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace SPC\store\pkg; namespace SPC\store\pkg;
use InvalidArgumentException;
use SPC\builder\linux\SystemUtil; use SPC\builder\linux\SystemUtil;
use SPC\store\Downloader; use SPC\store\Downloader;
use SPC\store\FileSystem; use SPC\store\FileSystem;
@@ -31,10 +30,10 @@ class GoXcaddy extends CustomPackage
public function fetch(string $name, bool $force = false, ?array $config = null): void public function fetch(string $name, bool $force = false, ?array $config = null): void
{ {
$pkgroot = PKG_ROOT_PATH; $pkgroot = PKG_ROOT_PATH;
$go_exec = "{$pkgroot}/go-xcaddy/bin/go"; $go_exec = "{$pkgroot}/{$name}/bin/go";
$xcaddy_exec = "{$pkgroot}/go-xcaddy/bin/xcaddy"; $xcaddy_exec = "{$pkgroot}/{$name}/bin/xcaddy";
if ($force) { if ($force) {
FileSystem::removeDir("{$pkgroot}/go-xcaddy"); FileSystem::removeDir("{$pkgroot}/{$name}");
} }
if (file_exists($go_exec) && file_exists($xcaddy_exec)) { if (file_exists($go_exec) && file_exists($xcaddy_exec)) {
return; return;
@@ -42,12 +41,12 @@ class GoXcaddy extends CustomPackage
$arch = match (explode('-', $name)[2]) { $arch = match (explode('-', $name)[2]) {
'x86_64' => 'amd64', 'x86_64' => 'amd64',
'aarch64' => 'arm64', 'aarch64' => 'arm64',
default => throw new InvalidArgumentException('Unsupported architecture: ' . $name), default => throw new \InvalidArgumentException('Unsupported architecture: ' . $name),
}; };
$os = match (explode('-', $name)[3]) { $os = match (explode('-', $name)[3]) {
'linux' => 'linux', 'linux' => 'linux',
'macos' => 'darwin', 'macos' => 'darwin',
default => throw new InvalidArgumentException('Unsupported OS: ' . $name), default => throw new \InvalidArgumentException('Unsupported OS: ' . $name),
}; };
[$go_version] = explode("\n", Downloader::curlExec('https://go.dev/VERSION?m=text')); [$go_version] = explode("\n", Downloader::curlExec('https://go.dev/VERSION?m=text'));
$config = [ $config = [
@@ -79,18 +78,6 @@ class GoXcaddy extends CustomPackage
} }
// install xcaddy without using musl tools, xcaddy build requires dynamic linking // install xcaddy without using musl tools, xcaddy build requires dynamic linking
// Clone the fork and install from local clone to avoid module path conflicts
$xcaddyClonePath = "{$pkgroot}/go/src/github.com/henderkes/xcaddy";
if (!is_dir($xcaddyClonePath)) {
shell()
->appendEnv([
'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath,
])
->exec("git clone https://github.com/henderkes/xcaddy {$xcaddyClonePath}");
} else {
shell()->cd($xcaddyClonePath)->exec('git fetch && git pull');
}
shell() shell()
->appendEnv([ ->appendEnv([
'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath, 'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath,
@@ -98,8 +85,7 @@ class GoXcaddy extends CustomPackage
'GOBIN' => "{$pkgroot}/go-xcaddy/bin", 'GOBIN' => "{$pkgroot}/go-xcaddy/bin",
'GOPATH' => "{$pkgroot}/go", 'GOPATH' => "{$pkgroot}/go",
]) ])
->cd($xcaddyClonePath) ->exec('CC=cc go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest');
->exec('CC=cc go install ./cmd/xcaddy');
} }
public static function getEnvironment(): array public static function getEnvironment(): array