Release to Maven-Central #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build and a release Java project to the Maven-Central repository | |
name: Release to Maven-Central | |
on: | |
workflow_dispatch | |
jobs: | |
maven-perform-release: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Java for deployment | |
uses: ./.github/actions/setup-java-for-deployment | |
with: | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
- name: Configure git user | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions (run by ${{ github.actor }})" | |
# Perform the usual maven-release-plugin procedure, but prevent the release commits | |
# and tag from being pushed to the master immediately. They are only pushed after | |
# the release is performed successfully. This avoids to have the release | |
# commits on the master in case release publication fails in the last step). | |
# All file-system/git-operations are performed on the runnner's clone of this repo | |
- run: mvn -f symja_android_library -B release:clean release:prepare -DpushChanges=false | |
- name: Read release version | |
run: | # Create environment variables associcated to release version, derived from the release tag | |
releaseGitTag=$(git describe --abbrev=0) | |
echo "release_tag=${releaseGitTag}" >> $GITHUB_ENV | |
echo "release_version=${releaseGitTag#v}" >> $GITHUB_ENV | |
# Edit the 'release' commit with updates of the changelog: | |
- name: Checkout release commit | |
run: git checkout ${{ env.release_tag }} # headless checkout! | |
- name: Finalize changelog entry | |
uses: stefanzweifel/changelog-updater-action@v1 | |
id: "update-changelog" | |
with: | |
latest-version: ${{ env.release_tag }} | |
- name: Amend release commit and tag and cherry-pick preparation commit | |
run: | | |
git add CHANGELOG.md | |
git commit --amend --no-edit | |
git tag -a ${{ env.release_tag }} -f -m "Symja ${{ env.release_version }}" # reset tag to amended release commit | |
git cherry-pick master | |
- name: Push ${{ env.release_version }} release commits to draft branch | |
# Save the commits from which the release is build in the main repository | |
# but only on a temporary draft branch. This way the release commits | |
# are not on the master in case performing/publishing the release fails | |
run: git push origin HEAD:refs/heads/draft_${{ env.release_version }} | |
- run: mvn -f symja_android_library -B release:perform -DlocalCheckout=true | |
# Deployment of all modules is deferred to the last module by nexus-staging-maven-plugin | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Publish release commits and tag to master | |
run: | # the release was published successfully | |
git push origin HEAD:master # push release commits to master | |
git push origin refs/tags/${{ env.release_tag }} # push release tag | |
git push origin --delete draft_${{ env.release_version }} # delete draft branch | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Symja ${{ env.release_version }} | |
tag_name: ${{ env.release_tag }} | |
draft: false | |
prerelease: false | |
files: ./symja_android_library/target/checkout/symja_android_library/target/nexus-staging/**/*.jar | |
body: | | |
We are pleased to announce the release of Symja ${{ env.release_version }}. | |
This release is available on Maven central using the following coordinates: | |
``` | |
<dependency> | |
<groupId>org.matheclipse</groupId> | |
<artifactId>matheclipse-core</artifactId> | |
<version>${{ env.release_version }}</version> | |
</dependency> | |
``` | |
You can obtain the other Symja-modules using their corresponding `artifactId`. | |
See the [changelog for Symja ${{ env.release_version }}](CHANGELOG.md${{ steps.update-changelog.outputs.release_url_fragment }}) for all noteworthy changes. | |
The exact changes are: ${{ steps.update-changelog.outputs.release_compare_url }} | |
Thanks to everyone who contributed to this release! |