Repository: release-drafter/release-drafter
Pull request #1016 (2022-01-16 18:03:43)

add automatic release of release-drafter


Patch:
diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
index 43f6fc8..8e176bd 100644
--- a/.github/release-drafter.yml
+++ b/.github/release-drafter.yml
@@ -4,6 +4,9 @@ template: |
   # What's Changed
 
   $CHANGES
+
+  **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
+
 categories:
   - title: 'Breaking'
     label: 'type: breaking'
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..fcb6eda
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,56 @@
+name: Release
+on:
+  push:
+    tags:
+      - v*.*.*
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Setup Node
+        uses: actions/setup-node@v2
+        with:
+          node-version: '16'
+          cache: yarn
+          registry-url: https://registry.npmjs.org
+
+      - name: yarn install
+        run: yarn install --frozen-lockfile
+
+      - name: yarn test
+        run: yarn test
+
+      - name: yarn publish
+        env:
+          NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
+        run: yarn publish --access public
+
+      - name: Deploy to Heroku
+        env:
+          HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }}
+          HEROKU_APP_NAME: release-drafter
+        run: git push https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git origin/master:master
+
+      - name: version
+        id: version
+        run: |
+          version=${{ github.event.release.tag_name }}
+          version=${version#v}
+          major=${version%%.*}
+          echo "::set-output name=version::${version}"
+          echo "::set-output name=major::${major}"
+
+      - uses: release-drafter/release-drafter@master
+        with:
+          version: '{{ steps.version.outputs.version }}'
+          publish: true
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: force update major tag
+        run: |
+          git tag v{{ steps.version.outputs.major }} ${{ github.event.release.tag_name }} -f
+          git push origin refs/tags/v{{ steps.version.outputs.major }} -f
diff --git a/Dockerfile b/Dockerfile
index 11e2ccc..7ee0d1b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,8 +1,8 @@
 FROM node:17.3.1-alpine@sha256:7ef8e673a9ea7b1dfaae292bf8faf549bb81ba60f68087454cef143698bdf2c4
 ARG NODE_ENV=production
 ENV NODE_ENV=${NODE_ENV}
-LABEL "repository"="https://github.com/toolmantim/release-drafter"
-LABEL "homepage"="https://github.com/toolmantim/release-drafter"
+LABEL "repository"="https://github.com/release-drafter/release-drafter"
+LABEL "homepage"="https://github.com/release-drafter/release-drafter"
 LABEL "maintainer"="Tim Lucas"
 LABEL "com.github.actions.name"="Release Drafter"
 LABEL "com.github.actions.description"="Drafts your next release notes as pull requests are merged into master."
diff --git a/README.md b/README.md
index 2d6c0c5..76b1151 100644
--- a/README.md
+++ b/README.md
@@ -141,6 +141,8 @@ You can use any of the following variables in your `template`:
 | `$CHANGES`      | The markdown list of pull requests that have been merged.                                                             |
 | `$CONTRIBUTORS` | A comma separated list of contributors to this release (pull request authors, commit authors, and commit committers). |
 | `$PREVIOUS_TAG` | The previous releases’s tag.                                                                                          |
+| `$REPOSITORY`   | Current Repository                                                                                                    |
+| `$OWNER`        | Current Repository Owner                                                                                              |
 
 ## Category Template Variables
 
diff --git a/dist/index.js b/dist/index.js
index 864605c..b77a392 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -132982,6 +132982,7 @@ module.exports = (app, { getRouter }) => {
     )
 
     const releaseInfo = generateReleaseInfo({
+      context,
       commits,
       config,
       lastRelease,
@@ -133655,6 +133656,7 @@ const resolveVersionKeyIncrement = (mergedPullRequests, config) => {
 }
 
 const generateReleaseInfo = ({
+  context,
   commits,
   config,
   lastRelease,
@@ -133666,6 +133668,8 @@ const generateReleaseInfo = ({
   shouldDraft,
   commitish,
 }) => {
+  const { owner, repo } = context.repo()
+
   let body = config.template
 
   body = template(
@@ -133678,6 +133682,8 @@ const generateReleaseInfo = ({
         pullRequests: mergedPullRequests,
         config,
       }),
+      $OWNER: owner,
+      $REPOSITORY: repo,
     },
     config.replacers
   )
diff --git a/index.js b/index.js
index 5dfe1d0..5740e89 100644
--- a/index.js
+++ b/index.js
@@ -178,6 +178,7 @@ module.exports = (app, { getRouter }) => {
     )
 
     const releaseInfo = generateReleaseInfo({
+      context,
       commits,
       config,
       lastRelease,
diff --git a/lib/releases.js b/lib/releases.js
index a129708..d251ac1 100644
--- a/lib/releases.js
+++ b/lib/releases.js
@@ -259,6 +259,7 @@ const resolveVersionKeyIncrement = (mergedPullRequests, config) => {
 }
 
 const generateReleaseInfo = ({
+  context,
   commits,
   config,
   lastRelease,
@@ -270,6 +271,8 @@ const generateReleaseInfo = ({
   shouldDraft,
   commitish,
 }) => {
+  const { owner, repo } = context.repo()
+
   let body = config.template
 
   body = template(
@@ -282,6 +285,8 @@ const generateReleaseInfo = ({
         pullRequests: mergedPullRequests,
         config,
       }),
+      $OWNER: owner,
+      $REPOSITORY: repo,
     },
     config.replacers
   )
diff --git a/package.json b/package.json
index 4112d33..f0983a9 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
   "description": "A GitHub app that draft releases based on pull-request labels",
   "author": "Tim Lucas <t@toolmantim.com> (https://github.com/toolmantim)",
   "license": "ISC",
-  "repository": "https://github.com/toolmantim/release-drafter",
+  "repository": "https://github.com/release-drafter/release-drafter",
   "scripts": {
     "build": "ncc build action.js --target es2021",
     "dev": "nodemon --exec \"npm start\"",
@@ -16,7 +16,7 @@
     "generate-fixtures": "node ./bin/generate-fixtures.js",
     "lint": "eslint bin/*.js lib/*.js action.js index.js test/**/*.js",
     "prettier": "prettier --write **/*.{js,md,json,yml,yaml}",
-    "postversion": "npm run test && git push && git push --tags && npm publish && npm run deploy && npm run open-releases",
+    "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"


Test patch:
diff --git a/test/fixtures/config/config-with-compare-link.yml b/test/fixtures/config/config-with-compare-link.yml
new file mode 100644
index 0000000..f726960
--- /dev/null
+++ b/test/fixtures/config/config-with-compare-link.yml
@@ -0,0 +1,12 @@
+template: |
+  # What's Changed
+
+  $CHANGES
+
+  **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
+
+categories:
+  - label: feature
+    title: 🚀 Features
+  - label: fix
+    title: 🐛 Bug Fixes
diff --git a/test/index.test.js b/test/index.test.js
index 1f046dd..1067936 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -861,6 +861,64 @@ describe('release-drafter', () => {
       })
     })
 
+    describe('with owner and repository templating', () => {
+      it('include full-changelog link in output', async () => {
+        getConfigMock('config-with-compare-link.yml')
+
+        nock('https://api.github.com')
+          .get('/repos/toolmantim/release-drafter-test-project/releases')
+          .query(true)
+          .reply(200, [releasePayload])
+
+        nock('https://api.github.com')
+          .post('/graphql', (body) =>
+            body.query.includes('query findCommitsWithAssociatedPullRequests')
+          )
+          .reply(200, graphqlCommitsMergeCommit)
+
+        nock('https://api.github.com')
+          .post(
+            '/repos/toolmantim/release-drafter-test-project/releases',
+            (body) => {
+              expect(body).toMatchInlineSnapshot(`
+                Object {
+                  "body": "# What's Changed
+
+                * Add documentation (#5) @TimonVS
+                * Update dependencies (#4) @TimonVS
+
+                ## 🚀 Features
+
+                * Add big feature (#2) @TimonVS
+                * 👽 Add alien technology (#1) @TimonVS
+
+                ## 🐛 Bug Fixes
+
+                * Bug fixes (#3) @TimonVS
+
+                **Full Changelog**: https://github.com/toolmantim/release-drafter-test-project/compare/v2.0.0...v2.0.1
+                ",
+                  "draft": true,
+                  "name": "",
+                  "prerelease": false,
+                  "tag_name": "",
+                  "target_commitish": "",
+                }
+              `)
+              return true
+            }
+          )
+          .reply(200, releasePayload)
+
+        await probot.receive({
+          name: 'push',
+          payload: pushPayload,
+        })
+
+        expect.assertions(1)
+      })
+    })
+
     describe('with categories config', () => {
       it('categorizes pull requests with single label', async () => {
         getConfigMock('config-with-categories.yml')