diff --git a/.github/actions/get-release-notes/action.yml b/.github/actions/get-release-notes/action.yml new file mode 100644 index 000000000..846aa45c9 --- /dev/null +++ b/.github/actions/get-release-notes/action.yml @@ -0,0 +1,38 @@ +name: Return the release notes extracted from the PR body + +# +# Returns the release notes from the content of a pull request linked to a release branch. It expects the branch name to be in the format release/vX.Y.Z, release/X.Y.Z, release/vX.Y.Z-beta.N. etc. +# +# TODO: Remove once the common repo is public. +# +inputs: + version : + required: true + repo_name: + required: false + repo_owner: + required: true + token: + required: true + +runs: + using: composite + + steps: + - uses: actions/github-script@v7 + id: get_release_notes + with: + result-encoding: string + script: | + const { data: pulls } = await github.rest.pulls.list({ + owner: process.env.REPO_OWNER, + repo: process.env.REPO_NAME, + state: 'all', + head: `${process.env.REPO_OWNER}:release/${process.env.VERSION}`, + }); + core.exportVariable('RELEASE_NOTES', pulls[0].body) + env: + GITHUB_TOKEN: ${{ inputs.token }} + REPO_OWNER: ${{ inputs.repo_owner }} + REPO_NAME: ${{ inputs.repo_name }} + VERSION: ${{ inputs.version }} diff --git a/.github/actions/get-version/action.yml b/.github/actions/get-version/action.yml index 387fdba67..9440ec920 100644 --- a/.github/actions/get-version/action.yml +++ b/.github/actions/get-version/action.yml @@ -1,7 +1,7 @@ name: Return the version extracted from the branch name # -# Returns the version from a branch name of a pull request. It expects the branch name to be in the format release/vX.Y.Z, release/X.Y.Z, release/vX.Y.Z-beta.N. etc. +# Returns the version from the .version file. # # TODO: Remove once the common repo is public. # @@ -17,7 +17,5 @@ runs: - id: get_version shell: bash run: | - VERSION=$(echo ${BRANCH_NAME} | sed -r 's#release/+##g') + VERSION=$(head -1 .version) echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - env: - BRANCH_NAME: ${{ github.event.pull_request.head.ref }} diff --git a/.github/actions/tag-create/action.yml b/.github/actions/tag-create/action.yml deleted file mode 100644 index 727df4854..000000000 --- a/.github/actions/tag-create/action.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Create a repository tag - -# -# Creates a tag with the given version. -# -# TODO: Remove once the common repo is public. -# - -inputs: - token: - required: true - tag: - required: true - -runs: - using: composite - - steps: - - shell: bash - run: | - git config user.name "${AUTHOR_USERNAME}" - git config user.email "${AUTHOR_EMAIL}" - env: - AUTHOR_USERNAME: ${{ github.event.pull_request.user.login }} - AUTHOR_EMAIL: ${{ github.event.pull_request.user.email }} - - - shell: bash - run: | - git tag -a ${TAG_NAME} -m "Version ${TAG_NAME}" - git push --follow-tags - env: - TAG_NAME: ${{ inputs.tag }} - GITHUB_TOKEN: ${{ inputs.token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b11376ffe..e01357bc7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: pull_request: types: - closed + workflow_dispatch: permissions: contents: write @@ -16,7 +17,7 @@ env: jobs: release: - if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/') + if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest environment: release @@ -35,6 +36,16 @@ jobs: uses: ./.github/actions/get-prerelease with: version: ${{ steps.get_version.outputs.version }} + + # Get the release notes + # This will expose the release notes as env.RELEASE_NOTES + - id: get_release_notes + uses: ./.github/actions/get-release-notes + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: ${{ steps.get_version.outputs.version }} + repo_owner: ${{ github.repository_owner }} + repo_name: ${{ github.event.repository.name }} # Check if the tag already exists - id: tag_exists @@ -53,18 +64,12 @@ jobs: node-version: ${{ env.NODE_VERSION }} npm-token: ${{ secrets.NPM_TOKEN }} - # Create a tag for the release - - uses: ./.github/actions/tag-create - with: - tag: ${{ steps.get_version.outputs.version }} - token: ${{ secrets.GITHUB_TOKEN }} - # Create a release for the tag - uses: ./.github/actions/release-create with: token: ${{ secrets.GITHUB_TOKEN }} name: ${{ steps.get_version.outputs.version }} - body: ${{ github.event.pull_request.body }} + body: ${{ env.RELEASE_NOTES }} tag: ${{ steps.get_version.outputs.version }} commit: ${{ github.sha }} prerelease: ${{ steps.get_prerelease.outputs.prerelease }} diff --git a/.shiprc b/.shiprc index 5215f1661..17e66ff1b 100644 --- a/.shiprc +++ b/.shiprc @@ -1,8 +1,13 @@ { "files": { "src/version.ts": [], - "README.md": ["{MAJOR}.{MINOR}"], - "FAQ.md": ["{MAJOR}.{MINOR}.{PATCH}"] + ".version": [], + "README.md": [ + "{MAJOR}.{MINOR}" + ], + "FAQ.md": [ + "{MAJOR}.{MINOR}.{PATCH}" + ] }, "postbump": "npm run docs" -} +} \ No newline at end of file diff --git a/.version b/.version new file mode 100644 index 000000000..18f3fb198 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +v2.1.2 \ No newline at end of file