Skip to content

Commit

Permalink
Merge pull request #29 from helgatheviking/features/block
Browse files Browse the repository at this point in the history
Features/block
  • Loading branch information
helgatheviking authored Mar 25, 2024
2 parents 16625b7 + e1ec380 commit 019e3a1
Show file tree
Hide file tree
Showing 29 changed files with 36,862 additions and 118 deletions.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/.github
/node_modules
/build
/src

*.sublime-project
*.afdesign
Expand Down
160 changes: 142 additions & 18 deletions .github/workflows/push-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,147 @@
name: Deploy to WordPress.org
# Add build zip to GitHub releases.
# Version: 1.1.0
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Release

on:
push:
tags-ignore:
- 'v*-alpha*'
- 'v*-beta*'
- 'v*-rc*'
tags:
# Semver (https://semver.org/) release pattern.
- '[0-9]+.[0-9]+.[0-9]+*'

jobs:
tag:
name: New tag
# Build distribution release.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP with Composer.
# - Logs debug information.
# - Get Composer Cache Directory.
# - Sets up Composer Caching..
# - Logs debug information.
# - Install Composer dependencies with development dependencies.
# - Setup NodeJS.
# - Get NPM cache directory.
# - Sets up NPM Caching.
# - Install NPM dependencies.
# - Get release version.
# - Check for Alpha release.
# - Check for Beta release.
# - Check for Release Candidate release.
# - Logs debug information.
# - Build release:
# - Pre-release.
# - Stable.
# - Add package to GitHub releases.

dist:
name: "Build distribution release."
runs-on: ubuntu-latest
env:
release: stable
steps:
- uses: actions/checkout@master
- name: Build # Remove or modify this step as needed
run: |
npm install
npm run build
- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@stable
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: simple-user-listing

- name: "Checks out the repository."
uses: "actions/checkout@v4"

- name: "Sets up PHP with Composer."
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Get Composer Cache Directory."
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: "Sets up Composer Caching."
uses: "actions/cache@v4"
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-composer-build-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-composer-build-
- name: "Logs debug information."
run: |
php --version
composer --version
- name: "Install Composer dependencies with development dependencies."
run: |
composer install --no-interaction --prefer-dist --no-scripts
- name: "Setup NodeJS."
uses: actions/setup-node@v4
with:
node-version: '16'

- name: "Get NPM cache directory."
id: npm-cache-dir
run: |
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: "Sets up NPM Caching."
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-npm-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-npm-build-
- name: "Install NPM dependencies."
run: npm install

- name: "Get release version."
run: |
echo "release_tag=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
- name: "Get release file base name."
run: |
echo "release_name=$(node -p -e "require('./package.json').name")" >> $GITHUB_ENV
- name: "Check for Alpha release."
if: ${{ contains(env.release_tag, '-alpha') }}
run: |
echo "release_status=pre-release" >> $GITHUB_ENV
- name: "Check for Beta release."
if: ${{ contains(env.release_tag, '-beta') }}
run: |
echo "release_status=pre-release" >> $GITHUB_ENV
- name: "Check for Release Candidate release."
if: ${{ contains(env.release_tag, '-rc') }}
run: |
echo "release_status=pre-release" >> $GITHUB_ENV
- name: "Logs debug information."
run: |
node --version
npm --version
echo ${{ env.release_tag }}
echo ${{ env.release_status }}
- name: "Build release"
run: |
npm run deploy
- name: "Add package to GitHub releases."
uses: softprops/action-gh-release@v1
with:
files: ./deploy/${{ env.release_name }}-${{ env.release_tag }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Deploy Stable Release to WordPress.org"
if: ${{ env.release_status != 'pre-release' }}
uses: 10up/action-wordpress-plugin-deploy@stable
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: simple-user-listing
BUILD_DIR: ./build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
node_modules/
vendor/
build/
*.DS_Store
*.afdesign
.cache/
*.sublime-workspace
dist/
44 changes: 24 additions & 20 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(grunt) {

clean: {
//Clean up build folder
main: ['build/<%= pkg.name %>']
main: ['build/**']
},

copy: {
Expand All @@ -22,6 +22,7 @@ module.exports = function(grunt) {
'!.git/**','!.gitignore','!.gitmodules',
'!tests/**',
'!vendor/**',
'!src/**',
'!Gruntfile.js','!package.json','!package-lock.json',
'!composer.lock','!composer.phar','!composer.json',
'!CONTRIBUTING.md',
Expand All @@ -39,9 +40,23 @@ module.exports = function(grunt) {
'!.wordpress-org/**',
'!.github/**',
],
dest: 'build/<%= pkg.name %>/'
dest: 'build/'
},
},
},

// Make a zipfile.
compress: {
main: {
options: {
mode: 'zip',
archive: 'deploy/<%= pkg.name %>-<%= pkg.version %>.zip',
},
expand: true,
cwd: 'build/',
dest: '<%= pkg.name %>',
src: [ '**/*' ]
},
},

// bump version numbers
replace: {
Expand Down Expand Up @@ -98,23 +113,12 @@ module.exports = function(grunt) {
}
},

// Generate .pot file
makepot: {
target: {
options: {
domainPath: '/languages', // Where to save the POT file.
exclude: ['build'], // List of files or directories to ignore.
mainFile: '<%= pkg.name %>.php', // Main project file.
potFilename: '<%= pkg.name %>.pot', // Name of the POT file.
type: 'wp-plugin' // Type of project (wp-plugin or wp-theme).
}
}
},

});
});

grunt.registerTask( 'docs', [ 'wp_readme_to_markdown'] );
grunt.registerTask( 'build', [ 'replace', 'makepot' ] );
grunt.registerTask( 'release', [ 'build', 'clean', 'copy' ] );
grunt.registerTask( 'docs', [ 'wp_readme_to_markdown'] );
grunt.registerTask( 'build', [ 'replace', 'clean', 'copy' ] );
grunt.registerTask( 'deploy', [ 'build', 'compress' ] );
grunt.registerTask( 'release', [ 'deploy', 'clean' ] );
grunt.registerTask( 'zip', [ 'clean', 'copy', 'compress' ] );

};
13 changes: 13 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"require-dev": {
"wp-cli/i18n-command": "^2.6"
},
"scripts": {
"makepot-audit": [
"wp --allow-root i18n make-pot . languages/free_gift_coupons.pot --slug=wc_free_gift_coupons --exclude=\".github,.wordpress-org,node_modules,vendor,src,build,deploy\" --headers=\"Report-Msgid-Bugs-To: https://woocommerce.com/my-account/tickets/\n\""
],
"makepot": [
"@makepot-audit --skip-audit"
]
}
}
Loading

0 comments on commit 019e3a1

Please sign in to comment.