Skip to content

Merge pull request #203 from domaframework/renovate/com.diffplug.spot… #314

Merge pull request #203 from domaframework/renovate/com.diffplug.spot…

Merge pull request #203 from domaframework/renovate/com.diffplug.spot… #314

name: Release Drafter
on:
push:
branches:
- main
workflow_dispatch:
jobs:
update_release_draft:
if: ${{ !contains(github.head_ref, 'doc/changelog-update-') && startsWith(github.event.head_commit.message, 'Merge pull request') }}
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
skip_job: ${{ steps.check.outputs.SKIP_JOB }}
steps:
- name: Check Commit Message
id: check
run: |
# Define a regex pattern to match commit messages for changelog updates
CHANGELOG_UPDATE_PATTERN="^Merge pull request #[0-9]+ from ${{ github.repository_owner }}/doc/changelog-update-.*$"
if [[ "${{ github.event.head_commit.message }}" =~ $CHANGELOG_UPDATE_PATTERN ]]; then
echo "This commit is not target. Skip the workflow."
echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
else
echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
fi
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commitish: main
update_version:
needs: update_release_draft
if: ${{ needs.update_release_draft.outputs.skip_job != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
pull-requests: write
steps:
- name: Get latest draft release title
run: |
TITLE=$(gh api repos/${{ github.repository }}/releases \
--jq '.[] | select(.draft==true) | .name' | head -n 1)
if [[ -z "$TITLE" ]]; then
echo "No draft release found."
exit 1
fi
VERSION=$(echo "$TITLE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
if [[ -z "$VERSION" ]]; then
echo "No version found in version."
exit 1
fi
echo "Extracted version: $VERSION"
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
# Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: true
- name: Update Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew replaceDraftVersion -PdraftVersion=$RELEASE_VERSION --no-configuration-cache
- name: Commit New Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.email "[email protected]"
git config user.name "GitHub Action"
git pull
git add src/main/kotlin/org/domaframework/doma/intellij/common/util/PluginUtil.kt
git add src/main/resources/logback.xml
git add src/main/resources/logback-test.xml
git add gradle.properties
if [[ -z "$(git status --porcelain)" ]]; then
echo "No changes to commit."
exit 0
fi
git commit -am "Update Version With Release Draft - $REPLACE_VERSION"
git push origin main