Update and simplify build process
This commit is contained in:
parent
748af6a14f
commit
d7ee54fcec
|
@ -1,9 +0,0 @@
|
|||
src
|
||||
node_modules
|
||||
|
||||
README.md
|
||||
.*
|
||||
package.json
|
||||
yarn.lock
|
||||
webpack.config.js
|
||||
tsconfig.json
|
|
@ -0,0 +1,53 @@
|
|||
name: release
|
||||
on: [ push ]
|
||||
jobs:
|
||||
release-to-github:
|
||||
name: Release to GitHub
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(github.ref, 'main')
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: main
|
||||
|
||||
- name: Check if version has changed
|
||||
uses: EndBug/version-check@v1
|
||||
id: check
|
||||
|
||||
- name: Version update detected
|
||||
if: steps.check.outputs.changed == 'true'
|
||||
run: 'echo "Version change found! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"'
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.check.outputs.changed == 'true'
|
||||
run: npm install
|
||||
|
||||
- name: Build plugin zip
|
||||
if: steps.check.outputs.changed == 'true'
|
||||
run: npm run create-zip
|
||||
|
||||
- name: Create release
|
||||
if: steps.check.outputs.changed == 'true'
|
||||
uses: actions/create-release@v1
|
||||
id: create_release
|
||||
with:
|
||||
draft: false
|
||||
prerelease: false
|
||||
release_name: ${{ steps.check.outputs.version }}
|
||||
tag_name: ${{ github.ref }}
|
||||
body_path: CHANGELOG.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Upload artifact
|
||||
if: steps.check.outputs.changed == 'true'
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./cognito-forms-${{ steps.check.outputs.version }}.zip
|
||||
asset_name: cognito-forms-${{ steps.check.outputs.version }}.zip
|
||||
asset_content_type: application/zip
|
|
@ -1,2 +1,3 @@
|
|||
node_modules
|
||||
dist/
|
||||
*.zip
|
||||
|
|
|
@ -102,7 +102,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
// Register block editor styles for backend.
|
||||
wp_register_style(
|
||||
'cognito-block-editor-css', // Handle.
|
||||
plugins_url( 'dist/editor.css', __FILE__ ), // Block editor CSS.
|
||||
plugins_url( 'dist/main.css', __FILE__ ), // Block editor CSS.
|
||||
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
|
||||
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
|
||||
);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import { src, dest } from 'gulp';
|
||||
import zip from 'gulp-zip';
|
||||
import pjson from './package.json';
|
||||
|
||||
export default function() {
|
||||
return src( [
|
||||
'**/*',
|
||||
'!src/**',
|
||||
'!node_modules/**',
|
||||
'!README.md',
|
||||
'!.*',
|
||||
'!package.json',
|
||||
'!yarn.lock',
|
||||
'!webpack.config.*',
|
||||
'!tsconfig.*',
|
||||
'!gulpfile.*',
|
||||
] )
|
||||
.pipe( zip( `cognito-forms-${ pjson.version }.zip` ) )
|
||||
.pipe( dest( '.' ) );
|
||||
}
|
19
package.json
19
package.json
|
@ -4,13 +4,10 @@
|
|||
"private": true,
|
||||
"main": "src/blocks.ts",
|
||||
"scripts": {
|
||||
"lint:js": "wp-scripts lint-js 'src/**/*{.js,.jsx,.ts,.tsx}'",
|
||||
"build:js": "webpack --mode=production",
|
||||
"build:sass": "sass src/styles:dist",
|
||||
"build": "npm run build:js && npm run build:sass",
|
||||
"watch:js": "webpack --mode=development --watch",
|
||||
"watch:sass": "sass -w src/styles:dist",
|
||||
"start": "shx rm -rf dist/* && concurrently -n \"JS,CSS\" -c \"bgBlue.bold,bgMagenta.bold\" --kill-others \"npm run watch:js\" \"wait-on dist/index.js && npm run watch:sass\""
|
||||
"lint": "wp-scripts lint-js 'src/**/*{.js,.jsx,.ts,.tsx}'",
|
||||
"build": "webpack --mode=production",
|
||||
"start": "webpack --mode=development --watch",
|
||||
"create-zip": "npm run build && gulp"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
|
@ -49,11 +46,11 @@
|
|||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||
"@typescript-eslint/parser": "^5.10.0",
|
||||
"concurrently": "^7.0.0",
|
||||
"eslint-plugin-jest": "^25.7.0",
|
||||
"esm": "^3.2.25",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-zip": "^5.1.0",
|
||||
"prettier": "^2.0.5",
|
||||
"sass": "^1.48.0",
|
||||
"shx": "^0.3.4",
|
||||
"wait-on": "^6.0.0"
|
||||
"sass": "^1.48.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,20 @@
|
|||
*/
|
||||
|
||||
import { registerBlockType } from '@wordpress/blocks';
|
||||
|
||||
import { IBlockAttributes } from './types';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
* Internal dependencies
|
||||
*/
|
||||
import Edit from './edit';
|
||||
import Save from './save';
|
||||
|
||||
/**
|
||||
* Stylesheets
|
||||
*/
|
||||
import './styles/editor.scss';
|
||||
import './styles/style.scss';
|
||||
|
||||
import { ReactComponent as CogIcon } from './assets/cogicon.svg';
|
||||
|
||||
registerBlockType<IBlockAttributes>( 'cognito-forms/cognito-embed', {
|
||||
|
|
Loading…
Reference in New Issue