Skip to content

Commit 2bb9b2d

Browse files
authored
Merge pull request #5 from dployr-io/non-static-deploy
Non static deploy
2 parents 0c49890 + 3a146c4 commit 2bb9b2d

20 files changed

Lines changed: 567 additions & 193 deletions

.github/workflows/beta.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Beta
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Test"]
6+
types: [completed]
7+
push:
8+
branches: ["beta"]
9+
pull_request:
10+
branches: ["beta"]
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release:
17+
if: >
18+
github.event.workflow_run.conclusion == 'success' &&
19+
github.event.workflow_run.head_branch == 'beta'
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: '8.3'
31+
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo
32+
33+
- name: Validate version
34+
id: version
35+
run: |
36+
VERSION=$(php -r "echo trim(file_get_contents('VERSION'));")
37+
echo "version=$VERSION" >> $GITHUB_OUTPUT
38+
EXISTING=$(git tag | grep -E "^v${VERSION}-beta\.[0-9]+$" | sort -V | tail -n 1 || true)
39+
40+
if [ -z "$EXISTING" ]; then
41+
NEW_TAG="v${VERSION}-beta.1"
42+
else
43+
LAST_NUM=$(echo "$EXISTING" | sed -E 's/^v[0-9]+\.[0-9]+\.[0-9]+-beta\.([0-9]+)$/\1/')
44+
NEXT_NUM=$((LAST_NUM + 1))
45+
NEW_TAG="v${VERSION}-beta.${NEXT_NUM}"
46+
fi
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
48+
49+
- name: Check if tag already exists
50+
run: |
51+
TAG="v${{ steps.version.outputs.version }}"
52+
echo "Checking if tag $TAG already exists..."
53+
54+
if git rev-parse "$TAG" >/dev/null 2>&1; then
55+
echo "Tag $TAG already exists. Please bump the version before releasing."
56+
exit 1
57+
fi
58+
echo "Tag $TAG is available."
59+
60+
- name: Setup Node.js
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: '22'
64+
65+
- name: Get composer cache directory
66+
id: composer-cache
67+
run: cd app && echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
68+
69+
- name: Cache composer dependencies
70+
uses: actions/cache@v4
71+
with:
72+
path: ${{ steps.composer-cache.outputs.dir }}
73+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
74+
restore-keys: ${{ runner.os }}-composer-
75+
76+
- name: Install PHP dependencies
77+
run: composer install --no-dev --optimize-autoloader --no-interaction
78+
79+
- name: Install pnpm
80+
run: npm install -g pnpm
81+
82+
- name: Install Node dependencies
83+
run: pnpm i
84+
85+
- name: Build frontend assets
86+
run: pnpm run build
87+
88+
- name: Prepare release
89+
run: |
90+
echo "removing development files..."
91+
rm -rf tests .github .cache builds .config .local node_modules phpunit.xml eslint.config.js .editorconfig .gitattributes .gitignore .prettierrc .prettierignore resources/css resources/js
92+
93+
echo "cleaning storage directories..."
94+
find storage -name "*.log" -delete 2>/dev/null || true
95+
find storage/framework/cache -name "*" -not -name ".gitignore" -delete 2>/dev/null || true
96+
find storage/framework/sessions -name "*" -not -name ".gitignore" -delete 2>/dev/null || true
97+
find storage/framework/views -name "*" -not -name ".gitignore" -delete 2>/dev/null || true
98+
99+
- name: Create archive
100+
run: zip -r "../dployr-v${{ steps.version.outputs.version }}.zip" .
101+
102+
- name: Create tag
103+
run: |
104+
echo "Creating tag..."
105+
git config user.name "github-actions[bot]"
106+
git config user.email "github-actions[bot]@users.noreply.github.com"
107+
git tag v${{ steps.version.outputs.version }}
108+
git push origin v${{ steps.version.outputs.version }}
109+
110+
- name: Create Release
111+
uses: softprops/action-gh-release@v2
112+
with:
113+
tag_name: v${{ steps.version.outputs.version }}
114+
name: dployr ${{ steps.version.outputs.version }}
115+
files: |
116+
dployr-v${{ steps.version.outputs.version }}.zip
117+
LICENSE
118+
generate_release_notes: true
119+
make_latest: false
120+
env:
121+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,56 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
workflow_run:
5+
workflows: ["Test"]
6+
types: [completed]
7+
pull_request:
8+
branches: ["master"]
79

810
permissions:
911
contents: write
1012

1113
jobs:
1214
release:
15+
if: >
16+
github.event.workflow_run.conclusion == 'success' &&
17+
github.event.workflow_run.head_branch == 'master'
1318
runs-on: ubuntu-latest
1419
steps:
1520
- name: Checkout
1621
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
1724

1825
- name: Setup PHP
1926
uses: shivammathur/setup-php@v2
2027
with:
2128
php-version: '8.3'
2229
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo
2330

