DEV Community

Slava Vasenin for Visual Composer

Posted on

5 4

How to get WordPress plugin release in GitHub actions

We started to use GitHub actions to build Visual Composer release candidates in GitHub. This action will prepare a proper zip archive file which we can use to update our plugin in Wordpress.org.

We decided that the release will be built on the new tag. The tag will be the version of the published release.

on:
  push:
    tags:
      - '*'
Enter fullscreen mode Exit fullscreen mode

We already had the script which was able to create a valid zip archive of Visual Composer Website Builder for Wordpress.org. It looks like this.

$ node _infrastructure/vcwb-builder/builder plugin -b VERSION -p ./_infrastructure
Enter fullscreen mode Exit fullscreen mode

Yeah, this script will set plugin version also -b VERSION. The question is how to get the version from GitHub tag. There is access to $GITHUB_REF where we can get tags. I decide to create variable get_version which can be used in other steps of the job.

- name: Get the version
  id: get_version
  run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
Enter fullscreen mode Exit fullscreen mode

Then we just need to use steps.version_version in the next step.

- name: Build project
  run: |
    yarn install
    node _infrastructure/vcwb-builder/builder plugin -b ${{ steps.get_version.outputs.VERSION }} -p ./_infrastructure
Enter fullscreen mode Exit fullscreen mode

The next action is to create Github release itself.

- name: Create Release
  id: create_release
  uses: actions/create-release@v1.0.0
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    tag_name: ${{ github.ref }}
    release_name: ${{ github.ref }}
    draft: false
    prerelease: false
Enter fullscreen mode Exit fullscreen mode

After release creation needs to upload our zip archive. I use actions/upload-release-asset@v1.0.1 action for that.

- name: Upload Release Asset
  id: upload_release_asset
  uses: actions/upload-release-asset@v1.0.1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    upload_url: ${{ steps.create_release.outputs.upload_url }}
    asset_path: ./_infrastructure/visualcomposer.zip
    asset_name: visualcomposer.zip
    asset_content_type: application/zip
Enter fullscreen mode Exit fullscreen mode

That's it. The full version of the configuration file you can check here.

Good luck ✌️

Image of Wix Studio

2025: Your year to build apps that sell

Dive into hands-on resources and actionable strategies designed to help you build and sell apps on the Wix App Market.

Get started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay