Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-o committed May 12, 2024
1 parent d95afc1 commit 71ae1de
Show file tree
Hide file tree
Showing 13 changed files with 1,056 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push-asset-readme-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4

- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
uses: nk-crew/action-wordpress-plugin-asset-update@develop
env:
SLUG: redirect-txt
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
Expand Down
Binary file added .wordpress-org/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const path = require('path');

const gulp = require('gulp');
const changeFileContent = require('gulp-change-file-content');
const yargs = require('yargs/yargs');
const parseVersionString = require('parse-version-string').default;

const pkg = require('./package.json');

const currentVersion = pkg.version;
const currentVersionData = parseVersionString(pkg.version);
const bumpFiles = {
// Version in the package file.
'./package.json': /("version": ")[0-9][0-9.a-zA-Z-]*(",$)/gm,
// Version in the readme file.
'./readme.txt': /(^\* Stable tag: )[0-9][0-9.a-zA-Z-]*($)/gm,
'./redirect-txt.php': [
// Version in the file header.
/(\* Version:\s\s+)[0-9][0-9.a-zA-Z-]*($)/gm,

// Version in the constant definition.
/(define\( 'REDIRECT_TXT_VERSION', ').*(' \);$)/gm,
],
};

// Bump current version number.
// gulp bump --type major : bumps 1.0.0
// gulp bump --type minor : bumps 0.1.0
// gulp bump --type patch : bumps 0.0.2
// gulp bump --type prerelease : bumps 0.0.1-alpha.2
gulp.task('bump', (done) => {
let newVersion = '';

const { argv } = yargs(process.argv.slice(2));
const { major, minor, preReleaseType, preReleaseIncrement } =
currentVersionData;
let { patch } = currentVersionData;

switch (argv.type) {
case 'major':
newVersion = `${(major || 0) + 1}.0.0`;
break;
case 'minor':
newVersion = `${major || 0}.${(minor || 0) + 1}.0`;
break;
case 'prerelease':
if (!preReleaseIncrement) {
patch = (patch || 0) + 1;
}

newVersion = `${major || 0}.${minor || 0}.${patch || 0}-${
preReleaseType || 'alpha'
}.${(preReleaseIncrement || 0) + 1}`;
break;

// patch
default:
newVersion = `${major || 0}.${minor || 0}.${(patch || 0) + 1}`;
break;
}

Object.keys(bumpFiles).forEach((src) => {
gulp.src(src)
.pipe(
changeFileContent((content) => {
if (!Array.isArray(bumpFiles[src])) {
bumpFiles[src] = [bumpFiles[src]];
}

bumpFiles[src].forEach((reg) => {
content = content.replace(reg, `$1${newVersion}$2`);
});

return content;
})
)
.pipe(
gulp.dest((file) => {
return path.dirname(file.path);
})
);
});

// eslint-disable-next-line no-console
console.log(
`Bumped version from %cv${currentVersion}%c to %cv${newVersion}`,
'color: #f08d49',
'',
'color: #7ec699'
);

done();
});
Loading

0 comments on commit 71ae1de

Please sign in to comment.