DEV Community

Paul
Paul

Posted on • Originally published at boldoak.design

Automatically creating the release for a WordPress theme

The new GitHub Action I’ve set up will build a new downloadable copy of a WordPress theme when I create a new release or tag in its GitHub repository. In this regard, it’s still fired off by a manual action, but the uploaded file is automatically attached to the new release. This way I can create a new release and just concern myself with writing the description, without having to manually build the theme and upload its zip file.

My Workflow

My WordPress theme uses Justin Tadlock's Mythic starter theme as its base. As such, it has both Composer and npm dependencies, both of which must be included for the theme to work. To that end, I've created a new GitHub Action called "Generate Installable Theme and Upload as Release Asset" to automate this process.

Alt Text

The action is fired off when I create a new release (through either the Releases or Tags tab), which will download the production build's Composer and npm dependencies. (These are slightly different than a development build, which has linting utilities not used in production.) The theme's internal build process uses webpack to compile CSS and JavaScript assets, so this same process is invoked by the action once all dependencies are downloaded.

The final result is a zip file suitable for upload and installation in WordPress, which is then attached to the aforementioned release (or tag).

Alt Text

Submission Category:

  • DIY Deployments

Yaml File or Link to Code

main.yml

GitHub logo peiche / garrick

Garrick is a modern, multi-purpose WordPress theme built to be compatible with the core block editor and page builder.

Additional Resources / Info

I took inspiration from Leonardo Losoviz's post on how he accomplished a similar process for a WordPress plugin. I probably would have had a more difficult time figuring this out without his code to learn from.


This post was originally published on Bold Oak Design.

Top comments (0)