forked from elementor/elementor
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (82 loc) · 2.73 KB
/
build.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Build
on:
workflow_dispatch:
pull_request:
paths-ignore:
- '**.md'
- '**.txt'
- '.github/config.json'
- 'bin/**'
- '.gitignore'
- 'docs/**'
workflow_call:
outputs:
artifact_name:
value: ${{ jobs.build-plugin.outputs.artifact_name }}
changelog_diff:
value: ${{ jobs.build-plugin.outputs.changelog_diff }}
push:
branches:
- 'main'
- '3.*'
jobs:
build-plugin:
name: Build plugin
runs-on: ubuntu-22.04
if: startsWith( github.repository, 'elementor/' )
outputs:
artifact_name: ${{ env.PLUGIN_FOLDER_FILENAME}}
changelog_diff: ${{ steps.changelog_diff_files.outputs.diff }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- name: Check if this is only a changelog PR
id: changelog_diff_files
uses: technote-space/get-diff-action@v6
with:
# PATTERNS are:
# Everything: **/*
# Everything in directories starting with a period: .*/**/*
# Not readme.txt: !readme.txt
# Not changelog.txt: !changelog.txt
PATTERNS: |
**/*
.*/**/*
!readme.txt
!changelog.txt
- name: Prevent git tag versioning
shell: bash
run: npm config set git-tag-version false
- name: Install Dependencies
if: github.event.pull_request.title == null || steps.changelog_diff_files.outputs.diff
uses: ./.github/workflows/install-dependencies
- name: Set ENV variables
shell: bash
run: |
DATE_VERSION=$(date '+%Y%m%d.%H%M')
VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
PACKAGE_VERSION=${VERSION}-${DATE_VERSION}
PLUGIN_FOLDER_FILENAME="elementor-${PACKAGE_VERSION}"
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "PLUGIN_FOLDER_FILENAME=$PLUGIN_FOLDER_FILENAME" >> $GITHUB_ENV
- name: Build plugin
if: github.event.pull_request.title == null || steps.changelog_diff_files.outputs.diff
uses: ./.github/workflows/build-plugin
with:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
BUILD_SCRIPT_PATH: "./.github/scripts/build-zip.sh"
- uses: actions/upload-artifact@v4
if: github.event.pull_request.title == null || steps.changelog_diff_files.outputs.diff
with:
name: ${{ env.PLUGIN_FOLDER_FILENAME }}
path: elementor