Skip to content

Merge pull request #15 from ButterCMS/feature/api-changes #3

Merge pull request #15 from ButterCMS/feature/api-changes

Merge pull request #15 from ButterCMS/feature/api-changes #3

# 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
# 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:
- 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 }}