Skip to content

Commit 646a3f9

Browse files
authored
Use GitHub releases to create a release. (#1531)
1 parent 00e7efa commit 646a3f9

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release from GitHub Release
2+
on:
3+
release:
4+
types: [created]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
packages: write
12+
steps:
13+
- name: Get release version from tag
14+
id: get_version
15+
run: |
16+
RELEASE_VERSION=${GITHUB_REF#refs/tags/}
17+
echo "Extracted version: $RELEASE_VERSION"
18+
# Validate semver format (MAJOR.MINOR.PATCH)
19+
echo "$RELEASE_VERSION" | grep -P '^2\.[0-9]+\.[0-9]+$'
20+
echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
21+
22+
- uses: actions/checkout@v4
23+
- name: Set up JDK 17
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '17'
27+
distribution: 'temurin'
28+
cache: maven
29+
30+
- name: Set projects Maven version to GitHub Release version
31+
run: mvn versions:set "-DnewVersion=${{ steps.get_version.outputs.release_version }}"
32+
33+
- name: Deploy to Maven Central Repository
34+
uses: actions/setup-java@v4
35+
with:
36+
java-version: '17'
37+
distribution: 'temurin'
38+
cache: maven
39+
server-id: ossrh
40+
server-username: MAVEN_USERNAME
41+
server-password: MAVEN_PASSWORD
42+
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
43+
44+
- name: Publish to the Maven Central Repository
45+
run: mvn --batch-mode clean deploy -Possrh
46+
env:
47+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
48+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
49+
50+
- name: Update Release Notes
51+
id: changelog
52+
uses: metcalfc/changelog-generator@v4.6.2
53+
with:
54+
mytoken: "${{ secrets.GITHUB_TOKEN }}"
55+
56+
- name: Update GitHub Release with Changelog
57+
uses: octokit/request-action@v2.x
58+
with:
59+
route: PATCH /repos/{repo}/releases/{release_id}
60+
repo: ${{ github.repository }}
61+
release_id: ${{ github.event.release.id }}
62+
body: |
63+
### Things that changed in this release
64+
${{ steps.changelog.outputs.changelog }}
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
call_pom_update:
69+
needs: publish
70+
uses: ./.github/workflows/pom_update.yml

RELEASE_PROCESS.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Release Process
2+
3+
## Creating a New Release
4+
5+
The release process is now driven by GitHub Releases:
6+
7+
1. Go to the [Releases page](https://github.com/datafaker-net/datafaker/releases) of the repository
8+
2. Click on "Draft a new release"
9+
3. Create a new tag in the format `2.x.y` (where x and y are the minor and patch version numbers)
10+
4. Set the release title (can be the same as the tag)
11+
5. Add a description of the changes (optional - will be enhanced by automated changelog)
12+
6. Click "Publish release"
13+
14+
The automated workflow will:
15+
1. Extract the version from the tag
16+
2. Update the Maven project version
17+
3. Build and deploy to Maven Central
18+
4. Generate a changelog and add it to the release notes
19+
5. Create a PR to update the pom.xml to the next SNAPSHOT version
20+
21+
## Requirements
22+
23+
- The tag must follow semver format: `2.x.y` (where x and y are numeric)
24+
- GitHub Release creation permissions are required to trigger the workflow
25+
- All required secrets must be configured in the repository settings
26+
27+
## Verification
28+
29+
After publishing a release:
30+
1. Check the workflow run in the Actions tab
31+
2. Verify the artifact is published to Maven Central
32+
3. Review the PR created to update the SNAPSHOT version

0 commit comments

Comments
 (0)