Skip to content

Commit

Permalink
[meta] fix publishing after first push on new branch
Browse files Browse the repository at this point in the history
  • Loading branch information
MelanX committed Jul 2, 2024
1 parent a74a0f0 commit 12b2bb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ jobs:
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 ${{ github.event.before }}..${{ github.sha }} --pretty=format:'%s')
commits=$(git log $GIT_PREVIOUS_COMMIT..${{ github.sha }} --pretty=format:'%s')
echo "Commits since last push:"
echo "$commits"
if echo "$commits" | grep -qE '^\[meta\]'; then
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static String[] getArray(String deps) {
}

String changelog(Project project) {
String logFmt = '--pretty=tformat:- [%s](' + project.changelog_repository.toString() + ') - *%aN*'
String logFmt = '--pretty=tformat:"- [%s](' + project.changelog_repository.toString() + ') - *%aN*"'
def stdout = new ByteArrayOutputStream()
def gitHash = System.getenv('GIT_COMMIT')
def gitPrevHash = System.getenv('GIT_PREVIOUS_COMMIT')
Expand All @@ -236,7 +236,7 @@ String changelog(Project project) {

if (gitHash != null && gitPrevHash != null) {
exec {
commandLine 'sh', '-c', "git log ${logFmt} ${gitPrevHash}...${gitHash} | grep -v '^\\[meta\\]'"
commandLine 'bash', '-c', "git log ${logFmt} ${gitPrevHash}...${gitHash} | grep -v '^\\[meta\\]'"
standardOutput = stdout
}
} else {
Expand Down

0 comments on commit 12b2bb6

Please sign in to comment.