Skip to content

Commit

Permalink
Merge pull request #76 from dreamsicle-io/release/4.3.0
Browse files Browse the repository at this point in the history
Release/4.3.0
  • Loading branch information
theenoahmason authored Jun 22, 2024
2 parents d1d9cc6 + c89e071 commit 88cf497
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 9 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-theme-assets",
"version": "4.2.3",
"version": "4.3.0",
"description": "WP Theme Assets",
"homepage": "https://github.com/dreamsicle-io/wp-theme-assets",
"license": "GPL-3.0",
Expand All @@ -12,8 +12,8 @@
"url": "https://github.com/dreamsicle-io/wp-theme-assets/issues"
},
"author": {
"name": "Dreamsicle",
"email": "[email protected]",
"url": "https://www.dreamsicle.io"
}
"name": "Dreamsicle",
"email": "[email protected]",
"url": "https://www.dreamsicle.io"
}
}
77 changes: 77 additions & 0 deletions package/.github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Deploy

on:
release:
types:
- published

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

# Initialize the env variables. These get set after the repo is checked out
# because they depend on files in the repo.
env:
PHP_VERSION: ''
NODE_VERSION: ''
THEME_VERSION: ''
THEME_NAME: ''
WPE_ENV: ''

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it.
- name: Checkout Repo
id: checkout_repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

# Sets the environment variables from the env.sh script.
- name: Set Environment Variables
id: set_env_vars
run: .github/workflows/scripts/env.sh

# Setup PHP.
- name: Setup PHP
id: setup_php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}

# Setup Node.
- name: Setup Node
id: setup_node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

# Installs npm and composer dependencies.
- name: Install
id: install
run: npm ci

# Runs a build.
- name: Build
id: build
run: npm run build

# Extracts the built theme zip file into a .deploy/ directory.
- name: Unzip Theme
id: unzip_theme
run: |
mkdir -p .deploy
unzip ${{ env.THEME_NAME }}.zip -d .deploy/
# Deploys the contents of .deploy/ to the theme directory on WPEngine.
# More information: https://my.wpengine.com/profile/github_action
# Manage WP Engine SSH keys: https://my.wpengine.com/profile/ssh_keys
- name: Deploy to WPEngine
id: deploy_to_wpengine
uses: wpengine/github-action-wpe-site-deploy@v3
with:
WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
WPE_ENV: ${{ env.WPE_ENV }}
SRC_PATH: .deploy/
REMOTE_PATH: wp-content/themes/${{ env.THEME_NAME }}/
FLAGS: -azvr --inplace --delete
5 changes: 5 additions & 0 deletions package/.github/workflows/scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ THEME_VERSION=$(jq -r ".version" package.json)

NODE_VERSION=$(cat .nvmrc)

# Get the theme name from the package.json file.

WPE_ENV=$(jq -r ".wpEngine.env" package.json)

# Set environment variables on $GITHUB_ENV.

echo "THEME_NAME=$(echo $THEME_NAME)" >> $GITHUB_ENV
echo "THEME_VERSION=$(echo $THEME_VERSION)" >> $GITHUB_ENV
echo "PHP_VERSION=$(echo $PHP_VERSION)" >> $GITHUB_ENV
echo "NODE_VERSION=$(echo $NODE_VERSION)" >> $GITHUB_ENV
echo "WPE_ENV=$(echo $WPE_ENV)" >> $GITHUB_ENV
21 changes: 21 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,24 @@ root
```

> **Note:** The map files are only output when running a development build. They will not be included when building for production.
## GitHub Actions

This theme uses GitHub Actions that automate various steps of the test, build, and deployment pipelines.

### Test

**Runs when a pull request to `main` is created** ― This action lints the code and runs a build; and fails when errors are found.

### Release

**Runs when a push to `main` is detected** ― This action runs a build and creates a release draft; and uploads a theme zip file as a release asset. The zip file will be named by the `name` key from the `package.json` file.

### Deploy

**Runs when a release is published** ― This action runs a build at the tag referenced in the release, and deploys the theme to the WP Engine environment specified in the `package.json` file at the `wpEngine.env` key.

> **More information:** https://my.wpengine.com/profile/github_action
> **Manage WP Engine SSH keys:** https://my.wpengine.com/profile/ssh_keys
3 changes: 3 additions & 0 deletions package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"versionRequired": "6.4.0",
"versionTested": "6.4.0"
},
"wpEngine": {
"env": "wpthemedev"
},
"browserslist": {
"development": [
"last 1 versions"
Expand Down
11 changes: 7 additions & 4 deletions package/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,17 @@ class ThemePackageBuilderPlugin {
fs.cpSync(this.composerVendorPath, this.composerVendorBackupPath, { recursive: true, force: true });
fs.rmSync(this.composerVendorPath, { recursive: true, force: true });
}
execSync('composer install --no-dev', { stdio: 'inherit' });
logger.info('Replaced composer dependencies successfully');
logger.info('Replacing Composer dependencies...');
execSync('composer install --no-dev', { stdio: 'ignore' });
logger.info('Replaced Composer dependencies successfully');
}

/**
* @param {webpack.Compiler} compiler
*/
restoreComposerDeps(compiler) {
const logger = compiler.getInfrastructureLogger(this.pluginName);
logger.info('Restoring Composer dependencies...');
if (fs.existsSync(this.composerLockBackupPath)) {
fs.cpSync(this.composerLockBackupPath, this.composerLockPath, { force: true });
fs.rmSync(this.composerLockBackupPath, { force: true });
Expand All @@ -216,7 +218,7 @@ class ThemePackageBuilderPlugin {
if (fs.readdirSync(this.tmpPath).length < 1) {
fs.rmSync(this.tmpPath, { recursive: true, force: true });
}
logger.info('Restored composer dependencies successfully');
logger.info('Restored Composer dependencies successfully');
}

/**
Expand Down Expand Up @@ -277,7 +279,8 @@ class ThemePackageBuilderPlugin {
*/
buildPot(compiler) {
const logger = compiler.getInfrastructureLogger(this.pluginName);
execSync(`composer run translate . languages/${this.pkg.name}.pot`, { stdio: 'inherit' });
logger.info('Building POT file...');
execSync(`composer run translate . languages/${this.pkg.name}.pot`, { stdio: 'ignore' });
logger.info('POT file built successfully');
}

Expand Down

0 comments on commit 88cf497

Please sign in to comment.