Skip to content

Commit 4aa4974

Browse files
committed
Merge release workflow into publish workflow for atomic releases
1 parent fb055b6 commit 4aa4974

5 files changed

Lines changed: 75 additions & 72 deletions

File tree

.github/workflows/publish.yml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ jobs:
99
publish:
1010
runs-on: ubuntu-latest
1111
permissions:
12-
contents: read
12+
contents: write
1313
packages: write
1414
steps:
1515
- uses: actions/checkout@v6
16+
with:
17+
fetch-depth: 0
1618

1719
- name: Set up JDK for Maven Central
1820
uses: actions/setup-java@v5
@@ -45,4 +47,49 @@ jobs:
4547
- name: Publish to GitHub Packages
4648
run: mvn --batch-mode deploy -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/${{ github.repository }} -Dcentral.publishing.skip=true
4749
env:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Extract version from tag
53+
id: version
54+
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
55+
56+
- name: Extract changelog for version
57+
id: changelog
58+
run: |
59+
# Extract the section for this version from CHANGELOG.md
60+
VERSION="${{ steps.version.outputs.version }}"
61+
62+
# Get changelog content between version headers
63+
CHANGELOG=$(awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | sed '1d;$d' | sed '/^$/d')
64+
65+
# If changelog extraction failed, use a default message
66+
if [ -z "$CHANGELOG" ]; then
67+
CHANGELOG="Release version $VERSION
68+
69+
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md) for details."
70+
fi
71+
72+
# Save to output using heredoc to handle multiline content
73+
{
74+
echo 'notes<<EOF'
75+
echo "$CHANGELOG"
76+
echo EOF
77+
} >> $GITHUB_OUTPUT
78+
79+
- name: Create GitHub Release
80+
uses: actions/github-script@v7
81+
with:
82+
github-token: ${{ secrets.GITHUB_TOKEN }}
83+
script: |
84+
const tag = context.ref.replace('refs/tags/', '');
85+
const version = tag.replace('v', '');
86+
87+
await github.rest.repos.createRelease({
88+
owner: context.repo.owner,
89+
repo: context.repo.repo,
90+
tag_name: tag,
91+
name: `Release ${version}`,
92+
body: `${{ steps.changelog.outputs.notes }}`,
93+
draft: false,
94+
prerelease: version.includes('-') || version.includes('alpha') || version.includes('beta') || version.includes('rc')
95+
});

.github/workflows/release.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.0.2] - 2026-01-22
11+
12+
### Fixed
13+
- Fixed GPG key format in GitHub Actions (use ASCII armored format instead of base64)
14+
- Fixed GitHub Packages deployment by skipping Maven Central plugin during GitHub Packages publish
15+
16+
### Changed
17+
- Merged release workflow into publish workflow for atomic releases
18+
- GitHub releases now only created after successful publishing to both registries
19+
- Updated publishing documentation with correct GPG key export instructions
20+
1021
## [0.0.1] - 2026-01-20
1122

1223
### Added

CLAUDE.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ 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 tag push)
164-
- **release.yml** - Creates GitHub releases with changelog notes (triggered on tag push)
163+
- **publish.yml** - Publishes artifacts to Maven Central and GitHub Packages, then creates GitHub release (triggered on tag push)
165164

166165
## Publishing & Releases
167166

@@ -186,9 +185,12 @@ make push-tag
186185

187186
**Automated workflow (triggered by `make push-tag`):**
188187
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
188+
2. `make push-tag` - Pushes the tag to GitHub, which automatically triggers **publish.yml**:
189+
- Runs tests
190+
- Signs artifacts with GPG
191+
- Publishes to Maven Central
192+
- Publishes to GitHub Packages
193+
- Creates GitHub release with changelog notes (only if all publishing succeeds)
192194

193195
**One-command releases:**
194196
```bash

PUBLISHING.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,18 @@ make release-minor # 0.0.1 -> 0.1.0
119119
make release-major # 0.0.1 -> 1.0.0
120120
```
121121

122-
### Step 3: Monitor the Workflows
122+
### Step 3: Monitor the Workflow
123123

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
124+
The **publish.yml** workflow runs automatically on tag push and performs these steps in order:
125+
1. Runs all tests
126+
2. Publishes to Maven Central (with GPG signing)
127+
3. Publishes to GitHub Packages
128+
4. Creates GitHub release with changelog notes (only if steps 1-3 succeed)
127129

128130
Check the Actions tab: https://github.com/rootlyhq/rootly-java/actions
129131

132+
**Important:** The GitHub release is only created after successful publishing to both registries, ensuring atomic releases.
133+
130134
### Step 4: Verify Publication
131135

132136
**Maven Central** (available within 30 minutes):

0 commit comments

Comments
 (0)