Skip to content

Commit

Permalink
Merge pull request #561 from equalizedigital/william/no-issue/automat…
Browse files Browse the repository at this point in the history
…e-dot-org-releases

Automate release to dot org
  • Loading branch information
pattonwebz committed Apr 3, 2024
2 parents ce288f5 + e5153c9 commit 3bfd891
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .github/workflows/deploy-on-release-to-dot-org.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Deploy to WordPress.org Repository

# Allow manual triggering for testing but also trigger on release for real run
on:
workflow_dispatch:
release:
types: [released]

jobs:
# This job is based on and relies on the 10up action-wordpress-plugin-deploy action
deploy_to_wp_repository:
name: Deploy to WP.org
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Composer
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
coverage: none

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: NPM install, build and generate release artefacts
run: |
npm install
npm run build
npm run dist:dotorg
echo "::set-output name=zip-path::./dist/${{ github.event.repository.name }}/${{ github.event.repository.name }}.zip"
- name: WordPress plugin deploy
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
dry-run: true # exists to prevent accidental deploys during testing
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
BUILD_DIR: ./dist/${{ github.event.repository.name }}/

- name: Upload release asset
if: github.event.release # can only run in context of a release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.deploy.outputs.zip-path }}
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build": "npx webpack",
"dev": "npx webpack --watch --mode development",
"dist": "npx webpack --mode production && composer install --no-dev && composer dump-autoload --no-dev -o && ./scripts/dist.sh && composer install",
"dist:dotorg": "npx webpack --mode production && composer install --no-dev && composer dump-autoload --no-dev -o && ./scripts/dist.sh --keep-build-folder",
"lint": "./vendor/bin/phpcs && npm run lint:js",
"lint-staged-precommit": "lint-staged && npm run lint:js",
"lint:php": "./vendor/bin/phpcs",
Expand Down
27 changes: 26 additions & 1 deletion scripts/dist.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
#!/bin/bash

# Define the flag variable and set default value
KEEP_BUILD_FOLDER=false

# Parse command-line options
while getopts ":-:" opt; do
case $opt in
-)
case "${OPTARG}" in
keep-build-folder)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
KEEP_BUILD_FOLDER=$val
;;
*)
;;
esac;;
*)
;;
esac
done

#Remove the contents of the dist folder
rm -frd ./dist
mkdir ./dist
Expand All @@ -20,5 +42,8 @@ cd ./dist
zip -r accessibility-checker.zip ./accessibility-checker

#cleanup and drop back into the original dir
rm -r ./accessibility-checker
# Skip this step if the 'keep-build-folder' flag is true
if [ "$KEEP_BUILD_FOLDER" = false ] ; then
rm -r ./accessibility-checker
fi
cd ..

0 comments on commit 3bfd891

Please sign in to comment.