|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [ published ] |
| 5 | +env: |
| 6 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 7 | + JAVA_VERSION: '17.0.15' # this must be a specific version for reproducible builds |
| 8 | + RELEASE_TAG_PREFIX: 'v' |
| 9 | + DOCUMENTATION: 'false' |
| 10 | +jobs: |
| 11 | + publish: |
| 12 | + permissions: |
| 13 | + packages: read # pre-release workflow |
| 14 | + contents: write # to create release |
| 15 | + issues: write # to modify milestones |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + release_version: ${{ steps.release_version.outputs.value }} |
| 19 | + extract_repository_name: ${{ steps.extract_repository_name.outputs.repository_name }} |
| 20 | + steps: |
| 21 | + - name: "📝 Store the current release version" |
| 22 | + id: release_version |
| 23 | + run: | |
| 24 | + export RELEASE_VERSION="${{ github.ref_name }}" |
| 25 | + export RELEASE_VERSION=${RELEASE_VERSION:${#RELEASE_TAG_PREFIX}} |
| 26 | + echo "Found Release Version: ${RELEASE_VERSION}" |
| 27 | + echo "value=${RELEASE_VERSION}" >> $GITHUB_OUTPUT |
| 28 | + - name: "Extract repository name" |
| 29 | + id: extract_repository_name |
| 30 | + run: | |
| 31 | + echo "repository_name=${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT |
| 32 | + - name: "📥 Checkout the repository" |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + ref: v${{ steps.release_version.outputs.value }} |
| 37 | + - name: 'Ensure Common Build Date' # to ensure a reproducible build |
| 38 | + run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> "$GITHUB_ENV" |
| 39 | + - name: "Ensure source files use common date" |
| 40 | + run: | |
| 41 | + find . -depth \( -type f -o -type d \) -exec touch -d "@${SOURCE_DATE_EPOCH}" {} + |
| 42 | + - name: "☕️ Setup JDK" |
| 43 | + uses: actions/setup-java@v4 |
| 44 | + with: |
| 45 | + distribution: liberica |
| 46 | + java-version: ${{ env.JAVA_VERSION }} |
| 47 | + - name: "🐘 Setup Gradle" |
| 48 | + uses: gradle/actions/setup-gradle@v4 |
| 49 | + - name: "⚙️ Run pre-release" |
| 50 | + uses: grails/github-actions/pre-release@asf |
| 51 | + env: |
| 52 | + RELEASE_VERSION: ${{ steps.release_version.outputs.value }} |
| 53 | + - name: "🔐 Generate key file for artifact signing" |
| 54 | + env: |
| 55 | + SECRING_FILE: ${{ secrets.SECRING_FILE }} |
| 56 | + run: | |
| 57 | + printf "%s" "$SECRING_FILE" | base64 -d > "${{ github.workspace }}/secring.gpg" |
| 58 | + - name: "🧩 Run Assemble" |
| 59 | + id: assemble |
| 60 | + run: | |
| 61 | + ./gradlew -U assemble -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg -Psigning.keyId=${{ secrets.SIGNING_KEY }} |
| 62 | + env: |
| 63 | + GRAILS_PUBLISH_RELEASE: 'true' |
| 64 | + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} |
| 65 | + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} |
| 66 | + - name: "📤 Publish to Maven Central" |
| 67 | + env: |
| 68 | + GRAILS_PUBLISH_RELEASE: 'true' |
| 69 | + NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }} |
| 70 | + NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }} |
| 71 | + NEXUS_PUBLISH_URL: 'https://ossrh-staging-api.central.sonatype.com/service/local/' |
| 72 | + NEXUS_PUBLISH_DESCRIPTION: '${{ steps.extract_repository_name.outputs.repository_name }}:${{ steps.release_version.outputs.value }}' |
| 73 | + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} |
| 74 | + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} |
| 75 | + run: > |
| 76 | + ./gradlew |
| 77 | + -Psigning.keyId=${{ secrets.SIGNING_KEY }} |
| 78 | + -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg |
| 79 | + publishMavenPublicationToSonatypeRepository |
| 80 | + closeSonatypeStagingRepository |
| 81 | + - name: "Generate Build Date file" |
| 82 | + run: echo "$SOURCE_DATE_EPOCH" >> build/BUILD_DATE.txt |
| 83 | + - name: "Upload Build Date file" |
| 84 | + uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 |
| 85 | + with: |
| 86 | + files: build/BUILD_DATE.txt |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + release: |
| 90 | + needs: publish |
| 91 | + runs-on: ubuntu-latest |
| 92 | + environment: release |
| 93 | + permissions: |
| 94 | + contents: write |
| 95 | + issues: write |
| 96 | + pull-requests: write |
| 97 | + steps: |
| 98 | + - name: "📥 Checkout repository" |
| 99 | + uses: actions/checkout@v4 |
| 100 | + with: |
| 101 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + ref: v${{ needs.publish.outputs.release_version }} |
| 103 | + - name: "☕️ Setup JDK" |
| 104 | + uses: actions/setup-java@v4 |
| 105 | + with: |
| 106 | + distribution: liberica |
| 107 | + java-version: ${{ env.JAVA_VERSION }} |
| 108 | + - name: "🐘 Setup Gradle" |
| 109 | + uses: gradle/actions/setup-gradle@v4 |
| 110 | + - name: "📤 Release staging repository" |
| 111 | + env: |
| 112 | + GRAILS_PUBLISH_RELEASE: 'true' |
| 113 | + NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }} |
| 114 | + NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }} |
| 115 | + NEXUS_PUBLISH_URL: 'https://ossrh-staging-api.central.sonatype.com/service/local/' |
| 116 | + NEXUS_PUBLISH_DESCRIPTION: '${{ needs.publish.outputs.extract_repository_name }}:${{ needs.publish.outputs.release_version }}' |
| 117 | + run: > |
| 118 | + ./gradlew |
| 119 | + findSonatypeStagingRepository |
| 120 | + releaseSonatypeStagingRepository |
| 121 | + - name: "📖 Generate Documentation" |
| 122 | + if: ${{ env.DOCUMENTATION != 'false' }} |
| 123 | + run: ./gradlew docs |
| 124 | + - name: "📤 Publish Documentation to Github Pages" |
| 125 | + if: ${{ env.DOCUMENTATION != 'false' }} |
| 126 | + uses: apache/grails-github-actions/deploy-github-pages@asf |
| 127 | + env: |
| 128 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + GRADLE_PUBLISH_RELEASE: 'true' |
| 130 | + SOURCE_FOLDER: build/docs |
| 131 | + VERSION: ${{ needs.publish.outputs.release_version }} |
| 132 | + - name: "⚙️ Run post-release" |
| 133 | + uses: apache/grails-github-actions/post-release@asf |
0 commit comments