[meta] Update publish.yml. #19
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
# Do not edit this file directly | |
# This file is synced by https://github.com/ChaoticTrials/ModMeta | |
name: publish | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Determine previous commit | |
id: determine_previous_commit | |
run: | | |
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then | |
gitPrevHash=$(git rev-parse HEAD~1) | |
else | |
gitPrevHash=${{ github.event.before }} | |
fi | |
echo "GIT_PREVIOUS_COMMIT=$gitPrevHash" >> $GITHUB_ENV | |
- name: Check commit messages | |
id: check_commit_messages | |
run: | | |
commits=$(git log $GIT_PREVIOUS_COMMIT..${{ github.sha }} --pretty=format:'%s') | |
echo "Commits since last push:" | |
echo "$commits" | |
total_commits=$(echo "$commits" | wc -l) | |
meta_commits=$(echo "$commits" | grep -E '^\[meta\]' | wc -l) | |
if [ "$total_commits" -eq "$meta_commits" ]; then | |
echo "Only meta commits present, skip publishing" | |
echo "run_publish=false" >> $GITHUB_ENV | |
else | |
echo "run_publish=true" >> $GITHUB_ENV | |
fi | |
- name: Build and publish to maven | |
if: env.run_publish == 'true' | |
run: | | |
chmod +x gradlew | |
./gradlew clean build publish curseforge modrinth --no-configuration-cache | |
env: | |
GIT_COMMIT: ${{ github.sha }} | |
GIT_PREVIOUS_COMMIT: ${{ github.event.before }} | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} |