Skip to content

Commit fddea9b

Browse files
merge with trunk
2 parents 1145685 + 1f684b4 commit fddea9b

File tree

191 files changed

+47126
-23499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+47126
-23499
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ updates:
44
# Maintain dependencies for GitHub Actions
55
- package-ecosystem: "github-actions"
66
directory: "/"
7-
target-branch: "develop"
7+
target-branch: "trunk"
88
allow:
99
- dependency-type: direct
1010
schedule:
@@ -14,11 +14,12 @@ updates:
1414
include: "scope"
1515
labels:
1616
- "dependencies"
17+
- "workflows"
1718

1819
# Maintain dependencies for npm
1920
- package-ecosystem: "npm"
2021
directory: "/"
21-
target-branch: "develop"
22+
target-branch: "trunk"
2223
allow:
2324
- dependency-type: direct
2425
schedule:
@@ -31,17 +32,11 @@ updates:
3132
labels:
3233
- "dependencies"
3334
- "javascript"
34-
registries:
35-
npm-github:
36-
type: npm-registry
37-
url: https://npm.pkg.github.com
38-
token: ${{ secrets.NEWFOLD_ACCESS_TOKEN }}
39-
replaces-base: true
4035

4136
# Maintain dependencies for Composer
4237
- package-ecosystem: "composer"
4338
directory: "/"
44-
target-branch: "develop"
39+
target-branch: "trunk"
4540
schedule:
4641
interval: "daily"
4742
allow:

.github/scripts/set-version-bump.js

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,48 @@ const fs = require( 'fs' );
22
const path = require( 'path' );
33
const semver = require( 'semver' );
44
const packagefile = path.resolve( __dirname, '../../package.json' );
5-
const pluginfile = path.resolve( __dirname, '../../bootstrap.php' );
5+
const pluginfile = path.resolve(
6+
__dirname,
7+
'../../bootstrap.php'
8+
);
69

710
if ( fs.existsSync( packagefile ) && fs.existsSync( pluginfile ) ) {
8-
const packageData = require( packagefile );
9-
const currentVersion = packageData.version;
10-
let type = process.argv[ 2 ];
11-
if ( ! [ 'major', 'minor', 'patch' ].includes( type ) ) {
12-
type = 'patch';
13-
}
11+
const packageData = require( packagefile );
12+
const currentVersion = packageData.version;
13+
let type = process.argv[ 2 ];
14+
if ( ! [ 'major', 'minor', 'patch' ].includes( type ) ) {
15+
type = 'patch';
16+
}
1417

15-
const newVersion = semver.inc( packageData.version, type );
16-
packageData.version = newVersion;
17-
fs.writeFileSync( packagefile, JSON.stringify( packageData, null, 4 ) );
18+
const newVersion = semver.inc( packageData.version, type );
19+
packageData.version = newVersion;
1820

19-
fs.readFile( pluginfile, 'utf8', function ( err, data ) {
20-
if ( err ) {
21-
return console.log( err );
22-
}
23-
const result = data.replaceAll( currentVersion, newVersion );
21+
// update version in package file
22+
fs.writeFileSync( packagefile, JSON.stringify( packageData, null, 2 ) );
2423

25-
fs.writeFile( pluginfile, result, 'utf8', function ( err ) {
26-
if ( err ) {
27-
return console.log( err );
28-
}
29-
} );
30-
} );
24+
fs.readFile( pluginfile, 'utf8', function ( err, data ) {
25+
if ( err ) {
26+
return console.log( err );
27+
}
28+
const result = data.replaceAll( currentVersion, newVersion );
3129

32-
console.log( 'Version updated', currentVersion, '=>', newVersion );
30+
// update version in php file
31+
fs.writeFile( pluginfile, result, 'utf8', function ( err ) {
32+
if ( err ) {
33+
return console.log( err );
34+
}
35+
} );
36+
} );
37+
38+
const output = {
39+
oldVersion: currentVersion,
40+
newVersion: newVersion,
41+
level: type,
42+
message: `Version updated from ${ currentVersion } to ${ newVersion }`,
43+
}
44+
console.log( JSON.stringify( output ) );
45+
} else {
46+
console.log( JSON.stringify( {
47+
message: 'Version update error. A file was not found.',
48+
} ) );
3349
}

