|
| 1 | +# This workflow creates a tag, publishes to Maven Central, and creates a GitHub Release |
| 2 | + |
| 3 | +name: AutoMapper Release and Publish |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - 'main' # Triggers on any push to main, including merges |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + # This condition ensures the job only runs for merge commits from a release branch |
| 13 | + if: startsWith(github.event.pull_request.title, 'Prepare release of Kotlin AutoMapper') |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Extract version from merge commit |
| 25 | + id: get_version |
| 26 | + run: | |
| 27 | + COMMIT_MSG="${{ github.event.head_commit.message }}" |
| 28 | + VERSION=$(echo "$COMMIT_MSG" | sed 's/Prepare release of Kotlin AutoMapper //') |
| 29 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 30 | +
|
| 31 | + - name: Create and push Git Tag |
| 32 | + run: | |
| 33 | + git config user.name "github-actions[bot]" |
| 34 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 35 | + git tag "${{ steps.get_version.outputs.version }}" |
| 36 | + git push origin "${{ steps.get_version.outputs.version }}" |
| 37 | +
|
| 38 | + - name: Set up JDK 21 |
| 39 | + uses: actions/setup-java@v4 |
| 40 | + with: |
| 41 | + java-version: '21' |
| 42 | + distribution: 'temurin' |
| 43 | + |
| 44 | + - name: Grant execute permission for gradlew |
| 45 | + run: chmod +x ./gradlew |
| 46 | + |
| 47 | +# - name: Publish to Maven Central |
| 48 | +# run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel |
| 49 | +# env: |
| 50 | +# ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} |
| 51 | +# ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_TOKEN }} |
| 52 | +# ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }} |
| 53 | +# ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }} |
| 54 | + |
| 55 | + - name: Create GitHub Release |
| 56 | + uses: ncipollo/release-action@v1 |
| 57 | + with: |
| 58 | + tag: '${{ steps.get_version.outputs.version }}' |
| 59 | + name: '${{ steps.get_version.outputs.version }}' |
| 60 | + generateReleaseNotes: true |
0 commit comments