From e1526f4e8a89a29b071099576f66817b0798fcf0 Mon Sep 17 00:00:00 2001 From: Zuzana Wangle Date: Sun, 6 Aug 2023 13:32:21 +0200 Subject: [PATCH 1/6] chore: add release and publish actions + docs --- .github/workflows/release-and-publish.yml | 46 +++++++++++++++++++++++ CONTRIBUTING.md | 11 ++++++ composer.json | 3 +- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-and-publish.yml create mode 100644 CONTRIBUTING.md diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml new file mode 100644 index 0000000..26f288b --- /dev/null +++ b/.github/workflows/release-and-publish.yml @@ -0,0 +1,46 @@ +# This workflow opens and updates a pull request with a new package version +# based on code changes. Merging the pull request updates the version in +# composer.json, updates the changelog and creates release tags. + +# This workflow also publishes the package into the Packagist repository after +# a new version has been released. + +# For more information, see https://github.com/marketplace/actions/release-please-action + + +on: + push: + branches: + - master + +permissions: + contents: write + pull-requests: write + +name: release-please + +jobs: + release-please: + runs-on: ubuntu-22.04 + steps: + - uses: google-github-actions/release-please-action@v3.7.10 + with: + release-type: php + package-name: release-please-action + pull-request-title-pattern: "chore(release): ${version}" + pull-request-header: ":robot: Merge this PR to release a new version" + + publish-package: + # after merging the pull request, a release tag first has to be created + # in the release-please job above, before the publish job starts + needs: release-please + if: contains(github.event.head_commit.message, 'chore(release)') + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3.5.3 + + - uses: hotaruma/packagist-sync@v1.0.1 + with: + packagist-username: ${{ secrets.PACKAGIST_USERNAME }} + api-token: ${{ secrets.PACKAGIST_TOKEN }} + \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f72763e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,11 @@ +# Contributing + +## Release and publish a new SDK version + +This SDK uses the [`release-please` GitHub Action](https://github.com/google-github-actions/release-please-action) to automate preparing new versions for release. + +When you are ready to release a new SDK version, make sure that all your code changes have been approved and merged into the `master` branch and that your code is working. The `release-please` tool generates a changelog based on **commit messages; these messages should follow the [Conventional Commits](https://conventionalcommits.org) specification in order for the changelog to reflect all code changes accurately**. Otherwise, you would need to update the changelog manually before each release. + +The `release-please` action opens and maintains a GitHub pull request with changes relevant to a new version release. Approve this pull request to release a new version of the SDK. + +After the release, the new version is automatically published into the Packagist repository (see the package [here](https://packagist.org/packages/buttercms/buttercms-php)). diff --git a/composer.json b/composer.json index 4dde970..776167c 100644 --- a/composer.json +++ b/composer.json @@ -25,5 +25,6 @@ "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } - } + }, + "version": "3.0.1" } From 579fa3e7171956fe4a29b069c867023d5553f1b6 Mon Sep 17 00:00:00 2001 From: Prokop Simek Date: Fri, 8 Sep 2023 13:08:41 +0200 Subject: [PATCH 2/6] Update .github/workflows/release-and-publish.yml --- .github/workflows/release-and-publish.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index 26f288b..fca5ac5 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -8,6 +8,9 @@ # For more information, see https://github.com/marketplace/actions/release-please-action +# PHP Packagist works slightly differently then the other two cases (npm and rubygems). In this case, "publishing a # package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo and look for new versions itself (instead of us pushing a new version into the package repository directly). +# release-please, apart from opening a PR, also creates a GitHub release and a new tag (in this case the Action is # triggered by manually merging the PR). The problem here was that Packagist looked for a new version before release-please was done creating the tag and release. That is why there has to be a dependency so that the publish Action would only start after a proper release has been created. +# Because these two Actions are connected this way, it seemed logical to me to put them in a single workflow. on: push: branches: From 5c9df8e842ad5e8e61b5496e55d28c507d9c6166 Mon Sep 17 00:00:00 2001 From: Prokop Simek Date: Fri, 8 Sep 2023 13:09:05 +0200 Subject: [PATCH 3/6] Update .github/workflows/release-and-publish.yml --- .github/workflows/release-and-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index fca5ac5..b5b5ca5 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -11,6 +11,7 @@ # PHP Packagist works slightly differently then the other two cases (npm and rubygems). In this case, "publishing a # package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo and look for new versions itself (instead of us pushing a new version into the package repository directly). # release-please, apart from opening a PR, also creates a GitHub release and a new tag (in this case the Action is # triggered by manually merging the PR). The problem here was that Packagist looked for a new version before release-please was done creating the tag and release. That is why there has to be a dependency so that the publish Action would only start after a proper release has been created. # Because these two Actions are connected this way, it seemed logical to me to put them in a single workflow. +# Comment: https://github.com/ButterCMS/buttercms-php/pull/13/files#r1307254666 on: push: branches: From ce8090934306e9cea60fd7806e655292c50464a3 Mon Sep 17 00:00:00 2001 From: Prokop Simek Date: Fri, 8 Sep 2023 14:54:02 +0200 Subject: [PATCH 4/6] Update .github/workflows/release-and-publish.yml --- .github/workflows/release-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index b5b5ca5..deefd9a 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -9,7 +9,7 @@ # PHP Packagist works slightly differently then the other two cases (npm and rubygems). In this case, "publishing a # package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo and look for new versions itself (instead of us pushing a new version into the package repository directly). -# release-please, apart from opening a PR, also creates a GitHub release and a new tag (in this case the Action is # triggered by manually merging the PR). The problem here was that Packagist looked for a new version before release-please was done creating the tag and release. That is why there has to be a dependency so that the publish Action would only start after a proper release has been created. +# release-please, apart from opening a PR, also creates a GitHub release and a new tag (in this case the Action is triggered by manually merging the PR). The problem here was that Packagist looked for a new version before release-please was done creating the tag and release. That is why there has to be a dependency so that the publish Action would only start after a proper release has been created. # Because these two Actions are connected this way, it seemed logical to me to put them in a single workflow. # Comment: https://github.com/ButterCMS/buttercms-php/pull/13/files#r1307254666 on: From 48cb02e9577031cd2f13f5dc64f1daa977f5b846 Mon Sep 17 00:00:00 2001 From: Prokop Simek Date: Fri, 8 Sep 2023 14:56:07 +0200 Subject: [PATCH 5/6] docs: length of rows --- .github/workflows/release-and-publish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index deefd9a..fb5f0e7 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -8,8 +8,13 @@ # For more information, see https://github.com/marketplace/actions/release-please-action -# PHP Packagist works slightly differently then the other two cases (npm and rubygems). In this case, "publishing a # package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo and look for new versions itself (instead of us pushing a new version into the package repository directly). -# release-please, apart from opening a PR, also creates a GitHub release and a new tag (in this case the Action is triggered by manually merging the PR). The problem here was that Packagist looked for a new version before release-please was done creating the tag and release. That is why there has to be a dependency so that the publish Action would only start after a proper release has been created. +# PHP Packagist works slightly differently then the other two cases (npm and rubygems). +# In this case, "publishing a # package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo +# and look for new versions itself (instead of us pushing a new version into the package repository directly). +# release-please, apart from opening a PR, also creates a GitHub release +# and a new tag (in this case the Action is triggered by manually merging the PR). +# The problem here was that Packagist looked for a new version before release-please was done creating the tag and release. +# That is why there has to be a dependency so that the publish Action would only start after a proper release has been created. # Because these two Actions are connected this way, it seemed logical to me to put them in a single workflow. # Comment: https://github.com/ButterCMS/buttercms-php/pull/13/files#r1307254666 on: From 3e4055a6e344d5a6527874654e681b248b583b73 Mon Sep 17 00:00:00 2001 From: Prokop Simek Date: Fri, 8 Sep 2023 16:28:26 +0200 Subject: [PATCH 6/6] Update .github/workflows/release-and-publish.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Staƛczak --- .github/workflows/release-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index fb5f0e7..bd374db 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -9,7 +9,7 @@ # PHP Packagist works slightly differently then the other two cases (npm and rubygems). -# In this case, "publishing a # package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo +# In this case, "publishing a package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo # and look for new versions itself (instead of us pushing a new version into the package repository directly). # release-please, apart from opening a PR, also creates a GitHub release # and a new tag (in this case the Action is triggered by manually merging the PR).