Skip to content

Commit 92b15db

Browse files
authored
Merge pull request #33 from WebDevStudios/feature/Versioning-script
Feature/versioning script
2 parents d25d2a2 + ad3c337 commit 92b15db

File tree

14 files changed

+36565
-31417
lines changed

14 files changed

+36565
-31417
lines changed

.github/workflows/version-update.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Update Version on Merge to Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update-version:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '20'
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Run version update script
25+
run: node updateVersion.js
26+
27+
- name: Commit and push changes
28+
run: |
29+
git config --global user.name 'github-actions[bot]'
30+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
31+
git add .env style.css package.json composer.json
32+
git commit -m "Automated version update after merge to main"
33+
git push origin main

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- [Stylelint Configuration](#stylelint-configuration)
2525
- [Extends](#extends)
2626
- [Accessibility and Code Quality and Security Checks](#accessibility-and-code-quality-and-security-checks)
27+
- [Automated Versioning Process](#automated-versioning-process)
2728
- [Contributing and Support](#contributing-and-support)
2829

2930
</details>
@@ -539,6 +540,83 @@ WDS BT is equipped with automated workflow actions that ensure code security and
539540

540541
***
541542

543+
## Automated Versioning Process
544+
545+
This theme uses an automated versioning system that increments the `BUILD` number automatically upon merges to the `main` branch. The `VERSION` is manually controlled and is reflected in the `composer.json` and `package.json` files. The `BUILD` number is automatically appended to the `VERSION` in `style.css`.
546+
547+
<details>
548+
<summary><strong>How It Works</strong></summary>
549+
550+
1. **VERSION**: Manually set in the `.env` file. This is reflected in the `composer.json` and `package.json` files.
551+
- Format: `X.Y.Z` (Semantic Versioning)
552+
- This value is manually updated by the developer.
553+
554+
2. **BUILD**: Automatically increments on merges to the `main` branch. This is appended to the `VERSION` in the `style.css` file.
555+
- Format: `1.0.0x` where `x` is the build number.
556+
557+
</details>
558+
559+
<details>
560+
<summary><strong>Example</strong></summary>
561+
562+
Suppose the `.env` file has the following values:
563+
564+
```plaintext
565+
VERSION=1.0.0
566+
BUILD=4
567+
```
568+
569+
After merging a PR into the `main` branch:
570+
571+
- The `BUILD` increments to `5`.
572+
- The version in `style.css` becomes `Version: 1.0.005`.
573+
- The `composer.json` and `package.json` will still reflect `1.0.0`.
574+
575+
</details>
576+
577+
<details>
578+
<summary><strong>Modifying the Version</strong></summary>
579+
580+
- To update the `VERSION`, manually edit the `.env` file:
581+
```plaintext
582+
VERSION=1.1.0
583+
BUILD=0
584+
```
585+
- The `BUILD` should not be manually modified except for specific scenarios, such as resetting the build number after a major version change.
586+
587+
</details>
588+
589+
<details>
590+
<summary><strong>Workflow</strong></summary>
591+
592+
When a PR is merged into the `main` branch, the following occurs automatically:
593+
594+
1. The `BUILD` number increments.
595+
2. The `style.css` is updated to reflect the `VERSION + BUILD`.
596+
3. The `composer.json` and `package.json` files are updated with only the `VERSION`.
597+
4. The updated files are committed back to the `main` branch.
598+
599+
</details>
600+
601+
<details>
602+
<summary><strong>Manual Execution</strong></summary>
603+
604+
You can manually trigger the versioning process locally if necessary by running:
605+
606+
```bash
607+
npm run update-version
608+
```
609+
610+
This will:
611+
612+
- Increment the `BUILD` number.
613+
- Update the version in `style.css`.
614+
- Ensure `composer.json` and `package.json` reflect the correct `VERSION`.
615+
616+
</details>
617+
618+
***
619+
542620
## Contributing and Support
543621

544622
Your contributions and [support tickets](https://github.com/WebDevStudios/wds-bt/issues) are welcome. Please see our [contributing guidelines](https://github.com/WebDevStudios/wds-bt/blob/main/CONTRIBUTING.md) before submitting a pull request.

assets/scss/patterns/_index.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
// 'patterns/' houses styles for custom patterns.
22
// @import './pattern-name';
3-
@import './related-posts';

assets/scss/patterns/related-posts.scss

Lines changed: 0 additions & 19 deletions
This file was deleted.

composer.json

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
{
2-
"name": "webdevstudios/wds-bt",
3-
"version": "1.0.0",
4-
"description": "A block starter theme from WebDevStudios.",
5-
"type": "wordpress-theme",
6-
"license": "GPL-2.0-or-later",
7-
"authors": [
8-
{
9-
"name": "WebDevStudios",
10-
"email": "[email protected]"
11-
}
12-
],
13-
"config": {
14-
"platform": {
15-
"php": "8.2"
16-
},
17-
"allow-plugins": {
18-
"composer/installers": true,
19-
"dealerdirect/phpcodesniffer-composer-installer": true,
20-
"squizlabs/php_codesniffer": true,
21-
"wp-coding-standards/wpcs": true
22-
},
23-
"sort-packages": true
24-
},
25-
"require": {
26-
"composer/installers": "^2.3.0"
27-
},
28-
"require-dev": {
29-
"php": ">=8.2",
30-
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
31-
"phpcompatibility/phpcompatibility-wp": "^2.1.5",
32-
"squizlabs/php_codesniffer": "^3.10.2",
33-
"wp-cli/wp-cli-bundle": "^2.11.0",
34-
"wp-coding-standards/wpcs": "^3.1.0"
35-
},
36-
"scripts": {
37-
"phpcs": "./vendor/bin/phpcs --report=full,source",
38-
"phpcs-fix": "./vendor/bin/phpcbf --report=summary,source"
39-
}
40-
}
2+
"name": "webdevstudios/wds-bt",
3+
"version": "1.0.0",
4+
"description": "A block starter theme from WebDevStudios.",
5+
"type": "wordpress-theme",
6+
"license": "GPL-2.0-or-later",
7+
"authors": [
8+
{
9+
"name": "WebDevStudios",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"config": {
14+
"platform": {
15+
"php": "8.2"
16+
},
17+
"allow-plugins": {
18+
"composer/installers": true,
19+
"dealerdirect/phpcodesniffer-composer-installer": true,
20+
"squizlabs/php_codesniffer": true,
21+
"wp-coding-standards/wpcs": true
22+
},
23+
"sort-packages": true
24+
},
25+
"require": {
26+
"composer/installers": "^2.3.0"
27+
},
28+
"require-dev": {
29+
"php": ">=8.2",
30+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
31+
"phpcompatibility/phpcompatibility-wp": "^2.1.5",
32+
"squizlabs/php_codesniffer": "^3.10.2",
33+
"wp-cli/wp-cli-bundle": "^2.11.0",
34+
"wp-coding-standards/wpcs": "^3.1.0"
35+
},
36+
"scripts": {
37+
"phpcs": "./vendor/bin/phpcs --report=full,source",
38+
"phpcs-fix": "./vendor/bin/phpcbf --report=summary,source"
39+
}
40+
}

composer.lock

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/functions/related-posts-query.php

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)