Using gitattributes to make releasing WordPress themes easier
Zuari releases have been few and far apart in the last year. While I work on Zuari often, I cut a release only when I know I’ll have time to fix things in case they break for someone. This has meant that I haven’t paid much thought to the release process. Till now, I would create a copy of the directory, go through my list of files to delete, delete them and create an archive to upload to WordPress.org. As you can see this process is manual and error prone.
While looking at David’s syndication-links repository I saw a
.gitattributes file. I had seen it before but never looked into it. Turns out, that among other things, you can use it to define a list of files to ignore when creating a
So, I setup the following
.gitattributes file for my WordPress themes:
# Git .gitignore export-ignore .gitattributes export-ignore # Styles .sass-cache export-ignore *.css.map export-ignore **/*.scss export-ignore .stylelintrc.json export-ignore # Scripts Gruntfile.js export-ignore package.json export-ignore package-lock.json export-ignore node_modules export-ignore .storybook export-ignore .babelrc export-ignore # Github README.md export-ignore .github export-ignore # Composer composer.json export-ignore composer.lock export-ignore vendor export-ignore phpcs.xml.dist export-ignore
And now, to create the zip file for uploading on WordPress.org I simply run:
git archive master -o theme-name.zip
No more manual work, no more slips and mistakes.
Releasing a theme (or any other package for that matter) requires quite a few steps. And if you don’t release often it’s easy to forget and miss something. For this reason, the most important thing in Zuari’s otherwise inadequate README are the release steps. Documentation is as important for our future-selves as it is for others.