-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (59 loc) · 2 KB
/
Copy pathpackage.yml
File metadata and controls
75 lines (59 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Package Plugin
on:
workflow_call:
jobs:
package:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache dist and node_modules
uses: actions/cache@v3
with:
path: |
node_modules
dist
key: ${{ runner.os }}-package-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-package-
- name: Install PHP Dependencies
run: |
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer install --no-dev --optimize-autoloader
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Build Plugin Assets
run: yarn build
- name: Package Plugin
run: |
MAIN_FILE=$(grep -rl "Plugin Name:" --include="*.php" . | head -n 1)
echo "Main plugin file: $MAIN_FILE"
parse_field() {
grep -i "$1:" "$MAIN_FILE" | head -n1 \
| sed -E "s/^\s*\*\s*//" \
| sed -E "s|$1:[[:space:]]*||i" \
| xargs
}
VERSION="$(parse_field 'Version')"
REPO_NAME=$(basename "$GITHUB_WORKSPACE")
PACKAGE_FILE="${REPO_NAME}.zip"
echo "Packaging $REPO_NAME version $VERSION"
# Create zip one level up to avoid nesting
cd ..
zip -r -D "$PACKAGE_FILE" "$REPO_NAME" -x@"$REPO_NAME/.zipignore"
# Move the zip back to workflow directory
mv "$PACKAGE_FILE" "$GITHUB_WORKSPACE/"
# Set environment variable for later steps
echo "PACKAGE_FILE=$PACKAGE_FILE" >> "$GITHUB_ENV"
- name: Upload Package Artifact
uses: actions/upload-artifact@v4
with:
name: package
path: ${{ env.PACKAGE_FILE }}