Repository: release-drafter/release-drafter
Pull request #1385 (2024-03-26 09:35:59)

Update only drafts with the same prerelease status
Do **not** update *final* release drafts with when drafting a *prerelease* and vice versa

Given the following releases:

Name | Draft | Prerelease
-- | -- | --
v3.4.0 |   |  
v3.5.0-rc.4 |   | ✅
v3.5.0 | ✅  |  
v3.5.0-rc.5 | ✅ | ✅

when running release-drafter with this config:

```
prerelease: true
prerelease-identifier: rc
```

I'd expect the draft of `v3.5.0-rc.5` to be updated instead of `v3.5.0`.

This allows me to maintain a draft for the next prerelease, listing the changes since the previous prerelease, and a draft for the next final release, listing the changes since the previous final release.



Patch:
diff --git a/.github/workflows/action-build.yml b/.github/workflows/action-build.yml
index bea15c0..278d333 100644
--- a/.github/workflows/action-build.yml
+++ b/.github/workflows/action-build.yml
@@ -1,6 +1,6 @@
 name: Dependabot post-update
 on:
-  pull_request_target:
+  pull_request:
     types: [opened, synchronize, reopened]
     branches:
       - 'master'
@@ -8,23 +8,23 @@ on:
 env:
   HUSKY: '0'
 
+permissions:
+  contents: write
+  pull-requests: write
+
 concurrency:
   group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
   cancel-in-progress: true
 
 jobs:
   post-update:
-    if: ${{ github.actor == 'dependabot[bot]' }}
+    if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'release-drafter/release-drafter'
     runs-on: ubuntu-latest
     steps:
       - name: Checkout
-        uses: actions/checkout@v3
-
-      - name: Checkout out pull request
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          gh pr checkout ${{ github.event.pull_request.number }}
+        uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.pull_request.head.ref }}
 
       - uses: actions/setup-node@v3
         with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e931839..e62c8f0 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,6 +9,7 @@ env:
 
 jobs:
   build:
+    if: github.repository == 'release-drafter/release-drafter'
     runs-on: ubuntu-latest
     steps:
       - name: Checkout
@@ -29,14 +30,6 @@ jobs:
       - name: yarn test
         run: yarn test
 
-      - name: Deploy to Heroku
-        env:
-          HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }}
-          HEROKU_APP_NAME: release-drafter
-        run: |
-          git fetch origin master
-          git push https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git origin/master:master --force
-
       - name: yarn publish
         env:
           NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
diff --git a/README.md b/README.md
index ea63cff..189d7c0 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
 
 ## Usage
 
-You can use the [Release Drafter GitHub Action](https://github.com/marketplace/actions/release-drafter) in a [GitHub Actions Workflow](https://help.github.com/en/articles/about-github-actions) by configuring a YAML-based workflow file, e.g. `.github/workflows/release-drafter.yml`, with the following:
+You can use the [Release Drafter GitHub Action](https://github.com/marketplace/actions/release-drafter) in a [GitHub Actions Workflow](https://help.github.com/en/actions/about-github-actions) by configuring a YAML-based workflow file, e.g. `.github/workflows/release-drafter.yml`, with the following:
 
 ```yaml
 name: Release Drafter
@@ -45,7 +45,7 @@ jobs:
       #    echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
 
       # Drafts your next Release notes as Pull Requests are merged into "master"
-      - uses: release-drafter/release-drafter@v5
+      - uses: release-drafter/release-drafter@v6
         # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
         # with:
         #   config-name: my-config.yml
@@ -435,6 +435,5 @@ The command does the following:
 - Runs the `postversion` npm script in [package.json](package.json), which:
   - Runs test
   - Pushes the tag to GitHub, which triggers GitHub Action that does the following:
-    - Push GitHub app to Heroku
     - Releases NPM
     - Publish the Release Draft!
diff --git a/dist/index.js b/dist/index.js
index 96194ee..d1afe60 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -142984,7 +142984,9 @@ const findReleases = async ({
     ),
     tagPrefix
   )
-  const draftRelease = filteredReleases.find((r) => r.draft)
+  const draftRelease = filteredReleases.find(
+    (r) => r.draft && r.prerelease === includePreReleases
+  )
   const lastRelease = sortedSelectedReleases[sortedSelectedReleases.length - 1]
 
   if (draftRelease) {
diff --git a/lib/releases.js b/lib/releases.js
index 1f22d6e..fd89428 100644
--- a/lib/releases.js
+++ b/lib/releases.js
@@ -68,7 +68,9 @@ const findReleases = async ({
     ),
     tagPrefix
   )
-  const draftRelease = filteredReleases.find((r) => r.draft)
+  const draftRelease = filteredReleases.find(
+    (r) => r.draft && r.prerelease === includePreReleases
+  )
   const lastRelease = sortedSelectedReleases[sortedSelectedReleases.length - 1]
 
   if (draftRelease) {
diff --git a/package.json b/package.json
index 550ff0e..deee67c 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,6 @@
     "prettier": "prettier --write **/*.{js,md,json,yml}",
     "postversion": "npm run test && git push && git push --tags",
     "open-releases": "open \"$(node -e 'console.log(`${require(\"./package.json\").repository}/releases`)')\"",
-    "deploy": "git push -f heroku \"$(node -e 'console.log(`v${require(\"./package.json\").version}`)')\":master",
     "prepare": "husky install"
   },
   "dependencies": {


Test patch:
diff --git a/test/releases.test.js b/test/releases.test.js
index 67b329f..cbefadd 100644
--- a/test/releases.test.js
+++ b/test/releases.test.js
@@ -318,6 +318,7 @@ describe('releases', () => {
       const { draftRelease } = await findReleases({
         context,
         targetCommitish: 'refs/heads/master',
+        includePreReleases: false,
         tagPrefix: '',
       })
 
@@ -332,21 +333,27 @@ describe('releases', () => {
       paginateMock.mockResolvedValueOnce([
         { tag_name: 'v1.0.0', draft: true, prerelease: false },
         { tag_name: 'v1.0.1', draft: false, prerelease: false },
-        { tag_name: 'v1.0.2-rc.1', draft: false, prerelease: true },
+        { tag_name: 'v1.0.2-rc.1', draft: true, prerelease: true },
       ])
 
-      const { lastRelease } = await findReleases({
+      const { draftRelease, lastRelease } = await findReleases({
         context,
         targetCommitish: 'refs/heads/master',
         tagPrefix: '',
         includePreReleases: true,
       })
 
-      expect(lastRelease).toEqual({
+      expect(draftRelease).toEqual({
         tag_name: 'v1.0.2-rc.1',
-        draft: false,
+        draft: true,
         prerelease: true,
       })
+
+      expect(lastRelease).toEqual({
+        tag_name: 'v1.0.1',
+        draft: false,
+        prerelease: false,
+      })
     })
   })
 })