.github/workflows/brand-plugin-test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
needs: setup
3030
uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main
3131
with:
32-
only-module-tests: true
3332
module-repo: ${{ github.repository }}
3433
module-branch: ${{ needs.setup.outputs.branch }}
3534
plugin-repo: "newfold-labs/wp-plugin-bluehost"
@@ -40,7 +39,6 @@ jobs:
4039
needs: setup
4140
uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main
4241
with:
43-
only-module-tests: true
4442
module-repo: ${{ github.repository }}
4543
module-branch: ${{ needs.setup.outputs.branch }}
4644
plugin-repo: "newfold-labs/wp-plugin-hostgator"
@@ -51,7 +49,6 @@ jobs:
5149
needs: setup
5250
uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main
5351
with:
54-
only-module-tests: true
5552
module-repo: ${{ github.repository }}
5653
module-branch: ${{ needs.setup.outputs.branch }}
5754
plugin-repo: "newfold-labs/wp-plugin-crazy-domains"

.github/workflows/lint-check-php.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ jobs:
2222
steps:
2323

2424
- name: Checkout
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2626

2727
# User PHP 7.4 here for compatibility with the WordPress codesniffer rules.
2828
- name: Setup PHP
29-
uses: shivammathur/setup-php@v2
29+
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
3030
with:
3131
php-version: '7.3'
3232
coverage: none
3333
tools: composer, cs2pr
3434

35-
- uses: technote-space/get-diff-action@v6
35+
- uses: technote-space/get-diff-action@f27caffdd0fb9b13f4fc191c016bb4e0632844af # v6.1.2
3636
with:
3737
PATTERNS: |
3838
**/*.php
@@ -44,7 +44,7 @@ jobs:
4444
if: "!! env.GIT_DIFF"
4545

4646
- name: Cache Composer vendor directory
47-
uses: actions/cache@v4
47+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4848
with:
4949
path: ${{ steps.composer-cache.outputs.dir }}
5050
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

.github/workflows/lint-check-spa.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,31 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout Repository
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2525

2626
# Install Node and npm
2727
- name: Setup Node.js
28-
uses: actions/setup-node@v3
28+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2929
with:
3030
node-version: 16.x
3131
cache: 'npm'
3232

3333
# Checks if node_modules exists in the cache.
3434
- name: Cache node_modules directory
3535
id: cache
36-
uses: actions/cache@v4
36+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3737
with:
3838
path: node_modules
3939
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
4040
restore-keys: ${{ runner.os }}-node-
4141

42-
- name: Setup Registry
43-
run: printf "@newfold-labs:registry=https://npm.pkg.github.com/\n//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
44-
if: steps.cache.outputs.cache-hit != 'true'
45-
4642
# Installs @wordpress/scripts for lint checks if it does not exist in the cache.
4743
- name: Install dependencies
48-
run: npm i @wordpress/[email protected] @newfold-labs/js-utility-ui-analytics --legacy-peer-deps
44+
run: npm i @wordpress/[email protected] --legacy-peer-deps
4945
if: steps.cache.outputs.cache-hit != 'true'
5046

5147
# Gets the files changed wrt to trunk and filters out the js files.
52-
- uses: technote-space/get-diff-action@v6
48+
- uses: technote-space/get-diff-action@f27caffdd0fb9b13f4fc191c016bb4e0632844af # v6.1.2
5349
with:
5450
PATTERNS: |
5551
+(src)/**/*.js
@@ -61,7 +57,7 @@ jobs:
6157
if: "!! env.GIT_DIFF"
6258

6359
# Gets the files changed wrt to trunk and filters out the SASS files.
64-
- uses: technote-space/get-diff-action@v6
60+
- uses: technote-space/get-diff-action@f27caffdd0fb9b13f4fc191c016bb4e0632844af # v6.1.2
6561
with:
6662
PATTERNS: |
6763
+(src)/**/*.scss
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Newfold Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
level:
7+
description: The level of release to be used.
8+
type: choice
9+
options:
10+
- patch
11+
- minor
12+
- major
13+
default: 'patch'
14+
required: true
15+
16+
jobs:
17+
18+
# This job is used to extract the branch name from the pull request or branch.
19+
setup:
20+
name: Setup
21+
runs-on: ubuntu-latest
22+
outputs:
23+
branch: ${{ steps.extract_branch.outputs.branch }}
24+
steps:
25+
- name: Extract branch name
26+
shell: bash
27+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
28+
id: extract_branch
29+
30+
# This job runs the newfold module-prep-release workflow for this module.
31+
prep-release:
32+
name: Prepare Release
33+
needs: setup
34+
uses: newfold-labs/workflows/.github/workflows/module-prep-release.yml@add/preprelease
35+
with:
36+
module-repo: ${{ github.repository }}
37+
module-branch: ${{ needs.setup.outputs.branch }}
38+
level: ${{ inputs.level }}
39+
secrets: inherit

