diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..3459c03b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,45 @@ +name: Deploy + +# Run deploy only on tag and master builds. +on: + push: + branches: + - master + release: + types: [published] + +jobs: + + deploy: + name: Deploy to WordPress.org + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + cache: 'npm' + node-version-file: '.nvmrc' + + - name: Setup PHP and Composer + uses: shivammathur/setup-php@v2 + with: + php-version: '5.6' + tools: composer:v2 + + - name: Install NPM dependencies + run: npm install + + - name: Authenticate with WordPress.org SVN + run: svn info --non-interactive --username "${{ secrets.SVN_USERNAME }}" --password "${{ secrets.SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ + + - name: Deploy to WordPress.org SVN + env: + DEPLOY_SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} + DEPLOY_TAG: ${{ contains( github.ref_type, 'tag' ) }} + DEPLOY_SKIP_CONFIRMATION: true + if: env.DEPLOY_SVN_USERNAME + run: npm run deploy diff --git a/Gruntfile.js b/Gruntfile.js index b75416d4..22070134 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,6 +11,16 @@ module.exports = function( grunt ) { invert: true, } ); + /** + * Check if CLI input appears to indicate a truthy value. + * + * @param {string} input Value to check. + * @return {boolean} If value appears to be truthy. + */ + function isTruthy( input ) { + return ( '1' === input || 'true' === input ); + } + grunt.initConfig( { pkg: grunt.file.readJSON( 'package.json' ), @@ -33,10 +43,15 @@ module.exports = function( grunt ) { plugin_slug: 'two-factor', build_dir: '<%= dist_dir %>', assets_dir: 'assets', - deploy_tag: false, }, - trunk: { - deploy_trunk: true, + wporg: { + options: { + skip_confirmation: isTruthy( process.env.DEPLOY_SKIP_CONFIRMATION ), + svn_user: process.env.DEPLOY_SVN_USERNAME, + deploy_tag: isTruthy( process.env.DEPLOY_TAG ), + deploy_trunk: isTruthy( process.env.DEPLOY_TRUNK ), + assets_dir: ( isTruthy( process.env.DEPLOY_TAG ) || isTruthy( process.env.DEPLOY_TRUNK ) ) ? 'assets' : null, + }, }, }, } ); @@ -51,7 +66,7 @@ module.exports = function( grunt ) { grunt.registerTask( 'deploy', [ 'build', - 'wp_deploy:trunk', + 'wp_deploy', ] ); }; diff --git a/readme.md b/readme.md index 85722856..9189fd25 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Two-Factor -[![Test](https://github.com/WordPress/two-factor/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/test.yml) +[![Test](https://github.com/WordPress/two-factor/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/test.yml) [![Deploy](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml) Two-Factor plugin for WordPress. [View on WordPress.org →](https://wordpress.org/plugins/two-factor/) @@ -21,6 +21,10 @@ Here is how to get started: Then open [a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) with the suggested changes. +## Deployments + +Deployments [to WP.org plugin repository](https://wordpress.org/plugins/two-factor/) are handled automatically by the GitHub action [.github/workflows/deploy.yml](.github/workflows/deploy.yml). All merges to the `master` branch are commited to the [`trunk` directory](https://plugins.trac.wordpress.org/browser/two-factor/trunk) while all [Git tags](https://github.com/WordPress/two-factor/tags) are pushed as versioned releases [under the `tags` directory](https://plugins.trac.wordpress.org/browser/two-factor/tags). + ## Known Issues - PHP codebase doesn't pass the WordPress coding standard checks, see [#437](https://github.com/WordPress/two-factor/issues/437). diff --git a/readme.txt b/readme.txt index b98ebe64..52229961 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: two factor, two step, authentication, login, totp, fido u2f, u2f, email, b Requires at least: 4.3 Tested up to: 6.0 Requires PHP: 5.6 -Stable tag: trunk +Stable tag: 0.7.2 Enable Two-Factor Authentication using time-based one-time passwords (OTP, Google Authenticator), Universal 2nd Factor (FIDO U2F, YubiKey), email and backup verification codes.