-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add bg process for migrating legacy data, and github workflow
- Loading branch information
1 parent
1a41470
commit 6a4c676
Showing
14 changed files
with
478 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const readmePath = path.join(__dirname, '../../readme.md'); | ||
const changelogPath = path.join(__dirname, '../../CHANGELOG.md'); | ||
const outputPath = path.join(__dirname, '../temp/readme.txt'); | ||
|
||
// Function to detect and remove badge lines | ||
function shouldRemoveLine(line) { | ||
return line.startsWith('[!') || line.includes('![Build Status]') || line.includes('badges/'); | ||
} | ||
|
||
function formatLine(line) { | ||
if (line.startsWith('### ')) { | ||
return `= ${line.replace('### ', '').trim()} =\n`; | ||
} | ||
if (line.startsWith('## ')) { | ||
return `== ${line.replace('## ', '').trim()} ==\n`; | ||
} | ||
if (line.startsWith('# ')) { | ||
return `=== ${line.replace('# ', '').trim()} ===\n`; | ||
} | ||
if (line.startsWith('**Q:')) { | ||
return `= ${line.replace('**Q:', '').replace('**', '').trim()} =\n`; | ||
} | ||
if (line.startsWith('**A:')) { | ||
return `${line.replace('**A:', '').replace('**', '').trim()}\n`; | ||
} | ||
// Replace **bold** and remove extra spaces | ||
return line.replace(/\*\*/g, '').replace(/\s+/g, ' ') + '\n'; | ||
} | ||
|
||
// Check if the output path (readme.txt) exists, and if not, create it | ||
function ensureFileExists(filePath) { | ||
const dir = path.dirname(filePath); | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirSync(dir, { recursive: true }); // Create directories if needed | ||
} | ||
if (!fs.existsSync(filePath)) { | ||
fs.writeFileSync(filePath, '', 'utf8'); // Create the file if it doesn't exist | ||
} | ||
} | ||
|
||
// Read the files and filter the lines | ||
function processFiles() { | ||
const readmeMd = fs.readFileSync(readmePath, 'utf8').split('\n'); | ||
const changelogMd = fs.readFileSync(changelogPath, 'utf8').split('\n'); | ||
const output = []; | ||
|
||
// Process readme.md file | ||
readmeMd.forEach(line => { | ||
if (!shouldRemoveLine(line)) { | ||
output.push(formatLine(line)); | ||
} | ||
}); | ||
|
||
// Process changelog.md and format accordingly | ||
changelogMd.forEach(line => { | ||
if (line.startsWith('### ')) { | ||
output.push(`= ${line.replace('### ', '').trim()} =\n`); | ||
} else { | ||
output.push(line + '\n'); | ||
} | ||
}); | ||
|
||
// Ensure the output file exists and write the content | ||
ensureFileExists(outputPath); | ||
fs.writeFileSync(outputPath, output.join(''), 'utf8'); | ||
console.log(`readme.txt generated at ${outputPath}`); | ||
} | ||
|
||
processFiles(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Deploy to WordPress SVN | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout the repository | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
# Step 2: Set up Node.js (use the latest stable version) | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 'lts/*' # Use latest LTS version of Node.js | ||
|
||
# Step 3: Install Node.js dependencies (if you have any, can be skipped if not needed) | ||
# - name: Install dependencies | ||
# run: npm install | ||
|
||
# Step 4: Generate readme.txt using the Node.js script in .github/scripts/ | ||
- name: Generate readme.txt | ||
run: node .github/scripts/generate-readme.js | ||
|
||
# Step 5: Install Subversion | ||
- name: Install Subversion | ||
run: sudo apt-get install subversion | ||
|
||
# Step 6: Deploy to WordPress SVN /trunk/ | ||
- name: Deploy to WordPress SVN /trunk/ | ||
env: | ||
SVN_USERNAME: ${{ secrets.WORDPRESS_USERNAME }} | ||
SVN_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }} | ||
run: | | ||
svn co https://plugins.svn.wordpress.org/discontinued-products/ svn-dir | ||
rsync -av --delete --exclude=".git" ./ svn-dir/trunk/ | ||
cp .github/temp/readme.txt svn-dir/trunk/readme.txt # Copy the newly generated readme.txt | ||
cd svn-dir | ||
svn add --force trunk/* | ||
svn commit -m "Deploying version ${{ github.ref }}" --username $SVN_USERNAME --password $SVN_PASSWORD --non-interactive | ||
# Step 7: Create a tag in WordPress SVN /tags/ | ||
- name: Create SVN Tag | ||
env: | ||
SVN_USERNAME: ${{ secrets.WORDPRESS_USERNAME }} | ||
SVN_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }} | ||
run: | | ||
VERSION=${GITHUB_REF/refs\/tags\/v/} | ||
svn cp https://plugins.svn.wordpress.org/discontinued-products/trunk https://plugins.svn.wordpress.org/discontinued-products/tags/$VERSION -m "Tagging version $VERSION" --username $SVN_USERNAME --password $SVN_PASSWORD --non-interactive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
{ | ||
"require": { | ||
"woocommerce/woocommerce-sniffs": "^0.1.0" | ||
"woocommerce/woocommerce-sniffs": "^0.1.3" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.