|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [ published ] |
| 5 | +env: |
| 6 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 7 | + GRAILS_PUBLISH_RELEASE: 'true' |
| 8 | + JAVA_DISTRIBUTION: liberica |
| 9 | + JAVA_VERSION: 17.0.17 # this must be a specific version for reproducible builds, keep in sync with .sdkmanrc |
| 10 | + REPO_NAME: ${{ github.event.repository.name }} |
| 11 | + TAG: ${{ github.event.release.tag_name }} |
| 12 | + VERSION: will be computed in each job |
| 13 | +jobs: |
| 14 | + publish: |
| 15 | + name: "Create and Stage Release Artifacts" |
| 16 | + permissions: |
| 17 | + contents: write # to add distribution to the GitHub release page |
| 18 | + issues: write # to modify milestones |
| 19 | + runs-on: ubuntu-24.04 |
| 20 | + steps: |
| 21 | + - name: "📝 Establish release version" |
| 22 | + run: | |
| 23 | + echo "Release version: ${TAG#v}" |
| 24 | + echo "VERSION=${TAG#v}" >> "$GITHUB_ENV" |
| 25 | + - name: "📥 Checkout the repository" |
| 26 | + uses: actions/checkout@v5 |
| 27 | + with: |
| 28 | + ref: ${{ env.TAG }} |
| 29 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + - name: "📅 Store common build date" # to ensure a reproducible build |
| 31 | + run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> "$GITHUB_ENV" |
| 32 | + - name: "📅 Ensure source files use common date" |
| 33 | + run: find . -depth \( -type f -o -type d \) -exec touch -d "@${SOURCE_DATE_EPOCH}" {} + |
| 34 | + - name: "☕️ Setup JDK" |
| 35 | + uses: actions/setup-java@v5 |
| 36 | + with: |
| 37 | + distribution: ${{ env.JAVA_DISTRIBUTION }} |
| 38 | + java-version: ${{ env.JAVA_VERSION }} |
| 39 | + - name: "🐘 Setup Gradle" |
| 40 | + uses: gradle/actions/setup-gradle@v5 |
| 41 | + - name: "⚙️ Run pre-release" |
| 42 | + uses: grails/github-actions/pre-release@asf |
| 43 | + env: |
| 44 | + RELEASE_VERSION: ${{ env.VERSION }} |
| 45 | + - name: "🔐 Generate key file for artifact signing" |
| 46 | + env: |
| 47 | + SECRING_FILE: ${{ secrets.SECRING_FILE }} |
| 48 | + run: | |
| 49 | + printf "%s" "$SECRING_FILE" | base64 -d > "${{ github.workspace }}/secring.gpg" |
| 50 | + - name: "📤 Publish to Maven Central" |
| 51 | + env: |
| 52 | + NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }} |
| 53 | + NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }} |
| 54 | + NEXUS_PUBLISH_URL: 'https://ossrh-staging-api.central.sonatype.com/service/local/' |
| 55 | + NEXUS_PUBLISH_DESCRIPTION: '${{ env.REPO_NAME }}:${{ env.VERSION }}' |
| 56 | + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} |
| 57 | + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} |
| 58 | + run: > |
| 59 | + ./gradlew |
| 60 | + -Psigning.keyId=${SIGNING_KEY} |
| 61 | + -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg |
| 62 | + publishMavenPublicationToSonatypeRepository |
| 63 | + closeSonatypeStagingRepository |
| 64 | + - name: "📅 Generate Build Date file" |
| 65 | + run: echo "$SOURCE_DATE_EPOCH" >> build/BUILD_DATE.txt |
| 66 | + - name: "📤 Upload Build Date file" |
| 67 | + uses: softprops/action-gh-release@v2 |
| 68 | + with: |
| 69 | + tag_name: ${{ env.TAG }} |
| 70 | + files: build/BUILD_DATE.txt |
| 71 | + release: |
| 72 | + name: "Release Staging Repository, Publish Docs and Run Post-Release" |
| 73 | + needs: publish |
| 74 | + runs-on: ubuntu-24.04 |
| 75 | + permissions: |
| 76 | + contents: write |
| 77 | + issues: write |
| 78 | + pull-requests: write |
| 79 | + steps: |
| 80 | + - name: "📝 Establish release version" |
| 81 | + run: | |
| 82 | + echo "Release version: ${TAG#v}" |
| 83 | + echo "VERSION=${TAG#v}" >> "$GITHUB_ENV" |
| 84 | + - name: "📥 Checkout repository" |
| 85 | + uses: actions/checkout@v5 |
| 86 | + with: |
| 87 | + ref: ${{ env.TAG }} |
| 88 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + - name: "☕️ Setup JDK" |
| 90 | + uses: actions/setup-java@v5 |
| 91 | + with: |
| 92 | + distribution: ${{ env.JAVA_DISTRIBUTION }} |
| 93 | + java-version: ${{ env.JAVA_VERSION }} |
| 94 | + - name: "🐘 Setup Gradle" |
| 95 | + uses: gradle/actions/setup-gradle@v5 |
| 96 | + - name: "📤 Release staging repository" |
| 97 | + env: |
| 98 | + NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }} |
| 99 | + NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }} |
| 100 | + NEXUS_PUBLISH_URL: 'https://ossrh-staging-api.central.sonatype.com/service/local/' |
| 101 | + NEXUS_PUBLISH_DESCRIPTION: '${{ env.REPO_NAME }}:${{ env.VERSION }}' |
| 102 | + run: > |
| 103 | + ./gradlew |
| 104 | + findSonatypeStagingRepository |
| 105 | + releaseSonatypeStagingRepository |
| 106 | + - name: "📖 Generate Documentation" |
| 107 | + run: ./gradlew docs |
| 108 | + - name: "📤 Publish Documentation to Github Pages" |
| 109 | + uses: apache/grails-github-actions/deploy-github-pages@asf |
| 110 | + env: |
| 111 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + GRADLE_PUBLISH_RELEASE: 'true' |
| 113 | + SOURCE_FOLDER: plugin/build/docs |
| 114 | + - name: "⚙️ Run post-release" |
| 115 | + uses: apache/grails-github-actions/post-release@asf |
0 commit comments