|
| 1 | +name: release-version-check |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, edited, synchronize] |
| 6 | + branches: |
| 7 | + - master |
| 8 | + - develop |
| 9 | + |
| 10 | +jobs: |
| 11 | + check-rc-pattern: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: startsWith(github.head_ref, 'release') |
| 14 | + steps: |
| 15 | + - name: Check RC pattern |
| 16 | + run: | |
| 17 | + if [[ "${{ github.head_ref }}" =~ release/[0-9]+\.[0-9]+\.[0-9]+-rc ]]; then |
| 18 | + echo "Branch name contains release/version-rc pattern. Merging is not allowed. Only stable release should be merge into master" |
| 19 | + exit 1 |
| 20 | + fi |
| 21 | + env: |
| 22 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + |
| 24 | + check-master-version: |
| 25 | + needs: check-rc-pattern |
| 26 | + runs-on: ubuntu-latest |
| 27 | + if: github.base_ref == 'master' && startsWith(github.head_ref, 'release') |
| 28 | + steps: |
| 29 | + - name: Checkout master branch |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + ref: master |
| 33 | + path: master |
| 34 | + - name: Checkout release branch |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + ref: ${{ github.head_ref }} |
| 38 | + path: release |
| 39 | + - name: Extract versions |
| 40 | + run: | |
| 41 | + MASTER_VERSION=$(grep 'target-version' master/package.json | awk '{print $2}' | tr -d '",') |
| 42 | + RELEASE_VERSION=$(grep 'target-version' release/package.json | awk '{print $2}' | tr -d '",') |
| 43 | + echo "MASTER_VERSION=$MASTER_VERSION" >> $GITHUB_ENV |
| 44 | + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV |
| 45 | + - name: Compare versions |
| 46 | + uses: jackbilestech/semver-compare@1.0.4 |
| 47 | + with: |
| 48 | + head: ${{ env.RELEASE_VERSION }} |
| 49 | + base: ${{ env.MASTER_VERSION }} |
| 50 | + operator: '>' |
0 commit comments