< All Topics

User Build Processes

Many users have different build processes that may be helpful to others.

Bitbucket (For themes)

These steps may be applicable to more services but have only been tested within Bitbucket. This setup will create a new release asset when the style.css file within the theme has its’ version updated, and that version doesn’t already exist as a release. It will automatically create the tag alongside all other steps.


Required environment variables to be set on your repo and preferably hidden:

  • $GITHUB_ACCESS_TOKEN: Generate this from your github account to prevent rate limiting with composer
  • $APP_USERNAME: The bitbucket account that has admin access to this repo
  • $APP_PASSWORD: The password for the bitbucket account

Vars provided by Bitbucket:


A specimen pipeline can be found below as a point of reference

Specimen Bitbucket Pipeline

# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.1.29

    # Execute change detection only on master branch
      - step:
          image: atlassian/default-image:2
          # Run change detection script (requires git command)
            - ./changedetected.sh
    # Build and upload release asset each time a new tag is pushed
      - step:
            - composer
            - node
            # Setup Environment
            - apt-get update && apt-get install -y unzip zip
            - curl -sL https://deb.nodesource.com/setup_13.x | bash -
            - apt-get install -y nodejs
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            # Install node and composer dependencies
            - composer config -g github-oauth.github.com $GITHUB_ACCESS_TOKEN
            - composer install --prefer-dist
            - npm install
            # Build all script and style assets (if you use a node based build toolchain)
            - npm run build
            # Zip and upload new release (replace directories to zip with your own)
            - zip -r -q release/$BITBUCKET_REPO_SLUG-$BITBUCKET_TAG.zip *.php assets/ fonts/ languages/ inc/ page-templates/ views/ vendor/ style.css screenshot.jpg
            - pipe: atlassian/bitbucket-upload-file:0.1.2
                FILENAME: 'release/$BITBUCKET_REPO_SLUG-$BITBUCKET_TAG.zip'

Change Detection Script

This is a simple bash script that checks if style.css is in the list of updated files for the current commit. If a change is detected, it checks if a tag already exists for the current release version. If the release doesn’t already exist, it creates a new tag and pushes it to the master repo; which will then trigger the release build in the main pipeline.

The specimen change detection script can be found below

Specimen Change Detection Bash Script


revcount=$(git rev-list --all --count)

if [ "$revcount" -gt 1 ]
  histdiff=$(git diff --name-only HEAD HEAD~1 | grep 'style.css')
  if [ "$histdiff" = "style.css" ]
    version=$(grep "Version:" style.css | cut -d ':' -f 2 | xargs)
    if git rev-parse "$version" >/dev/null 2>&1 
      echo "Tag already exists; no action taken"
      echo "Creating new tag ${version}"
      changeref=$(git rev-parse HEAD)
      git tag -a ${version} ${changeref} -m "Release version ${version}"
      git push origin --tags
    echo "style.css not changed"
  echo "History too short"
Table of Contents