Skip to content

Commit

Permalink
Merge pull request #33 from WebDevStudios/feature/Versioning-script
Browse files Browse the repository at this point in the history
Feature/versioning script
  • Loading branch information
lswilson authored Aug 26, 2024
2 parents d25d2a2 + ad3c337 commit 92b15db
Show file tree
Hide file tree
Showing 14 changed files with 36,565 additions and 31,417 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/version-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update Version on Merge to Main

on:
push:
branches:
- main

jobs:
update-version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run version update script
run: node updateVersion.js

- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .env style.css package.json composer.json
git commit -m "Automated version update after merge to main"
git push origin main
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [Stylelint Configuration](#stylelint-configuration)
- [Extends](#extends)
- [Accessibility and Code Quality and Security Checks](#accessibility-and-code-quality-and-security-checks)
- [Automated Versioning Process](#automated-versioning-process)
- [Contributing and Support](#contributing-and-support)

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

***

## Automated Versioning Process

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`.

<details>
<summary><strong>How It Works</strong></summary>

1. **VERSION**: Manually set in the `.env` file. This is reflected in the `composer.json` and `package.json` files.
- Format: `X.Y.Z` (Semantic Versioning)
- This value is manually updated by the developer.

2. **BUILD**: Automatically increments on merges to the `main` branch. This is appended to the `VERSION` in the `style.css` file.
- Format: `1.0.0x` where `x` is the build number.

</details>

<details>
<summary><strong>Example</strong></summary>

Suppose the `.env` file has the following values:

```plaintext
VERSION=1.0.0
BUILD=4
```

After merging a PR into the `main` branch:

- The `BUILD` increments to `5`.
- The version in `style.css` becomes `Version: 1.0.005`.
- The `composer.json` and `package.json` will still reflect `1.0.0`.

</details>

<details>
<summary><strong>Modifying the Version</strong></summary>

- To update the `VERSION`, manually edit the `.env` file:
```plaintext
VERSION=1.1.0
BUILD=0
```
- The `BUILD` should not be manually modified except for specific scenarios, such as resetting the build number after a major version change.

</details>

<details>
<summary><strong>Workflow</strong></summary>

When a PR is merged into the `main` branch, the following occurs automatically:

1. The `BUILD` number increments.
2. The `style.css` is updated to reflect the `VERSION + BUILD`.
3. The `composer.json` and `package.json` files are updated with only the `VERSION`.
4. The updated files are committed back to the `main` branch.

</details>

<details>
<summary><strong>Manual Execution</strong></summary>

You can manually trigger the versioning process locally if necessary by running:

```bash
npm run update-version
```

This will:

- Increment the `BUILD` number.
- Update the version in `style.css`.
- Ensure `composer.json` and `package.json` reflect the correct `VERSION`.

</details>

***

## Contributing and Support

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.
Expand Down
1 change: 0 additions & 1 deletion assets/scss/patterns/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// 'patterns/' houses styles for custom patterns.
// @import './pattern-name';
@import './related-posts';
19 changes: 0 additions & 19 deletions assets/scss/patterns/related-posts.scss

This file was deleted.

78 changes: 39 additions & 39 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"name": "webdevstudios/wds-bt",
"version": "1.0.0",
"description": "A block starter theme from WebDevStudios.",
"type": "wordpress-theme",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "WebDevStudios",
"email": "[email protected]"
}
],
"config": {
"platform": {
"php": "8.2"
},
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"squizlabs/php_codesniffer": true,
"wp-coding-standards/wpcs": true
},
"sort-packages": true
},
"require": {
"composer/installers": "^2.3.0"
},
"require-dev": {
"php": ">=8.2",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"phpcompatibility/phpcompatibility-wp": "^2.1.5",
"squizlabs/php_codesniffer": "^3.10.2",
"wp-cli/wp-cli-bundle": "^2.11.0",
"wp-coding-standards/wpcs": "^3.1.0"
},
"scripts": {
"phpcs": "./vendor/bin/phpcs --report=full,source",
"phpcs-fix": "./vendor/bin/phpcbf --report=summary,source"
}
}
"name": "webdevstudios/wds-bt",
"version": "1.0.0",
"description": "A block starter theme from WebDevStudios.",
"type": "wordpress-theme",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "WebDevStudios",
"email": "[email protected]"
}
],
"config": {
"platform": {
"php": "8.2"
},
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"squizlabs/php_codesniffer": true,
"wp-coding-standards/wpcs": true
},
"sort-packages": true
},
"require": {
"composer/installers": "^2.3.0"
},
"require-dev": {
"php": ">=8.2",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"phpcompatibility/phpcompatibility-wp": "^2.1.5",
"squizlabs/php_codesniffer": "^3.10.2",
"wp-cli/wp-cli-bundle": "^2.11.0",
"wp-coding-standards/wpcs": "^3.1.0"
},
"scripts": {
"phpcs": "./vendor/bin/phpcs --report=full,source",
"phpcs-fix": "./vendor/bin/phpcbf --report=summary,source"
}
}
34 changes: 17 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 0 additions & 73 deletions inc/functions/related-posts-query.php

This file was deleted.

Loading

0 comments on commit 92b15db

Please sign in to comment.