Skip to content

Fix releasing github actions #2

Fix releasing github actions

Fix releasing github actions #2

name: Release Snapshot
on:
push:
branches: [ master ]
jobs:
release-snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # Need at least 2 commits to get the commit message
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
run: ./gradlew buildPlugin
- name: Get plugin version
id: get_version
run: echo "VERSION=$(grep 'version =' build.gradle.kts | head -n 1 | cut -d '"' -f 2)-SNAPSHOT" >> $GITHUB_OUTPUT
- name: Get commit details
id: get_commit
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
echo "COMMIT=${COMMIT_HASH}" >> $GITHUB_OUTPUT
# Escape newlines and special characters for GitHub Actions
COMMIT_MESSAGE="${COMMIT_MESSAGE//'%'/'%25'}"
COMMIT_MESSAGE="${COMMIT_MESSAGE//$'\n'/'%0A'}"
COMMIT_MESSAGE="${COMMIT_MESSAGE//$'\r'/'%0D'}"
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: snapshot-${{ steps.get_commit.outputs.COMMIT }}
name: Snapshot ${{ steps.get_version.outputs.VERSION }}-${{ steps.get_commit.outputs.COMMIT }}
body: |
Automated snapshot build from commit ${{ steps.get_commit.outputs.COMMIT }}
**Commit Message:**
${{ steps.get_commit.outputs.COMMIT_MESSAGE }}
This is an automated snapshot release created from the latest commit to the master branch.
files: build/distributions/*.jar
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}