Skip to content

Commit 7665b0d

Browse files
committed
Update workflows: publish on tag push, auto-create releases
1 parent a8848fe commit 7665b0d

4 files changed

Lines changed: 103 additions & 46 deletions

File tree

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Publish to Maven Central and GitHub Packages
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
tags:
6+
- 'v*'
67

78
jobs:
89
publish:

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Create GitHub Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v6
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Extract version from tag
19+
id: version
20+
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
21+
22+
- name: Extract changelog for version
23+
id: changelog
24+
run: |
25+
# Extract the section for this version from CHANGELOG.md
26+
VERSION="${{ steps.version.outputs.version }}"
27+
28+
# Get changelog content between version headers
29+
CHANGELOG=$(awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | sed '1d;$d' | sed '/^$/d')
30+
31+
# If changelog extraction failed, use a default message
32+
if [ -z "$CHANGELOG" ]; then
33+
CHANGELOG="Release version $VERSION
34+
35+
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md) for details."
36+
fi
37+
38+
# Save to output using heredoc to handle multiline content
39+
{
40+
echo 'notes<<EOF'
41+
echo "$CHANGELOG"
42+
echo EOF
43+
} >> $GITHUB_OUTPUT
44+
45+
- name: Create GitHub Release
46+
uses: actions/github-script@v7
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
const tag = context.ref.replace('refs/tags/', '');
51+
const version = tag.replace('v', '');
52+
53+
await github.rest.repos.createRelease({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
tag_name: tag,
57+
name: `Release ${version}`,
58+
body: `${{ steps.changelog.outputs.notes }}`,
59+
draft: false,
60+
prerelease: version.includes('-') || version.includes('alpha') || version.includes('beta') || version.includes('rc')
61+
});

CLAUDE.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ The project uses **Spotless** with **Google Java Format (AOSP style)**:
160160
GitHub Actions workflows:
161161
- **test.yml** - Runs tests on all branches using JDK 17
162162
- **maven.yml** - Maven-based build pipeline
163-
- **publish.yml** - Publishes artifacts to Maven Central and GitHub Packages (triggered on releases)
163+
- **publish.yml** - Publishes artifacts to Maven Central and GitHub Packages (triggered on tag push)
164+
- **release.yml** - Creates GitHub releases with changelog notes (triggered on tag push)
164165

165166
## Publishing & Releases
166167

@@ -179,37 +180,34 @@ make bump-patch # 0.0.1 -> 0.0.2
179180
make bump-minor # 0.0.1 -> 0.1.0
180181
make bump-major # 0.0.1 -> 1.0.0
181182

