From 8faa97185e9a2eb4ce7d5d6ec4ab2490ea97fa97 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 5 Dec 2024 15:25:34 -0500 Subject: [PATCH 1/2] add version bump script and command --- package.json | 1 + set-version-bump.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 set-version-bump.js diff --git a/package.json b/package.json index 41e64e44..96c5c2fd 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "php-deps": "composer install --no-dev --optimize-autoloader", "postprepare": "npm run set-wp-version", "prebuild:cleanup": "rm -rf ./build ./wp-plugin-hostgator ./wp-plugin-hostgator.zip ./vendor", + "set-version-bump": "node ./set-version-bump.js && npm i && rm -rf ./build && npm run build && composer run i18n", "set-wp-version": "node ./set-latest-wp-version.js", "srb": "npm run simulate-runner-build", "simulate-runner-build": "npm run prebuild:cleanup && npm i && npm run php-deps && npm run build && npm run create:dist && npm run create:zip", diff --git a/set-version-bump.js b/set-version-bump.js new file mode 100644 index 00000000..9d2e8131 --- /dev/null +++ b/set-version-bump.js @@ -0,0 +1,32 @@ +const fs = require( 'fs' ); +const semver = require( 'semver' ); +const packagefile = './package.json'; +const pluginfile = './wp-plugin-hostgator.php'; + +if ( fs.existsSync( packagefile ) && fs.existsSync( pluginfile ) ) { + const packageData = require( packagefile ); + const currentVersion = packageData.version; + let type = process.argv[ 2 ]; + if ( ! [ 'major', 'minor', 'patch' ].includes( type ) ) { + type = 'patch'; + } + + const newVersion = semver.inc( packageData.version, type ); + packageData.version = newVersion; + fs.writeFileSync( packagefile, JSON.stringify( packageData, null, 4 ) ); + + fs.readFile( pluginfile, 'utf8', function ( err, data ) { + if ( err ) { + return console.log( err ); + } + const result = data.replaceAll( currentVersion, newVersion ); + + fs.writeFile( pluginfile, result, 'utf8', function ( err ) { + if ( err ) { + return console.log( err ); + } + } ); + } ); + + console.log( 'Version updated', currentVersion, '=>', newVersion ); +} From c379f8cb6436c0970d12a0cc43ae717d6491552e Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 5 Dec 2024 16:02:24 -0500 Subject: [PATCH 2/2] auto retry workflow step when wp install fails --- .github/workflows/cypress-matrix.yml | 6 +++++- .github/workflows/cypress-tests.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress-matrix.yml b/.github/workflows/cypress-matrix.yml index 8f8c3d62..eb9c386c 100644 --- a/.github/workflows/cypress-matrix.yml +++ b/.github/workflows/cypress-matrix.yml @@ -110,7 +110,11 @@ jobs: echo '{"wpVersion": "${{ matrix.wpVersion }}","phpVersion": "${{ matrix.phpVersion }}"}' > cypress.env.json - name: Install WordPress - run: npx wp-env start --debug + uses: nick-fields/retry@v3 + with: + timeout_minutes: 4 + max_attempts: 3 + command: npx wp-env start --debug - name: Run Cypress Tests if: ${{ github.repository != 'newfold-labs/wp-plugin-hostgator' || github.actor == 'dependabot[bot]' }} diff --git a/.github/workflows/cypress-tests.yml b/.github/workflows/cypress-tests.yml index ea117088..d5c5e190 100644 --- a/.github/workflows/cypress-tests.yml +++ b/.github/workflows/cypress-tests.yml @@ -109,7 +109,11 @@ jobs: run: echo '{"config":{"WP_DEBUG_DISPLAY":false},"plugins":["${{ steps.workflow.outputs.DIST }}/${{ steps.workflow.outputs.PACKAGE }}"]}' > .wp-env.override.json - name: Install WordPress - run: npx wp-env start --debug + uses: nick-fields/retry@v3 + with: + timeout_minutes: 4 + max_attempts: 3 + command: npx wp-env start --debug - name: Run Cypress Tests if: ${{ github.repository != 'newfold-labs/wp-plugin-hostgator' || github.actor == 'dependabot[bot]' }}