Skip to content

Commit 68dc2c2

Browse files
committed
Updates
1 parent e9b8b32 commit 68dc2c2

4 files changed

Lines changed: 156 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build Package
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Code
12+
uses: actions/checkout@v3
13+
14+
- name: Set up PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: '8.1'
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
24+
- name: Cache Composer and Node Modules
25+
uses: actions/cache@v3
26+
with:
27+
path: |
28+
vendor
29+
node_modules
30+
dist
31+
key: ${{ runner.os }}-build-${{ hashFiles('composer.lock', 'yarn.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-build-
34+
35+
- name: Install PHP Dependencies
36+
run: |
37+
curl -sS https://getcomposer.org/installer | php
38+
sudo mv composer.phar /usr/local/bin/composer
39+
composer install --no-dev --optimize-autoloader
40+
41+
- name: Install Node Dependencies
42+
run: yarn install --frozen-lockfile
43+
44+
- name: Build
45+
run: |
46+
yarn build

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ name: CI Pipeline
33
on:
44
push:
55
branches: [main]
6-
pull_request:
7-
branches: [main]
86

97
jobs:
108
sync:
119
uses: ./.github/workflows/sync.yml
12-
secrets: inherit
10+
secrets: inherit
11+
12+
package:
13+
uses: ./.github/workflows/package.yml
14+
15+
release:
16+
uses: ./.github/workflows/release.yml
17+
needs: package

.github/workflows/package.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Package Plugin
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
package:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Code
12+
uses: actions/checkout@v3
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: '20'
18+
19+
- name: Cache dist and node_modules
20+
uses: actions/cache@v3
21+
with:
22+
path: |
23+
node_modules
24+
dist
25+
key: ${{ runner.os }}-package-${{ hashFiles('yarn.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-package-
28+
29+
- name: Install PHP Dependencies
30+
run: |
31+
curl -sS https://getcomposer.org/installer | php
32+
sudo mv composer.phar /usr/local/bin/composer
33+
composer install --no-dev --optimize-autoloader
34+
35+
- name: Install Dependencies
36+
run: yarn install --frozen-lockfile
37+
38+
- name: Package Plugin
39+
run: |
40+
PACKAGE_NAME=$(jq -r .name package.json)
41+
PACKAGE_VERSION=$(jq -r .version package.json)
42+
DATETIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
43+
44+
echo "Package Name: $PACKAGE_NAME"
45+
echo "Package Version: $PACKAGE_VERSION"
46+
47+
yarn build
48+
yarn run package
49+
50+
PACKAGE_FILE="${PACKAGE_NAME}.zip"
51+
52+
- name: Upload Package Artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: package
56+
path: |
57+
*.zip

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release Package
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
19+
- name: Download Build Artifact
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: package
23+
24+
- name: Read Package Info
25+
id: vars
26+
run: |
27+
echo "PACKAGE_NAME=$(jq -r .name package.json)" >> "$GITHUB_OUTPUT"
28+
echo "PACKAGE_VERSION=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT"
29+
30+
- name: Check for ZIP file
31+
run: |
32+
if [ ! -f "${{ steps.vars.outputs.PACKAGE_NAME }}.zip" ]; then
33+
echo "Package file not found!"
34+
exit 1
35+
fi
36+
37+
- name: Create GitHub Release
38+
uses: softprops/action-gh-release@v1
39+
with:
40+
name: "${{ steps.vars.outputs.PACKAGE_NAME }} ${{ steps.vars.outputs.PACKAGE_VERSION }}"
41+
tag_name: "${{ steps.vars.outputs.PACKAGE_VERSION }}"
42+
body: "Release of ${{ steps.vars.outputs.PACKAGE_NAME }} version ${{ steps.vars.outputs.PACKAGE_VERSION }}."
43+
files: "${{ steps.vars.outputs.PACKAGE_NAME }}.zip"
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)