|
| 1 | +name: Create GitHub Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - closed |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + id-token: write # For publishing to npm using --provenance |
| 12 | + |
| 13 | +env: |
| 14 | + NODE_VERSION: 18 |
| 15 | + |
| 16 | +### TODO: Replace instances of './.github/actions/' w/ `auth0/dx-sdk-actions/` and append `@latest` after the common `dx-sdk-actions` repo is made public. |
| 17 | +### 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. |
| 18 | + |
| 19 | +jobs: |
| 20 | + release: |
| 21 | + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')) |
| 22 | + runs-on: ubuntu-latest |
| 23 | + environment: release |
| 24 | + |
| 25 | + steps: |
| 26 | + # Checkout the code |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + # Get the version from the branch name |
| 32 | + - id: get_version |
| 33 | + uses: ./.github/actions/get-version |
| 34 | + |
| 35 | + # Get the prerelease flag from the branch name |
| 36 | + - id: get_prerelease |
| 37 | + uses: ./.github/actions/get-prerelease |
| 38 | + with: |
| 39 | + version: ${{ steps.get_version.outputs.version }} |
| 40 | + |
| 41 | + # Get the release notes |
| 42 | + # This will expose the release notes as env.RELEASE_NOTES |
| 43 | + - id: get_release_notes |
| 44 | + uses: ./.github/actions/get-release-notes |
| 45 | + with: |
| 46 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + version: ${{ steps.get_version.outputs.version }} |
| 48 | + repo_owner: ${{ github.repository_owner }} |
| 49 | + repo_name: ${{ github.event.repository.name }} |
| 50 | + |
| 51 | + # Check if the tag already exists |
| 52 | + - id: tag_exists |
| 53 | + uses: ./.github/actions/tag-exists |
| 54 | + with: |
| 55 | + tag: ${{ steps.get_version.outputs.version }} |
| 56 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + |
| 58 | + # If the tag already exists, exit with an error |
| 59 | + - if: steps.tag_exists.outputs.exists == 'true' |
| 60 | + run: exit 1 |
| 61 | + |
| 62 | + # Publish the release to our package manager |
| 63 | + - uses: ./.github/actions/publish-package |
| 64 | + with: |
| 65 | + node-version: ${{ env.NODE_VERSION }} |
| 66 | + version: ${{ steps.get_version.outputs.version }} |
| 67 | + npm-token: ${{ secrets.NPM_TOKEN }} |
| 68 | + release-directory: './dist/auth0-angular' |
| 69 | + |
| 70 | + # Create a release for the tag |
| 71 | + - uses: ./.github/actions/release-create |
| 72 | + with: |
| 73 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + name: ${{ steps.get_version.outputs.version }} |
| 75 | + body: ${{ env.RELEASE_NOTES }} |
| 76 | + tag: ${{ steps.get_version.outputs.version }} |
| 77 | + commit: ${{ github.sha }} |
| 78 | + prerelease: ${{ steps.get_prerelease.outputs.prerelease }} |
0 commit comments