Skip to content

Commit 257889c

Browse files
committed
Enable build with Composer
* Also opt-in PHPStan
1 parent f18c8b7 commit 257889c

File tree

7 files changed

+1995
-1
lines changed

7 files changed

+1995
-1
lines changed

.github/workflows/ci.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- dev/*
7+
pull_request:
8+
9+
jobs:
10+
build-php:
11+
name: Prepare PHP
12+
runs-on: ${{ matrix.image }}
13+
14+
strategy:
15+
matrix:
16+
image:
17+
- ubuntu-20.04
18+
php:
19+
- 8.2.1
20+
21+
steps:
22+
- name: Build and prepare PHP cache
23+
uses: pmmp/setup-php-action@4d1b890176aa299211f4ccae76ddbf9bd008bbd6
24+
with:
25+
php-version: ${{ matrix.php }}
26+
install-path: "./bin"
27+
pm-version-major: "4"
28+
29+
30+
phpstan:
31+
name: PHPStan analysis
32+
needs: build-php
33+
runs-on: ${{ matrix.image }}
34+
35+
strategy:
36+
matrix:
37+
image:
38+
- ubuntu-20.04
39+
php:
40+
- 8.2.1
41+
42+
steps:
43+
- uses: actions/checkout@v3
44+
45+
- name: Setup PHP
46+
uses: pmmp/setup-php-action@4d1b890176aa299211f4ccae76ddbf9bd008bbd6
47+
with:
48+
php-version: ${{ matrix.php }}
49+
install-path: "./bin"
50+
pm-version-major: "4"
51+
52+
- name: Install Composer
53+
run: curl -sS https://getcomposer.org/installer | php
54+
55+
- name: Restore Composer package cache
56+
uses: actions/cache@v3
57+
with:
58+
path: |
59+
~/.cache/composer/files
60+
~/.cache/composer/vcs
61+
key: "composer-v2-cache-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}"
62+
restore-keys: |
63+
composer-v2-cache-
64+
- name: Install Composer dependencies
65+
run: composer install --prefer-dist --no-interaction
66+
67+
- name: Analyze with PHPStan
68+
run: ./vendor/bin/phpstan analyze --no-progress --memory-limit=2G

.github/workflows/release.yml

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-php:
10+
name: Prepare PHP
11+
runs-on: ${{ matrix.image }}
12+
13+
strategy:
14+
matrix:
15+
image:
16+
- ubuntu-20.04
17+
php:
18+
- 8.2.1
19+
20+
steps:
21+
- name: Setup PHP
22+
uses: pmmp/setup-php-action@4d1b890176aa299211f4ccae76ddbf9bd008bbd6
23+
with:
24+
php-version: ${{ matrix.php }}
25+
install-path: "./bin"
26+
pm-version-major: "4"
27+
28+
build-and-release-plugin:
29+
name: Release artifact
30+
needs: build-php
31+
runs-on: ubuntu-20.04
32+
33+
strategy:
34+
matrix:
35+
image:
36+
- ubuntu-20.04
37+
php:
38+
- 8.2.1
39+
40+
steps:
41+
- uses: actions/checkout@v3
42+
43+
- name: Pull pmmp/DevTools
44+
uses: actions/checkout@v3
45+
with:
46+
repository: pmmp/DevTools
47+
ref: master
48+
path: DevTools
49+
50+
- name: Check Texter version
51+
id: check-texter-version
52+
run: |
53+
TEXTER_VERSION=`grep version plugin.yml | sed -e 's/^version: //g'`
54+
echo "::set-output name=VER::${TEXTER_VERSION}"
55+
56+
- name: Check short SHA
57+
id: check-short-sha
58+
run: |
59+
HASH=${{ github.sha }}
60+
echo "::set-output name=SHA::${HASH::7}"
61+
62+
- name: Setup PHP
63+
uses: pmmp/setup-php-action@4d1b890176aa299211f4ccae76ddbf9bd008bbd6
64+
with:
65+
php-version: ${{ matrix.php }}
66+
install-path: "./bin"
67+
pm-version-major: "4"
68+
69+
- name: Install Composer
70+
run: curl -sS https://getcomposer.org/installer | php
71+
72+
- name: Restore Composer package cache
73+
uses: actions/cache@v3
74+
with:
75+
path: |
76+
~/.cache/composer/files
77+
~/.cache/composer/vcs
78+
key: "composer-v2-cache-${{ matrix.php }}-${{ hashFiles('./composer.lock') }}"
79+
restore-keys: |
80+
composer-v2-cache-
81+
82+
- name: Install Composer dependencies (no dev)
83+
run: composer install --prefer-dist --no-interaction --no-dev
84+
85+
- name: Optimize Composer autoloader
86+
run: composer dump-autoload --optimize
87+
88+
- name: Build plugin Phar
89+
run: |
90+
rm -rf bin
91+
mkdir build
92+
php -dphar.readonly=0 DevTools/stub.php --make . --out "build/Texter_v${{ steps.check-texter-version.outputs.VER }}.phar"
93+
94+
- name: Tagging commit
95+
id: tagging-commit
96+
env:
97+
TAG_NAME: release/v${{ steps.check-texter-version.outputs.VER }}(${{ steps.check-short-sha.outputs.SHA }})
98+
run: |
99+
git tag ${TAG_NAME}
100+
git push origin ${TAG_NAME}
101+
echo "::set-output name=TAG::refs/tags/${TAG_NAME}"
102+
103+
- name: Upload release artifact on Github
104+
uses: svenstaro/upload-release-action@v2
105+
with:
106+
repo_token: ${{ secrets.GITHUB_TOKEN }}
107+
file_glob: true
108+
file: build/**
109+
tag: ${{ steps.tagging-commit.outputs.TAG }}

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Composer
2+
/vendor/
3+
14
# Intellij IDEA
25
/.idea
36

@@ -10,4 +13,4 @@
1013
/crfts.json
1114
/fts.json
1215
/uft.json
13-
/ft.json
16+
/ft.json

composer.json

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "fuyutsuki/texter",
3+
"description": "Texter is a plugin for PocketMine-MP that supports multiple worlds and allows you to add, edit, move, and delete FloatingText.",
4+
"type": "project",
5+
"license": "NCSA",
6+
"authors": [
7+
{
8+
"name": "yuko fuyutsuki",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"repositories": [
13+
{
14+
"type": "package",
15+
"package": {
16+
"name": "aieuo/mineflow",
17+
"version": "2.12.0",
18+
"source": {
19+
"type": "git",
20+
"url": "https://github.com/aieuo/Mineflow",
21+
"reference": "8c69fb5bbcec5def813148be9e8f01184c1c2d8b"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"aieuo\\mineflow\\": ["src/aieuo/Mineflow"]
26+
}
27+
}
28+
}
29+
},
30+
{
31+
"type": "package",
32+
"package": {
33+
"name": "dktapps-pm-pl/pmforms",
34+
"version": "2.0.0",
35+
"source": {
36+
"type": "git",
37+
"url": "https://github.com/dktapps-pm-pl/pmforms",
38+
"reference": "93cbd7b97a80d6edc54d9c8c8f58cea09ec3b47f"
39+
},
40+
"autoload": {
41+
"psr-4": {
42+
"dktapps\\pmforms\\": ["src/dktapps/pmforms"]
43+
}
44+
}
45+
}
46+
}
47+
],
48+
"require": {
49+
"aieuo/mineflow": "^2.12.0",
50+
"dktapps-pm-pl/pmforms": "^2.0.0"
51+
},
52+
"require-dev": {
53+
"phpstan/phpstan": "^1.9",
54+
"pocketmine/pocketmine-mp": "^4.14"
55+
},
56+
"autoload": {
57+
"psr-4": {
58+
"jp\\mcbe\\fuyutsuki\\Texter\\": ["src"]
59+
}
60+
},
61+
"config": {
62+
"sort-packages": true
63+
}
64+
}

0 commit comments

Comments
 (0)