.github/workflows/prep-release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Prepare Release
2+
# This workflow is manually dispatched. It:
3+
# - bumps the version as specified in the input
4+
# - prepares build artifacts
5+
# - creates a release branch
6+
# - commits the changes
7+
# - creates a pull request to the main branch
8+
# - TODO: consider skipping the PR, push to main, and create a release automatically
9+
10+
on:
11+
workflow_dispatch:
12+
inputs:
13+
level:
14+
description: The level of release to be used.
15+
type: choice
16+
options:
17+
- patch
18+
- minor
19+
- major
20+
default: 'patch'
21+
required: true
22+
23+
jobs:
24+
prep-release:
25+
name: Prepare Release
26+
runs-on: ubuntu-latest
27+
permissions:
28+
# Give the default token permission to commit, push the changed files, and open a pull request.
29+
contents: write
30+
pull-requests: write
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34+
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
37+
with:
38+
php-version: '8.1'
39+
coverage: none
40+
tools: composer, cs2pr
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
44+
with:
45+
node-version: 20.x
46+
cache: 'npm'
47+
48+
- name: Get Composer cache directory
49+
id: composer-cache
50+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
51+
52+
- name: Cache Composer vendor directory
53+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
54+
with:
55+
path: ${{ steps.composer-cache.outputs.dir }}
56+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
57+
restore-keys: |
58+
${{ runner.os }}-composer-
59+
60+
- name: Show versions
61+
run: |
62+
php --version
63+
composer --version
64+
node --version
65+
npm --version
66+
67+
- name: Validate composer.json and composer.lock
68+
run: composer validate
69+
70+
- name: Install Packages
71+
run: npm install
72+
73+
- name: Run Update Version Script
74+
id: version_bump
75+
run: |
76+
echo "Running version bump script..."
77+
OUTPUT=$(node ./.github/scripts/set-version-bump.js ${{ inputs.level }})
78+
echo ""
79+
echo "====== Script Output ======"
80+
echo "$OUTPUT"
81+
echo "==========================="
82+
echo ""
83+
echo "new_version=$(echo "$OUTPUT" | jq -r '.newVersion')" >> $GITHUB_OUTPUT
84+
echo "old_version=$(echo "$OUTPUT" | jq -r '.oldVersion')" >> $GITHUB_OUTPUT
85+
echo "message=$(echo "$OUTPUT" | jq -r '.message')" >> $GITHUB_OUTPUT
86+
87+
- name: Run Build and Update Language Files
88+
run: npm run post-set-version
89+
90+
- name: Create Release Pull Request
91+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
92+
with:
93+
token: ${{ github.token }}
94+
base: trunk
95+
branch: release/${{ steps.version_bump.outputs.new_version }}
96+
title: "Automated ${{ inputs.level }} Release ${{ steps.version_bump.outputs.new_version }} PR"
97+
body: "This PR was created automatically by a GitHub Action."
98+
commit-message: "🤖 prep release - ${{ steps.version_bump.outputs.message }}"

.github/workflows/prepare-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616

1717
- name: Checkout trunk
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1919

2020
- name: Create Release Branch
2121
run: |
@@ -42,20 +42,20 @@ jobs:
4242
git commit -m "Update boostrap.php to $new_version"
4343
4444
- name: Setup PHP
45-
uses: shivammathur/setup-php@v2
45+
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
4646
with:
4747
php-version: '8.1'
4848
coverage: none
4949
tools: composer, cs2pr
5050

5151
- name: Setup Node.js
52-
uses: actions/setup-node@v3
52+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
5353
with:
5454
node-version: 16.x
5555

5656
- name: Setup Registry
5757
run: printf "@newfold-labs:registry=https://npm.pkg.github.com/\n//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
58-
58+
5959
- name: Log Debug Information
6060
run: |
6161
php --version

.github/workflows/satis-update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
2323

2424
- name: Repository Dispatch
25-
uses: peter-evans/repository-dispatch@v1
25+
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
2626
with:
2727
token: ${{ secrets.WEBHOOK_TOKEN }}
2828
repository: newfold-labs/satis

0 commit comments

Comments
 (0)