|
| 1 | +name: "Publish new release" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + types: |
| 8 | + - closed |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + name: Publish new release |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: github.event.pull_request.merged == true # only merged pull requests must trigger this job |
| 15 | + steps: |
| 16 | + - name: Extract version from branch name (for release branches) |
| 17 | + if: startsWith(github.event.pull_request.head.ref, 'release/') |
| 18 | + run: | |
| 19 | + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" |
| 20 | + VERSION=${BRANCH_NAME#release/} |
| 21 | +
|
| 22 | + echo "::set-env name=RELEASE_VERSION::$VERSION" |
| 23 | +
|
| 24 | + - name: Extract version from branch name (for hotfix branches) |
| 25 | + if: startsWith(github.event.pull_request.head.ref, 'hotfix/') |
| 26 | + run: | |
| 27 | + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" |
| 28 | + VERSION=${BRANCH_NAME#hotfix/} |
| 29 | +
|
| 30 | + echo "::set-env name=RELEASE_VERSION::$VERSION" |
| 31 | +
|
| 32 | + - name: Create Release |
| 33 | + uses: fleskesvor/create-release@feature/support-target-commitish |
| 34 | + env: |
| 35 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + with: |
| 37 | + commitish: ${{ github.event.pull_request.merge_commit_sha }} |
| 38 | + tag_name: ${{ env.RELEASE_VERSION }} |
| 39 | + release_name: ${{ env.RELEASE_VERSION }} |
| 40 | + |
| 41 | + - name: Merge release into dev branch |
| 42 | + uses: thomaseizinger/create-pull-request@1.0.0 |
| 43 | + with: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + head: release/${{ env.RELEASE_VERSION }} |
| 46 | + base: dev |
| 47 | + title: Merge release ${{ env.RELEASE_VERSION }} into dev branch |
| 48 | + reviewers: ${{ github.event.pull_request.user.login }} |
| 49 | + |
| 50 | + # if needed, you can checkout the latest master here, build artifacts and publish / deploy them somewhere |
0 commit comments