31+
- name: Validate version
32+
id: version
33+
run: |
34+
VERSION=$(php -r "echo trim(file_get_contents('VERSION'));")
35+
echo "Detected version: $VERSION"
36+
37+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9\.]+)?$ ]]; then
38+
echo "Invalid version format in VERSION file: $VERSION"
39+
exit 1
40+
fi
41+
echo "version=$VERSION" >> $GITHUB_OUTPUT
42+
43+
- name: Check if tag already exists
44+
run: |
45+
TAG="v${{ steps.version.outputs.version }}"
46+
echo "Checking if tag $TAG already exists..."
47+
48+
if git rev-parse "$TAG" >/dev/null 2>&1; then
49+
echo "Tag $TAG already exists. Please bump the version before releasing."
50+
exit 1
51+
fi
52+
echo "Tag $TAG is available."
53+
2454
- name: Setup Node.js
2555
uses: actions/setup-node@v4
2656
with:
@@ -54,31 +84,23 @@ jobs:
5484
echo "removing development files..."
5585
rm -rf tests .github .cache builds .config .local node_modules phpunit.xml eslint.config.js .editorconfig .gitattributes .gitignore .prettierrc .prettierignore resources/css resources/js
5686
57-
echo "creating config..."
58-
cp .env.example .env
59-
APP_KEY=$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-32)
60-
if grep -q '^APP_KEY=' .env; then
61-
sed -i "s/^APP_KEY=.*/APP_KEY=${APP_KEY}/" .env
62-
else
63-
echo "APP_KEY=${APP_KEY}" >> .env
64-
fi
65-
6687
echo "cleaning storage directories..."
6788
find storage -name "*.log" -delete 2>/dev/null || true
6889
find storage/framework/cache -name "*" -not -name ".gitignore" -delete 2>/dev/null || true
6990
find storage/framework/sessions -name "*" -not -name ".gitignore" -delete 2>/dev/null || true
7091
find storage/framework/views -name "*" -not -name ".gitignore" -delete 2>/dev/null || true
7192
72-
- name: Read version from file
73-
id: version
74-
run: |
75-
VERSION=$(php -r "echo trim(file_get_contents('VERSION'));")
76-
echo "version=$VERSION" >> $GITHUB_OUTPUT
77-
echo "Using version: $VERSION"
78-
7993
- name: Create archive
8094
run: zip -r "../dployr-v${{ steps.version.outputs.version }}.zip" .
8195

96+
- name: Create tag
97+
run: |
98+
echo "Creating tag..."
99+
git config user.name "github-actions[bot]"
100+
git config user.email "github-actions[bot]@users.noreply.github.com"
101+
git tag v${{ steps.version.outputs.version }}
102+
git push origin v${{ steps.version.outputs.version }}
103+
82104
- name: Create Release
83105
uses: softprops/action-gh-release@v2
84106
with:

.github/workflows/tests.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ name: tests
22

33
on:
44
push:
5-
branches:
6-
- develop
7-
- main
5+
branches: ["*"]
86
pull_request:
9-
branches:
10-
- develop
11-
- main
7+
branches: ["*"]
128

139
jobs:
1410
ci:
@@ -17,34 +13,53 @@ jobs:
1713
steps:
1814
- name: Checkout
1915
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
2018

2119
- name: Setup PHP
2220
uses: shivammathur/setup-php@v2
2321
with:
24-
php-version: 8.4
22+
php-version: '8.3'
2523
tools: composer:v2
2624
coverage: xdebug
25+
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo
2726

28-
- name: Setup Node
27+
- name: Setup Node.js
2928
uses: actions/setup-node@v4
3029
with:
3130
node-version: '22'
32-
cache: 'npm'
3331

34-
- name: Install Node Dependencies
35-
run: npm ci
32+
- name: Get composer cache directory
33+
id: composer-cache
34+
run: cd app && echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
35+
36+
- name: Cache composer dependencies
37+
uses: actions/cache@v4
38+
with:
39+
path: ${{ steps.composer-cache.outputs.dir }}
40+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
41+
restore-keys: ${{ runner.os }}-composer-
42+
43+
- name: Install PHP dependencies
44+
run: composer install --no-interaction --prefer-dist
45+
46+
- name: Install pnpm
47+
run: npm install -g pnpm
3648

37-
- name: Install Dependencies
38-
run: composer install --no-interaction --prefer-dist --optimize-autoloader
49+
- name: Install Node dependencies
50+
run: pnpm i
3951

40-
- name: Build Assets
41-
run: npm run build
52+
- name: Build frontend assets
53+
run: pnpm run build
4254

4355
- name: Copy Environment File
4456
run: cp .env.example .env
4557

4658
- name: Generate Application Key
4759
run: php artisan key:generate
4860

49-
- name: Tests
61+
- name: Backend tests
5062
run: ./vendor/bin/phpunit
63+
64+
- name: Frontend tests
65+
run: pnpm run test

app/DTOs/Spec.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
use App\Models\Remote;
6+
7+
readonly class Spec
8+
{
9+
public function __construct(
10+
public string $id,
11+
public string $serviceName,
12+
public ?Remote $remote,
13+
public ?string $commitHash,
14+
public ?Remote $ciRemote,
15+
public string $runtime,
16+
public ?int $port,
17+
public ?string $image,
18+
public array $envVars = [],
19+
public array $secrets = [],
20+
public ?string $outputDir,
21+
public ?string $workingDir,
22+
public ?string $runCmd,
23+
) {}
24+
}

0 commit comments

Comments
 (0)