Skip to content

Commit

Permalink
Add release workflow for GitHub releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Jun 30, 2024
1 parent 572e7ef commit 7ba272d
Showing 1 changed file with 58 additions and 4 deletions.
62 changes: 58 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# GH_TOKEN
# NEXUS_USER
# NEXUS_PASS64 (base64 NOTE: `base64` and `openssl base64` failed, had to use Java
# byte[] data = "{{password}}".getBytes(StandardCharsets.UTF_8);
Expand Down Expand Up @@ -30,13 +29,14 @@ jobs:
runs-on: ubuntu-latest
name: deploy
env:
gh_token: ${{ secrets.GH_TOKEN }}
ORG_GRADLE_PROJECT_nexus_user: ${{ secrets.NEXUS_USER }}
ORG_GRADLE_PROJECT_nexus_pass64: ${{ secrets.NEXUS_PASS64 }}
ORG_GRADLE_PROJECT_gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
ORG_GRADLE_PROJECT_gpg_key64: ${{ secrets.GPG_KEY64 }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: jdk 11
uses: actions/setup-java@v4
with:
Expand All @@ -46,23 +46,77 @@ jobs:
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
- name: git fetch origin main
run: git fetch origin main
- name: Generate release name for lib
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'lib'
run: |
# Find the latest tag in the lib/ namespace
export LIB_TAG=$(git tag --sort=-creatordate --list 'lib/*' | head -n 1)
echo "LIB_TAG=$LIB_TAG" >> $GITHUB_ENV
# Generate the release name looks like "Lib 1.2.3"
echo "LIB_NAME=Lib $(echo $LIB_TAG | cut -d'/' -f2)" >> $GITHUB_ENV
- name: Extract release notes for lib
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'lib'
id: extract-release-notes-for-lib
uses: ffurrer2/extract-release-notes@v2
with:
changelog_file: CHANGES.md
- name: Generate release name for Gradle plugin
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-gradle'
run: |
# Find the latest tag in the gradle/ namespace
export PLUGIN_GRADLE_TAG=$(git tag --sort=-creatordate --list 'gradle/*' | head -n 1)
echo "PLUGIN_GRADLE_TAG=$PLUGIN_GRADLE_TAG" >> $GITHUB_ENV
# Generate the release name looks like "Gradle Plugin 1.2.3"
echo "PLUGIN_GRADLE_NAME=Gradle Plugin $(echo $PLUGIN_GRADLE_TAG | cut -d'/' -f2)" >> $GITHUB_ENV
- name: Extract release notes for Gradle plugin
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-gradle'
id: extract-release-notes-for-plugin-gradle
uses: ffurrer2/extract-release-notes@v2
with:
changelog_file: plugin-gradle/CHANGES.md
- name: Generate release name for Maven plugin
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-maven'
run: |
# Find the latest tag in the maven/ namespace
export PLUGIN_MAVEN_TAG=$(git tag --sort=-creatordate --list 'maven/*' | head -n 1)
echo "PLUGIN_MAVEN_TAG=$PLUGIN_MAVEN_TAG" >> $GITHUB_ENV
# Generate the release name looks like "Maven Plugin 1.2.3"
echo "PLUGIN_MAVEN_NAME=Maven Plugin $(echo $PLUGIN_MAVEN_TAG | cut -d'/' -f2)" >> $GITHUB_ENV
- name: Extract release notes for Maven plugin
if: github.event.inputs.to_publish == 'all' || github.event.inputs.to_publish == 'plugin-maven'
id: extract-release-notes-for-plugin-maven
uses: ffurrer2/extract-release-notes@v2
with:
changelog_file: plugin-maven/CHANGES.md
- name: publish all
if: "${{ github.event.inputs.to_publish == 'all' }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew :changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
./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
./gradlew :plugin-maven:changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
gh release create ${{ env.LIB_TAG }} --title ${{ env.LIB_NAME }} --notes "${{ steps.extract-release-notes-for-lib.outputs.release_notes }}"
gh release create ${{ env.PLUGIN_GRADLE_TAG }} --title ${{ env.PLUGIN_GRADLE_NAME }} --notes "${{ steps.extract-release-notes-for-plugin-gradle.outputs.release_notes }}"
gh release create ${{ env.PLUGIN_MAVEN_TAG }} --title ${{ env.PLUGIN_MAVEN_NAME }} --notes "${{ steps.extract-release-notes-for-plugin-maven.outputs.release_notes }}"
- name: publish just plugin-gradle
if: "${{ github.event.inputs.to_publish == 'plugin-gradle' }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./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
gh release create ${{ env.LIB_TAG }} --title ${{ env.LIB_NAME }} --notes "${{ steps.extract-release-notes-for-lib.outputs.release_notes }}"
- name: publish just plugin-maven
if: "${{ github.event.inputs.to_publish == 'plugin-maven' }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew :plugin-maven:changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
gh release create ${{ env.PLUGIN_GRADLE_TAG }} --title ${{ env.PLUGIN_GRADLE_NAME }} --notes "${{ steps.extract-release-notes-for-plugin-gradle.outputs.release_notes }}"
- name: publish just lib
if: "${{ github.event.inputs.to_publish == 'lib' }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew :changelogPush -Prelease=true --stacktrace --warning-mode all --no-configuration-cache
gh release create ${{ env.PLUGIN_MAVEN_TAG }} --title ${{ env.PLUGIN_MAVEN_NAME }} --notes "${{ steps.extract-release-notes-for-plugin-maven.outputs.release_notes }}"

0 comments on commit 7ba272d

Please sign in to comment.