Skip to content

Commit

Permalink
GitHub Action – Publish Release (#203)
Browse files Browse the repository at this point in the history
* drafting github action for publishing new releases

* update bundle script to export zip file abspath in GitHub Actions

* only run phpcs when PHP files are updated

* improve entire folder exclusions

* attempt to fix grep compatibility, attempt artifact upload

* fix artifact name extra zip suffix, attempt dry run wporg publish

* rn exclusions list to standard distignore filename

* finalize publish release workflow events
  • Loading branch information
MichelleBlanchette authored Dec 10, 2023
1 parent ec4dc5c commit 4fb7425
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 8 deletions.
12 changes: 10 additions & 2 deletions exclude.lst → .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ completionist/*.log
completionist/*.map
completionist/*.sh
completionist/*.DS_Store
completionist/.git*
completionist/.gitignore
completionist/.github/*
completionist/.github
completionist/.git/*
completionist/.git
completionist/.wordpress-org/*
completionist/.wordpress-org
completionist/exclude.lst
completionist/.distignore
completionist/composer.json
completionist/composer.lock
completionist/node_modules/*
completionist/node_modules
completionist/package-lock.json
completionist/package.json
completionist/phpcs.xml
completionist/assets/styles/scss/*
completionist/assets/styles/scss
completionist/src/components/*
completionist/src/components
completionist/src/*.js
completionist/src/*.jsx
5 changes: 4 additions & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: PHPCS Check

on: [pull_request]
on:
pull_request:
paths:
- '**.php'

jobs:
phpcs:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Release

on:
push:
tags:
- "v*"
- "!v**-rc.*"

jobs:
tag:
name: New release
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Build - Install
run: ./build_install.sh
shell: bash

- name: Bundle Package
run: ./bundle.sh
shell: bash

- name: Upload ZIP File
uses: actions/upload-artifact@v3
with:
name: ${{ env.PTC_PLUGIN_ZIP_FILE_BASENAME }}
path: ${{ env.PTC_PLUGIN_ZIP_FILE }}

- name: Publish WordPress Plugin Release
uses: 10up/action-wordpress-plugin-deploy@stable
with:
dry-run: true
generate-zip: false
env:
SVN_USERNAME: ${{ secrets.WPORG_SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.WPORG_SVN_PASSWORD }}
2 changes: 1 addition & 1 deletion build_cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

for PATTERN in $(cat "exclude.lst")
for PATTERN in $(cat ".distignore")
do rm -rf "../"${PATTERN}
done
31 changes: 28 additions & 3 deletions bundle.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
#!/bin/bash

# Determine package values.

PLUGIN_SLUG=$( basename `pwd` )

VERSION=$(grep -Eio 'Version:\s*[0-9\.]+' "${PLUGIN_SLUG}.php" | grep -Eo '[0-9\.]+')
VERSION=$(grep -Eio 'Version:\s*[0-9]+\.[0-9]+\.[0-9]+(\-rc\.[0-9]+)?' "${PLUGIN_SLUG}.php" | grep -Eio '[0-9]+\.[0-9]+\.[0-9]+(\-rc\.[0-9]+)?')

# Create the plugin package.

pushd ..

PLUGIN_ZIP_FILE=$( pwd )/"${PLUGIN_SLUG}-${VERSION}.zip"

zip -rT9X "${PLUGIN_ZIP_FILE}" "${PLUGIN_SLUG}" --exclude @"${PLUGIN_SLUG}"/.distignore

popd

# Maybe export variables for GitHub Action.

if [ -n "$GITHUB_ENV" ]; then
echo "PTC_PLUGIN_ZIP_FILE_BASENAME=$( basename -s '.zip' "$PLUGIN_ZIP_FILE" )" >> "$GITHUB_ENV"
echo "PTC_PLUGIN_ZIP_FILE=${PLUGIN_ZIP_FILE}" >> "$GITHUB_ENV"
echo "Exported GitHub ENV variables."
else
echo "Did not set \$GITHUB_ENV variables."
fi

# Final notes.

cd ..
zip -rT9X "${PLUGIN_SLUG}-${VERSION}.zip" "${PLUGIN_SLUG}" --exclude @"${PLUGIN_SLUG}"/exclude.lst
echo
echo "!! Finished bundling plugin package: ${PLUGIN_ZIP_FILE}"
echo
2 changes: 1 addition & 1 deletion completionist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Completionist – Asana for WordPress
* Plugin URI: https://purpleturtlecreative.com/completionist/
* Description: Manage, pin, automate, and display Asana tasks in relevant areas of your WordPress admin and website frontend.
* Version: 4.0.0
* Version: 4.0.0-rc.5
* Requires PHP: 7.2
* Requires at least: 5.0.0
* Tested up to: 6.4.2
Expand Down

0 comments on commit 4fb7425

Please sign in to comment.