Skip to content

Commit e3bfbf4

Browse files
Fix: Remove version field from composer.json and use git tags for versioning (#2)
* Remove version field from composer.json and update workflow to use git tags Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> * Update README with git tag-based versioning explanation Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Max Prilutskiy <maks.prilutskiy@gmail.com>
1 parent 4f353ff commit e3bfbf4

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

.github/workflows/publish.yml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ jobs:
3636
run: vendor/bin/phpunit tests/
3737

3838
# Only proceed with version bump and publishing if on main branch and tests passed
39-
- name: Get current version
39+
- name: Get current version from git tags
4040
id: current_version
4141
if: success() && (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
4242
run: |
43-
# Check if version exists in composer.json
44-
VERSION=$(php -r '
45-
$composerJson = json_decode(file_get_contents("composer.json"), true);
46-
echo isset($composerJson["version"]) ? $composerJson["version"] : "";
47-
')
43+
# Get latest tag or use 0.1.0 as default if no tags exist
44+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
45+
46+
# Remove 'v' prefix if present
47+
VERSION=${LATEST_TAG#v}
4848
49-
if [[ -z "$VERSION" || ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
49+
# Validate version format
50+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
5051
echo "Setting initial version to 0.1.0"
5152
VERSION="0.1.0"
5253
fi
@@ -79,21 +80,9 @@ jobs:
7980
8081
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
8182
82-
# Update version in composer.json
83-
php -r '
84-
$composerJson = json_decode(file_get_contents("composer.json"), true);
85-
$composerJson["version"] = "${{ steps.bump_version.outputs.new_version }}";
86-
file_put_contents("composer.json", json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
87-
'
83+
# No need to update version in composer.json as we're using git tags
8884
89-
- name: Commit and push version bump
90-
uses: stefanzweifel/git-auto-commit-action@v4
91-
if: success() && (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
92-
with:
93-
commit_message: "chore: bump PHP SDK version to ${{ steps.bump_version.outputs.new_version }}"
94-
file_pattern: composer.json
95-
commit_user_name: "Lingo.dev"
96-
commit_user_email: "hi@lingo.dev"
85+
# No need to commit version bump as we're using git tags
9786

9887
- name: Create tag for release
9988
if: success() && (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@ $engine->localizeText('Hello, world!', [
213213
The SDK uses semantic versioning (MAJOR.MINOR.PATCH) and is automatically published to Packagist when changes are merged to the main branch. The release process includes:
214214

215215
1. Running tests to ensure code quality
216-
2. Automatically bumping the patch version
217-
3. Creating a git tag for the new version
216+
2. Detecting the current version from git tags
217+
3. Automatically bumping the patch version
218+
4. Creating a new git tag for the new version
218219

219-
Packagist automatically fetches new versions from the GitHub repository when tags are pushed, making the new version immediately available for installation via Composer.
220+
Packagist automatically fetches new versions from the GitHub repository when tags are pushed, making the new version immediately available for installation via Composer. The version is determined by git tags rather than being stored in composer.json, following Packagist best practices.
220221

221222
## Documentation
222223

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"description": "Official PHP SDK for Lingo.dev",
44
"type": "library",
55
"license": "MIT",
6-
"version": "0.1.2",
76
"authors": [
87
{
98
"name": "Lingo.dev Team",

0 commit comments

Comments
 (0)