Skip to content

Release CI

Release CI #169

name: Release CI
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
release:
runs-on: ubuntu-latest
name: release
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
fetch-depth: 0
- name: Check for changes
id: check_changes
run: |
LAST_RELEASE_SHA=$(git rev-list --tags --max-count=1)
LAST_COMMIT_SHA=$(git rev-parse HEAD~2)
if [ "$LAST_RELEASE_SHA" == "$LAST_COMMIT_SHA" ]; then
echo "No changes since last release. Skipping..."
echo "::set-output name=skip::true"
else
echo "Changes detected. Proceeding with release..."
echo "::set-output name=skip::false"
fi
- name: Import GPG key
id: import_gpg
if: steps.check_changes.outputs.skip == 'false'
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set up JDK 21
if: steps.check_changes.outputs.skip == 'false'
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 21
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Configure Git author
if: steps.check_changes.outputs.skip == 'false'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Maven release ${{steps.metadata.outputs.current-version}}
if: steps.check_changes.outputs.skip == 'false'
id: maven_release
run: |
current_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
release_version=${current_version%-SNAPSHOT}
echo "Next release version is: $release_version"
next_dev_version="$(( ${current_version} + 1 ))-SNAPSHOT"
echo "Next development version is: $next_dev_version"
mvn -B release:prepare -DreleaseVersion=${release_version} -DdevelopmentVersion=${next_dev_version} -Dlib -Prelease -Dcommunity-app -Dacceptance-test
mvn -B release:perform -Prelease -Dlib
echo "::set-output name=release_version::$release_version"
echo "::set-output name=next_dev_version::$next_dev_version"
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
- name: Run JReleaser
if: steps.check_changes.outputs.skip == 'false'
uses: jreleaser/release-action@v2
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_PROJECT_VERSION: ${{ steps.maven_release.outputs.release_version }}
with:
setup-java: false
# Persist logs
- name: JReleaser release output
if: steps.check_changes.outputs.skip == 'false'
uses: actions/upload-artifact@v3
with:
name: jreleaser-release
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties
- name: Push changes to ${{github.base_ref}} branch
if: steps.check_changes.outputs.skip == 'false'
run: |
git push