Skip to content

Commit be4cc34

Browse files
authored
Merge pull request #43 from domaframework/ci/modify-release-action
Additional control over update log change actions
2 parents 5f13398 + 6118f74 commit be4cc34

File tree

4 files changed

+24
-71
lines changed

4 files changed

+24
-71
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,6 @@ jobs:
5555
- name: Setup Gradle
5656
uses: gradle/actions/setup-gradle@v4
5757

58-
# Set environment variables
59-
- name: Export Properties
60-
id: properties
61-
shell: bash
62-
run: |
63-
PROPERTIES="$(./gradlew properties --console=plain -q)"
64-
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
65-
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
66-
67-
echo "version=$VERSION" >> $GITHUB_OUTPUT
68-
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
69-
70-
echo "changelog<<EOF" >> $GITHUB_OUTPUT
71-
echo "$CHANGELOG" >> $GITHUB_OUTPUT
72-
echo "EOF" >> $GITHUB_OUTPUT
73-
7458
# Generate Lexer and Parser
7559
- name: Generate Lexer
7660
run: ./gradlew generateLexer

.github/workflows/release.yml

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,6 @@ jobs:
3535
- name: Setup Gradle
3636
uses: gradle/actions/setup-gradle@v4
3737

38-
# Set environment variables
39-
- name: Export Properties
40-
id: properties
41-
shell: bash
42-
run: |
43-
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
44-
${{ github.event.release.body }}
45-
EOM
46-
)"
47-
48-
echo "changelog<<EOF" >> $GITHUB_OUTPUT
49-
echo "$CHANGELOG" >> $GITHUB_OUTPUT
50-
echo "EOF" >> $GITHUB_OUTPUT
51-
52-
# Update the Unreleased section with the current release note
53-
- name: Patch Changelog
54-
if: ${{ steps.properties.outputs.changelog != '' }}
55-
env:
56-
CHANGELOG: ${{ steps.properties.outputs.changelog }}
57-
run: |
58-
./gradlew patchChangelog --release-note="$CHANGELOG"
59-
6038
# Generate Lexer and Parser
6139
- name: Generate Lexer
6240
run: ./gradlew generateLexer
@@ -77,32 +55,4 @@ jobs:
7755
- name: Upload Release Asset
7856
env:
7957
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80-
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
81-
82-
# Create a pull request
83-
- name: Create Pull Request
84-
if: ${{ steps.properties.outputs.changelog != '' }}
85-
env:
86-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87-
run: |
88-
VERSION="${{ github.event.release.tag_name }}"
89-
BRANCH="changelog-update-$VERSION"
90-
LABEL="release changelog"
91-
92-
git config user.email "[email protected]"
93-
git config user.name "GitHub Action"
94-
95-
git checkout -b $BRANCH
96-
git commit -am "Changelog update - $VERSION"
97-
git push --set-upstream origin $BRANCH
98-
99-
gh label create "$LABEL" \
100-
--description "Pull requests with release changelog update" \
101-
--force \
102-
|| true
103-
104-
gh pr create \
105-
--title "Changelog update - \`$VERSION\`" \
106-
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
107-
--label "$LABEL" \
108-
--head $BRANCH
58+
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*

.github/workflows/update_changelog.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,26 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19-
update-changelog:
19+
check-commit-message:
2020
runs-on: ubuntu-latest
2121
if: startsWith(github.event.head_commit.message, 'Merge pull request')
22+
outputs:
23+
skip_job: ${{ steps.check.outputs.SKIP_JOB }}
24+
steps:
25+
- name: Check Commit Message
26+
id: check
27+
run: |
28+
if [[ "${{ github.event.head_commit.message }}" =~ ^Merge\ pull\ request\ #[0-9]+\ from\ ${{ github.repository_owner }}/doc/changelog-update-.*$ ]]; then
29+
echo "This commit is not target. Skip the workflow."
30+
echo "SKIP_JOB=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "SKIP_JOB=false" >> $GITHUB_OUTPUT
33+
fi
34+
35+
update-changelog:
36+
runs-on: ubuntu-latest
37+
if: ${{ needs.check-commit-message.outputs.skip_job != 'true' }}
38+
needs: [ check-commit-message ]
2239
steps:
2340

2441
- name: Checkout repository
@@ -38,6 +55,7 @@ jobs:
3855
uses: gradle/actions/setup-gradle@v4
3956

4057
- name: Run Gradle updateChangelog
58+
id: updateChangelog
4159
run: |
4260
./gradlew updateChangelog -PreleaseDate=$(date +'%Y-%m-%d')
4361
env:
@@ -76,4 +94,4 @@ jobs:
7694
--label changelog,skip-changelog \
7795
--head $BRANCH \
7896
--draft
79-
fi
97+
fi

build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ tasks.register("updateChangelog") {
208208
val id: Long = 0,
209209
val name: String = "",
210210
val color: String = "",
211-
val description: String = "",
211+
val description: String? = "",
212212
)
213213

214214
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -458,9 +458,10 @@ tasks.register("checkExistChangelogPullRequest") {
458458
// https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests
459459
val apiPath = "https://api.github.com/search/issues"
460460
val status = "is:open"
461+
val type = "type:pr"
461462
val label = "label:changelog,skip-changelog"
462463
val branch = "base:main+head:$newBranch"
463-
val apiUrl = "$apiPath?q=repo:$repo+is:pr+$branch+$label+$status"
464+
val apiUrl = "$apiPath?q=repo:$repo+$branch+$label+$status+$type"
464465
val connection =
465466
URL(apiUrl).openConnection().apply {
466467
setRequestProperty("Authorization", "token $githubToken")

0 commit comments

Comments
 (0)