Skip to content

Commit c3b5a6a

Browse files
Merge pull request #13 from zuzanawangle/chore/add-release-and-publish-actions
chore: add release and publish actions + docs
2 parents ede07d4 + 3e4055a commit c3b5a6a

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This workflow opens and updates a pull request with a new package version
2+
# based on code changes. Merging the pull request updates the version in
3+
# composer.json, updates the changelog and creates release tags.
4+
5+
# This workflow also publishes the package into the Packagist repository after
6+
# a new version has been released.
7+
8+
# For more information, see https://github.com/marketplace/actions/release-please-action
9+
10+
11+
# PHP Packagist works slightly differently then the other two cases (npm and rubygems).
12+
# In this case, "publishing a package" means calling a Packagist webhook which causes Packagist to scan the GitHub repo
13+
# and look for new versions itself (instead of us pushing a new version into the package repository directly).
14+
# release-please, apart from opening a PR, also creates a GitHub release
15+
# and a new tag (in this case the Action is triggered by manually merging the PR).
16+
# The problem here was that Packagist looked for a new version before release-please was done creating the tag and release.
17+
# That is why there has to be a dependency so that the publish Action would only start after a proper release has been created.
18+
# Because these two Actions are connected this way, it seemed logical to me to put them in a single workflow.
19+
# Comment: https://github.com/ButterCMS/buttercms-php/pull/13/files#r1307254666
20+
on:
21+
push:
22+
branches:
23+
- master
24+
25+
permissions:
26+
contents: write
27+
pull-requests: write
28+
29+
name: release-please
30+
31+
jobs:
32+
release-please:
33+
runs-on: ubuntu-22.04
34+
steps:
35+
- uses: google-github-actions/[email protected]
36+
with:
37+
release-type: php
38+
package-name: release-please-action
39+
pull-request-title-pattern: "chore(release): ${version}"
40+
pull-request-header: ":robot: Merge this PR to release a new version"
41+
42+
publish-package:
43+
# after merging the pull request, a release tag first has to be created
44+
# in the release-please job above, before the publish job starts
45+
needs: release-please
46+
if: contains(github.event.head_commit.message, 'chore(release)')
47+
runs-on: ubuntu-22.04
48+
steps:
49+
- uses: actions/[email protected]
50+
51+
- uses: hotaruma/[email protected]
52+
with:
53+
packagist-username: ${{ secrets.PACKAGIST_USERNAME }}
54+
api-token: ${{ secrets.PACKAGIST_TOKEN }}
55+

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributing
2+
3+
## Release and publish a new SDK version
4+
5+
This SDK uses the [`release-please` GitHub Action](https://github.com/google-github-actions/release-please-action) to automate preparing new versions for release.
6+
7+
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.
8+
9+
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.
10+
11+
After the release, the new version is automatically published into the Packagist repository (see the package [here](https://packagist.org/packages/buttercms/buttercms-php)).

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
"allow-plugins": {
2626
"dealerdirect/phpcodesniffer-composer-installer": true
2727
}
28-
}
28+
},
29+
"version": "3.0.1"
2930
}

0 commit comments

Comments
 (0)