182-
# Push the tag to trigger release workflow
183+
# Push the tag to trigger automated workflows
183184
make push-tag
184-
185-
# Create GitHub release (triggers publish.yml workflow)
186-
gh release create v0.0.2 --title "Release 0.0.2" --notes "Release notes here"
187185
```
188186

189-
**Automated workflow:**
190-
1. `make bump-patch` (or minor/major) - Updates version in both pom.xml and build.gradle, commits, and creates tag
191-
2. `make push-tag` - Pushes the tag to GitHub
192-
3. `gh release create` - Creates GitHub release which automatically triggers the publish workflow
193-
4. The workflow publishes to both Maven Central and GitHub Packages
187+
**Automated workflow (triggered by `make push-tag`):**
188+
1. `make bump-patch` (or minor/major) - Updates version in both pom.xml and build.gradle, commits, and creates tag locally
189+
2. `make push-tag` - Pushes the tag to GitHub, which automatically triggers:
190+
- **publish.yml** - Runs tests, signs artifacts, publishes to Maven Central and GitHub Packages
191+
- **release.yml** - Creates GitHub release with changelog notes
194192

195193
**One-command releases:**
196194
```bash
197-
# These combine bump + push-tag
198-
make release-patch # Bump patch and push tag
199-
make release-minor # Bump minor and push tag
200-
make release-major # Bump major and push tag
201-
202-
# Then create the GitHub release
203-
gh release create v0.0.2
195+
# These combine bump + push-tag (fully automated!)
196+
make release-patch # Bump patch and push tag → triggers publish + release
197+
make release-minor # Bump minor and push tag → triggers publish + release
198+
make release-major # Bump major and push tag → triggers publish + release
204199
```
205200

206-
**What happens during publish:**
201+
**What happens automatically:**
207202
- Runs all tests
208203
- Signs artifacts with GPG
209204
- Deploys to Maven Central Portal (auto-publishes)
210205
- Deploys to GitHub Packages
206+
- Creates GitHub release with changelog notes from CHANGELOG.md
211207
- Available in Maven Central within 30 minutes
212208

209+
**No manual steps needed!** Just run `make release-patch` and everything is automated.
210+
213211
### Version Management
214212

215213
Version is tracked in two files (automatically updated by Makefile):

PUBLISHING.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -83,54 +83,51 @@ rm gpg-key.txt
8383

8484
## Publishing Process
8585

86-
The publish workflow runs automatically when you create a GitHub release.
86+
The publish workflow runs automatically when you push a version tag.
8787

88-
### Step 1: Update Version
88+
### Step 1: Update Version and Create Tag
8989

9090
```bash
9191
# Using Makefile (recommended)
9292
make bump-patch # 0.0.1 -> 0.0.2
9393
make bump-minor # 0.0.1 -> 0.1.0
9494
make bump-major # 0.0.1 -> 1.0.0
9595

96-
# Manual update
97-
sed -i '' 's/<version>0.0.1<\/version>/<version>0.0.2<\/version>/' pom.xml
98-
sed -i '' "s/version = '0.0.1'/version = '0.0.2'/" build.gradle
99-
git add pom.xml build.gradle
100-
git commit -m "Bump version to 0.0.2"
96+
# This updates pom.xml and build.gradle, commits, and creates a tag locally
10197
```
10298

103-
### Step 2: Push Changes
99+
### Step 2: Push Tag (Triggers Everything)
104100

105101
```bash
106-
git push origin master
102+
make push-tag
107103
```
108104

109-
### Step 3: Create a GitHub Release
110-
111-
```bash
112-
# Using GitHub CLI (recommended)
113-
gh release create v0.0.2 \
114-
--title "Release 0.0.2" \
115-
--notes "Release notes here"
116-
117-
# Or via GitHub UI:
118-
# Go to https://github.com/rootlyhq/rootly-java/releases/new
119-
```
120-
121-
### Step 4: Monitor the Workflow
122-
123-
The publish workflow will automatically:
124-
105+
**This single command automatically triggers:**
125106
1. ✅ Run all tests
126107
2. ✅ Sign artifacts with GPG
127108
3. ✅ Deploy to Maven Central Portal
128109
4. ✅ Auto-publish to Maven Central (no manual UI steps needed!)
129110
5. ✅ Deploy to GitHub Packages
111+
6. ✅ Create GitHub release with changelog notes
112+
113+
### One-Command Release (Recommended)
114+
115+
```bash
116+
# Combines bump + push (fully automated!)
117+
make release-patch # 0.0.1 -> 0.0.2
118+
make release-minor # 0.0.1 -> 0.1.0
119+
make release-major # 0.0.1 -> 1.0.0
120+
```
121+
122+
### Step 3: Monitor the Workflows
123+
124+
Two workflows run automatically on tag push:
125+
- **publish.yml** - Publishes to Maven Central and GitHub Packages
126+
- **release.yml** - Creates GitHub release with changelog
130127

131128
Check the Actions tab: https://github.com/rootlyhq/rootly-java/actions
132129

133-
### Step 5: Verify Publication
130+
### Step 4: Verify Publication
134131

135132
**Maven Central** (available within 30 minutes):
136133
- Search: https://central.sonatype.com/artifact/com.rootly.client/rootly

0 commit comments

Comments
 (0)