|
| 1 | +name: Create GitHub Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - closed |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/') |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + # Checkout the code |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + # Get the version from the branch name |
| 23 | + - id: get_version |
| 24 | + uses: auth0/dx-sdk-actions/get-version@latest |
| 25 | + |
| 26 | + # Get the prerelease flag from the branch name |
| 27 | + - id: get_prerelease |
| 28 | + uses: auth0/dx-sdk-actions/get-prerelease@latest |
| 29 | + with: |
| 30 | + version: ${{ steps.get_version.outputs.version }} |
| 31 | + |
| 32 | + # Check if the tag already exists |
| 33 | + - id: tag_exists |
| 34 | + uses: auth0/dx-sdk-actions/tag-exists@latest |
| 35 | + with: |
| 36 | + tag: ${{ steps.get_version.outputs.version }} |
| 37 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + |
| 39 | + # If the tag already exists, exit with an error |
| 40 | + - if: steps.tag_exists.outputs.exists == 'true' |
| 41 | + run: exit 1 |
| 42 | + |
| 43 | + ######################################################################### |
| 44 | + # Relevant build steps here |
| 45 | + ######################################################################### |
| 46 | + |
| 47 | + # Create a tag for the release |
| 48 | + - uses: auth0/dx-sdk-actions/tag-create@latest |
| 49 | + with: |
| 50 | + tag: ${{ steps.get_version.outputs.version }} |
| 51 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + |
| 53 | + # Create a release for the tag |
| 54 | + - uses: auth0/dx-sdk-actions/release-create@latest |
| 55 | + with: |
| 56 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + name: ${{ github.event.pull_request.title }} |
| 58 | + body: ${{ github.event.pull_request.body }} |
| 59 | + tag: ${{ steps.get_version.outputs.version }} |
| 60 | + commit: ${{ github.sha }} |
| 61 | + prerelease: ${{ steps.get_prerelease.outputs.prerelease }} |
0 commit comments