Skip to content

Commit fbe0f0b

Browse files
committed
Add release workflow for GitHub releases
1 parent 572e7ef commit fbe0f0b

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

.github/workflows/deploy.yml

+54-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GH_TOKEN
1+
# GITHUB_TOKEN
22
# NEXUS_USER
33
# NEXUS_PASS64 (base64 NOTE: `base64` and `openssl base64` failed, had to use Java
44
# byte[] data = "{{password}}".getBytes(StandardCharsets.UTF_8);
@@ -30,13 +30,17 @@ jobs:
3030
runs-on: ubuntu-latest
3131
name: deploy
3232
env:
33-
gh_token: ${{ secrets.GH_TOKEN }}
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434
ORG_GRADLE_PROJECT_nexus_user: ${{ secrets.NEXUS_USER }}
3535
ORG_GRADLE_PROJECT_nexus_pass64: ${{ secrets.NEXUS_PASS64 }}
3636
ORG_GRADLE_PROJECT_gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
3737
ORG_GRADLE_PROJECT_gpg_key64: ${{ secrets.GPG_KEY64 }}
38+
permissions:
39+
contents: write
3840
steps:
3941
- uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0 # All tags should be fetched.
4044
- name: jdk 11
4145
uses: actions/setup-java@v4
4246
with:
@@ -46,23 +50,69 @@ jobs:
4650
uses: gradle/actions/setup-gradle@v3
4751
with:
4852
gradle-home-cache-cleanup: true
49-
- name: git fetch origin main
50-
run: git fetch origin main
53+
- name: Generate release name for lib
54+
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'lib'
55+
run: |
56+
# Find the latest tag in the lib/ namespace
57+
export LIB_TAG=$(git tag --sort=-creatordate --list 'lib/*' | head -n 1)
58+
echo "LIB_TAG=$LIB_TAG" >> $GITHUB_ENV
59+
# Generate the release name looks like "Lib 1.2.3"
60+
echo "LIB_NAME=Lib $(echo $LIB_TAG | cut -d'/' -f2)" >> $GITHUB_ENV
61+
- name: Extract release notes for lib
62+
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'lib'
63+
uses: ffurrer2/extract-release-notes@v2
64+
with:
65+
changelog_file: CHANGES.md
66+
release_notes_file: RELEASE_NOTES_FOR_LIB.md
67+
- name: Generate release name for Gradle plugin
68+
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-gradle'
69+
run: |
70+
# Find the latest tag in the gradle/ namespace
71+
export PLUGIN_GRADLE_TAG=$(git tag --sort=-creatordate --list 'gradle/*' | head -n 1)
72+
echo "PLUGIN_GRADLE_TAG=$PLUGIN_GRADLE_TAG" >> $GITHUB_ENV
73+
# Generate the release name looks like "Gradle Plugin 1.2.3"
74+
echo "PLUGIN_GRADLE_NAME=Gradle Plugin $(echo $PLUGIN_GRADLE_TAG | cut -d'/' -f2)" >> $GITHUB_ENV
75+
- name: Extract release notes for Gradle plugin
76+
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-gradle'
77+
uses: ffurrer2/extract-release-notes@v2
78+
with:
79+
changelog_file: plugin-gradle/CHANGES.md
80+
release_notes_file: RELEASE_NOTES_FOR_PLUGIN_GRADLE.md
81+
- name: Generate release name for Maven plugin
82+
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-maven'
83+
run: |
84+
# Find the latest tag in the maven/ namespace
85+
export PLUGIN_MAVEN_TAG=$(git tag --sort=-creatordate --list 'maven/*' | head -n 1)
86+
echo "PLUGIN_MAVEN_TAG=$PLUGIN_MAVEN_TAG" >> $GITHUB_ENV
87+
# Generate the release name looks like "Maven Plugin 1.2.3"
88+
echo "PLUGIN_MAVEN_NAME=Maven Plugin $(echo $PLUGIN_MAVEN_TAG | cut -d'/' -f2)" >> $GITHUB_ENV
89+
- name: Extract release notes for Maven plugin
90+
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-maven'
91+
uses: ffurrer2/extract-release-notes@v2
92+
with:
93+
changelog_file: plugin-maven/CHANGES.md
94+
release_notes_file: RELEASE_NOTES_FOR_PLUGIN_MAVEN.md
5195
- name: publish all
5296
if: "${{ github.event.inputs.to_publish == 'all' }}"
5397
run: |
5498
./gradlew :changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
5599
./gradlew :plugin-gradle:changelogPush -Prelease=true -Pgradle.publish.key=${{ secrets.GRADLE_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_SECRET }} --stacktrace --warning-mode all --no-configuration-cache
56100
./gradlew :plugin-maven:changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
101+
gh release create ${{ env.LIB_TAG }} --title '${{ env.LIB_NAME }}' --notes-file RELEASE_NOTES_FOR_LIB.md
102+
gh release create ${{ env.PLUGIN_GRADLE_TAG }} --title '${{ env.PLUGIN_GRADLE_NAME }}' --notes-file RELEASE_NOTES_FOR_PLUGIN_GRADLE.md
103+
gh release create ${{ env.PLUGIN_MAVEN_TAG }} --title '${{ env.PLUGIN_MAVEN_NAME }}' --notes-file RELEASE_NOTES_FOR_PLUGIN_MAVEN.md
57104
- name: publish just plugin-gradle
58105
if: "${{ github.event.inputs.to_publish == 'plugin-gradle' }}"
59106
run: |
60107
./gradlew :plugin-gradle:changelogPush -Prelease=true -Pgradle.publish.key=${{ secrets.GRADLE_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_SECRET }} --stacktrace --warning-mode all --no-configuration-cache
108+
gh release create ${{ env.PLUGIN_GRADLE_TAG }} --title '${{ env.PLUGIN_GRADLE_NAME }}' --notes-file RELEASE_NOTES_FOR_PLUGIN_GRADLE.md
61109
- name: publish just plugin-maven
62110
if: "${{ github.event.inputs.to_publish == 'plugin-maven' }}"
63111
run: |
64112
./gradlew :plugin-maven:changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
113+
gh release create ${{ env.PLUGIN_MAVEN_TAG }} --title '${{ env.PLUGIN_MAVEN_NAME }}' --notes-file RELEASE_NOTES_FOR_PLUGIN_MAVEN.md
65114
- name: publish just lib
66115
if: "${{ github.event.inputs.to_publish == 'lib' }}"
67116
run: |
68117
./gradlew :changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
118+
gh release create ${{ env.LIB_TAG }} --title '${{ env.LIB_NAME }}' --notes-file RELEASE_NOTES_FOR_LIB.md

0 commit comments

Comments
 (0)