Skip to content

Commit 288ae55

Browse files
kojiromikeclaude
andauthored
chore: implement release-please for automated releases (#10)
Add release-please GitHub Action for automated versioning and changelog generation based on conventional commits. - Add release-please workflow triggered on push to main - Configure PHP release type for composer.json version bumping - Initialize changelog and manifest at version 0.1.0 - Convert lightweight tags to annotated tags for git describe compatibility Closes #8 Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 7f495ff commit 288ae55

File tree

4 files changed

+138
-0
lines changed

4 files changed

+138
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
release-please:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Run Release Please
23+
id: release
24+
uses: googleapis/release-please-action@v4
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
# Convert lightweight tag to annotated tag
29+
#
30+
# Why this is needed:
31+
# - Release-please creates releases via GitHub's release API, which creates lightweight tags
32+
# - We require annotated tags because:
33+
# * git describe ignores lightweight tags by default (requires --tags flag)
34+
# * Lightweight tags are not copied into forks
35+
# * Annotated tags have proper metadata (creation date, tagger info, message)
36+
#
37+
# Why we do this after release creation:
38+
# - We can't create the annotated tag before release-please runs because we don't know
39+
# the version number until release-please determines it from conventional commits
40+
# - The GitHub release API will use an existing tag if present (per the target_commitish
41+
# parameter docs: "Unused if the Git tag already exists"), but release-please doesn't
42+
# provide a way to hook into the process between version determination and release creation
43+
# - Using skip-github-release has known issues and breaks release-please's workflow
44+
# (see: https://github.com/googleapis/release-please/issues/1561)
45+
#
46+
# Race condition considerations:
47+
# - There is a small window (milliseconds) between when the lightweight tag is created
48+
# and when we convert it to annotated where someone could fetch the lightweight tag
49+
# - In practice, this risk is acceptable because:
50+
# * Most users interact with releases, not tags directly
51+
# * The window is extremely brief
52+
# * By the time manual tag fetches occur, the annotated version exists
53+
# * The GitHub release points to the correct commit regardless of tag type
54+
- name: Convert to annotated tag
55+
if: ${{ steps.release.outputs.release_created }}
56+
run: |
57+
git config user.name "github-actions[bot]"
58+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
59+
git fetch --tags
60+
TAG_NAME="${{ steps.release.outputs.tag_name }}"
61+
git tag -a -f -m "Release ${TAG_NAME}" "${TAG_NAME}" "${TAG_NAME}^{commit}"
62+
git push -f origin "${TAG_NAME}"

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.1.0"
3+
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

release-please-config.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"release-type": "php",
3+
"packages": {
4+
".": {
5+
"package-name": "oce-cli-import-codes",
6+
"changelog-path": "CHANGELOG.md",
7+
"include-component-in-tag": false,
8+
"include-v-in-tag": false
9+
}
10+
},
11+
"bump-minor-pre-major": true,
12+
"bump-patch-for-minor-pre-major": true,
13+
"changelog-sections": [
14+
{
15+
"type": "feat",
16+
"section": "Features"
17+
},
18+
{
19+
"type": "fix",
20+
"section": "Bug Fixes"
21+
},
22+
{
23+
"type": "perf",
24+
"section": "Performance Improvements"
25+
},
26+
{
27+
"type": "revert",
28+
"section": "Reverts"
29+
},
30+
{
31+
"type": "docs",
32+
"section": "Documentation"
33+
},
34+
{
35+
"type": "style",
36+
"section": "Styles",
37+
"hidden": true
38+
},
39+
{
40+
"type": "chore",
41+
"section": "Miscellaneous Chores",
42+
"hidden": true
43+
},
44+
{
45+
"type": "refactor",
46+
"section": "Code Refactoring"
47+
},
48+
{
49+
"type": "test",
50+
"section": "Tests",
51+
"hidden": true
52+
},
53+
{
54+
"type": "build",
55+
"section": "Build System"
56+
},
57+
{
58+
"type": "ci",
59+
"section": "Continuous Integration",
60+
"hidden": true
61+
},
62+
{
63+
"type": "deps",
64+
"section": "Dependencies"
65+
}
66+
]
67+
}

0 commit comments

Comments
 (0)