|
| 1 | +name: Create GitHub Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - closed |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +### TODO: Replace instances of './.github/actions/' w/ `auth0/dx-sdk-actions/` and append `@latest` after the common `dx-sdk-actions` repo is made public. |
| 12 | +### TODO: Also remove `get-prerelease`, `get-version`, `release-create`, `tag-create` and `tag-exists` actions from this repo's .github/actions folder once the repo is public. |
| 13 | + |
| 14 | +jobs: |
| 15 | + release: |
| 16 | + if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/') |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + # Checkout the code |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + # Get the version from the branch name |
| 26 | + - id: get_version |
| 27 | + uses: ./.github/actions/get-version |
| 28 | + |
| 29 | + # Get the prerelease flag from the branch name |
| 30 | + - id: get_prerelease |
| 31 | + uses: ./.github/actions/get-prerelease |
| 32 | + with: |
| 33 | + version: ${{ steps.get_version.outputs.version }} |
| 34 | + |
| 35 | + # Check if the tag already exists |
| 36 | + - id: tag_exists |
| 37 | + uses: ./.github/actions/tag-exists |
| 38 | + with: |
| 39 | + tag: ${{ steps.get_version.outputs.version }} |
| 40 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + # If the tag already exists, exit with an error |
| 43 | + - if: steps.tag_exists.outputs.exists == 'true' |
| 44 | + run: exit 1 |
| 45 | + |
| 46 | + # Publish the release to our package manager |
| 47 | + - uses: ./.github/actions/publish-package |
| 48 | + with: |
| 49 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + name: ${{ steps.get_version.outputs.version }} |
| 51 | + body: ${{ github.event.pull_request.body }} |
| 52 | + tag: ${{ steps.get_version.outputs.version }} |
| 53 | + commit: ${{ github.sha }} |
| 54 | + prerelease: ${{ steps.get_prerelease.outputs.prerelease }} |
| 55 | + |
| 56 | + # Create a tag for the release |
| 57 | + - uses: ./.github/actions/tag-create |
| 58 | + with: |
| 59 | + tag: ${{ steps.get_version.outputs.version }} |
| 60 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + |
| 62 | + # Create a release for the tag |
| 63 | + - uses: ./.github/actions/release-create |
| 64 | + with: |
| 65 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + name: ${{ steps.get_version.outputs.version }} |
| 67 | + body: ${{ github.event.pull_request.body }} |
| 68 | + tag: ${{ steps.get_version.outputs.version }} |
| 69 | + commit: ${{ github.sha }} |
| 70 | + prerelease: ${{ steps.get_prerelease.outputs.prerelease }} |
0 commit comments