Skip to content

Commit 42642c4

Browse files
committed
Add release workflow and release notes template
Introduces a GitHub Actions workflow for automated releases triggered by tag pushes or manual dispatch. Adds a release notes template to standardize installation instructions in release notes.
1 parent 075329d commit 42642c4

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

.github/release_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Installation
2+
3+
To install the latest version of Litebase PHP, run the following command or download for manual installation.
4+
5+
```sh
6+
composer require litebase/litebase-php
7+
```

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
permissions:
10+
id-token: write
11+
contents: write
12+
packages: write
13+
attestations: write
14+
15+
env:
16+
PROJECT_NAME: litebase
17+
18+
jobs:
19+
get-version:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
version: ${{ steps.version.outputs.version }}
23+
steps:
24+
- name: Get version from tag
25+
id: version
26+
run: |
27+
VERSION=${GITHUB_REF#refs/tags/}
28+
echo "version=$VERSION" >> $GITHUB_OUTPUT
29+
30+
release:
31+
needs: [get-version]
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
39+
- name: Set up PHP
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
php-version: "8.4"
43+
44+
- name: Validate composer.json
45+
run: composer validate --strict
46+
47+
- name: Create GitHub Release
48+
run: |
49+
# Create release with auto-generated notes
50+
gh release create ${{ needs.get-version.outputs.version }} \
51+
--draft \
52+
--title "Litebase PHP ${{ needs.get-version.outputs.version }} (Alpha)" \
53+
--target ${{ github.sha }} \
54+
--generate-notes
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
58+
- name: Update release notes with template
59+
if: hashFiles('.github/release_template.md') != ''
60+
run: |
61+
# Get the auto-generated notes
62+
GENERATED_NOTES=$(gh release view ${{ needs.get-version.outputs.version }} --json body --jq '.body')
63+
64+
# Create notes with auto-generated content first, then custom template
65+
echo "## Release Notes" > temp_notes.md
66+
echo "" >> temp_notes.md
67+
echo "$GENERATED_NOTES" >> temp_notes.md
68+
echo "" >> temp_notes.md
69+
echo "---" >> temp_notes.md
70+
echo "" >> temp_notes.md
71+
72+
# Get version without 'v' prefix
73+
FLOAT_VERSION=$(echo ${{ needs.get-version.outputs.version }} | sed 's/^v//')
74+
75+
# Replace $VERSION in template with actual version
76+
cat .github/release_template.md | sed "s/\$VERSION/$FLOAT_VERSION/g" >> temp_notes.md
77+
78+
# Update the release with combined notes
79+
gh release edit ${{ needs.get-version.outputs.version }} --notes-file temp_notes.md
80+
env:
81+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)