|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + |
| 14 | + check_commit_message: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + patternMatch: ${{ steps.check_pattern.outputs.match }} |
| 18 | + isReleaseComplete: ${{ steps.check_pattern.outputs.release_complete }} |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Check for release pattern in commit message |
| 24 | + id: check_pattern |
| 25 | + run: | |
| 26 | + PATTERN="Release-As: [0-9]+\.[0-9]+\.[0-9]+|release [0-9]+\.[0-9]+\.[0-9]+" |
| 27 | + COMMIT_MESSAGE=$(git log --format=%B -n 1) |
| 28 | + echo "Commit Message: $COMMIT_MESSAGE" |
| 29 | + if [[ "$COMMIT_MESSAGE" =~ $PATTERN ]]; then |
| 30 | + echo "Pattern found. Proceeding with the job." |
| 31 | + echo "::set-output name=match::true" |
| 32 | + else |
| 33 | + echo "Pattern not found. Skipping subsequent steps." |
| 34 | + echo "::set-output name=match::false" |
| 35 | + fi |
| 36 | + PATTERN="release [0-9]+\.[0-9]+\.[0-9]+" |
| 37 | + COMMIT_MESSAGE=$(git log --format=%B -n 1) |
| 38 | + echo "Commit Message: $COMMIT_MESSAGE" |
| 39 | + if [[ "$COMMIT_MESSAGE" =~ $PATTERN ]]; then |
| 40 | + echo "Pattern found. Proceeding with the job." |
| 41 | + echo "::set-output name=release_complete::true" |
| 42 | + else |
| 43 | + echo "Pattern not found. Skipping subsequent steps." |
| 44 | + echo "::set-output name=release_complete::false" |
| 45 | + fi |
| 46 | +
|
| 47 | + release-please: |
| 48 | + needs: check_commit_message |
| 49 | + runs-on: ubuntu-latest |
| 50 | + if: needs.check_commit_message.outputs.patternMatch == 'true' |
| 51 | + steps: |
| 52 | + - uses: google-github-actions/release-please-action@v4 |
| 53 | + with: |
| 54 | + release-type: node |
| 55 | + |
| 56 | + trigger-publish-dispatch: |
| 57 | + name: "Trigger Publish Repository Dispatch Event" |
| 58 | + needs: [release-please, check_commit_message] |
| 59 | + runs-on: ubuntu-latest |
| 60 | + if: needs.check_commit_message.outputs.isReleaseComplete == 'true' |
| 61 | + steps: |
| 62 | + - name: Create Release Repository Dispatch Event |
| 63 | + id: create_release_dispatch |
| 64 | + uses: peter-evans/repository-dispatch@v3 |
| 65 | + with: |
| 66 | + event-type: publish-new-version |
0 commit comments