Jelajahi Sumber

Merge pull request #4386 from weseek/master

Release slackbot-proxy v4.4.6-slackbot-proxy.0
Yuki Takei 4 tahun lalu
induk
melakukan
23f16f9c6f

+ 2 - 5
.github/workflows/ci-slackbot-proxy.yml

@@ -94,6 +94,7 @@ jobs:
         cp config/ci/.env.local.for-ci .env.development.local
         yarn dev:ci
       env:
+        SERVER_URI: http://localhost:8080
         TYPEORM_CONNECTION: mysql
         TYPEORM_HOST: localhost
         TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
@@ -167,17 +168,13 @@ jobs:
         cp config/ci/.env.local.for-ci .env.production.local
         yarn start:prod:ci
       env:
+        SERVER_URI: http://localhost:8080
         TYPEORM_CONNECTION: mysql
         TYPEORM_HOST: localhost
         TYPEORM_PORT: ${{ job.services.mysql.ports[3306] }}
         TYPEORM_DATABASE: growi-slackbot-proxy
         TYPEORM_USERNAME: root
         TYPEORM_PASSWORD:
-    - name: Upload report as artifact
-      uses: actions/upload-artifact@v2
-      with:
-        name: Report
-        path: report
 
     - name: Slack Notification
       uses: weseek/ghaction-slack-notification@master

+ 58 - 0
.github/workflows/release-slackbot-proxy.yml

@@ -19,6 +19,8 @@ jobs:
     - name: Retrieve information from package.json
       uses: myrotvorets/info-from-package-json-action@1.1.0
       id: package-json
+      with:
+        workingDir: packages/slackbot-proxy
 
     - name: Docker meta
       id: meta
@@ -78,6 +80,13 @@ jobs:
         rm -rf /tmp/.buildx-cache
         mv /tmp/.buildx-cache-new /tmp/.buildx-cache
 
+    - name: Add tag
+      uses: anothrNick/github-tag-action@1.36.0
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        CUSTOM_TAG: v${{ steps.package-json.outputs.packageVersion }}
+        VERBOSE : true
+
     - name: Update Docker Hub Description
       uses: peter-evans/dockerhub-description@v2
       with:
@@ -85,3 +94,52 @@ jobs:
         password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
         repository: weseek/growi-slackbot-proxy
         readme-filepath: ./packages/slackbot-proxy/docker/README.md
+
+
+  create-pr-for-next-rc:
+    needs: build-and-push-image
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+      with:
+        ref: ${{ github.event.pull_request.base.ref }}
+
+    - uses: actions/setup-node@v2
+      with:
+        node-version: '14'
+        cache: 'yarn'
+        cache-dependency-path: '**/yarn.lock'
+
+    - name: Install dependencies
+      run: |
+        npx lerna bootstrap
+
+    - name: Bump versions for next RC
+      run: |
+        node ./bin/github-actions/bump-versions -i prerelease -d packages/slackbot-proxy --preid slackbot-proxy --update-dependencies false
+
+    - name: Retrieve information from package.json
+      uses: myrotvorets/info-from-package-json-action@1.1.0
+      id: package-json
+      with:
+        workingDir: packages/slackbot
+
+    - name: Commit
+      uses: github-actions-x/commit@v2.8
+      with:
+        github-token: ${{ secrets.GITHUB_TOKEN }}
+        push-branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
+        commit-message: 'Bump version'
+        name: GitHub Action
+
+    - name: Create PR
+      uses: repo-sync/pull-request@v2
+      with:
+        source_branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
+        destination_branch: master
+        pr_title: Prepare v${{ steps.package-json.outputs.packageVersion }}
+        pr_label: exclude from changelog
+        pr_body: "An automated PR generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
+        github_token: ${{ secrets.GITHUB_TOKEN }}

+ 1 - 0
.github/workflows/release.yml

@@ -96,6 +96,7 @@ jobs:
     - name: Bump versions for next RC
       run: |
         node ./bin/github-actions/bump-versions -i prerelease
+        node ./bin/github-actions/bump-versions -i prerelease -d packages/slackbot-proxy --preid slackbot-proxy --update-dependencies false
 
     - name: Retrieve information from package.json
       uses: myrotvorets/info-from-package-json-action@1.1.0

+ 7 - 1
bin/github-actions/bump-versions/flow/bump-versions.js

@@ -13,6 +13,7 @@ async function bumpVersions({
   help = false,
   dir = '.',
   dryRun = false,
+  updateDependencies = true,
   increment = 'patch',
   preid = 'RC',
 }) {
@@ -26,8 +27,12 @@ async function bumpVersions({
 
   const config = await loadConfig(dir, 'bump-versions.config');
 
-  // get current version
   const { monorepo } = config;
+  if (!updateDependencies) {
+    monorepo.updateDependencies = false;
+  }
+
+  // get current version
   const currentVersion = monorepo && monorepo.mainVersionFile
     ? getCurrentVersion(dir, monorepo.mainVersionFile)
     : getCurrentVersion(dir);
@@ -55,6 +60,7 @@ const arg = {
   '--dir': String,
   '--help': Boolean,
   '--dry-run': Boolean,
+  '--update-dependencies': Boolean,
   '--increment': String,
   '--preid': String,
 

+ 5 - 1
bin/github-actions/bump-versions/step/printHelp.js

@@ -9,8 +9,9 @@ export default () => runStep({}, () => {
   const dir = `--dir ${underline('PATH')}`;
   const increment = `--increment ${underline('LEVEL')}`;
   const preId = `--preid ${underline('IDENTIFIER')}`;
+  const updateDependencies = `--update-dependencies ${underline('true/false')}`;
   const dryRun = '--dry-run';
-  const all = [help, dir, increment, preId, dryRun]
+  const all = [help, dir, increment, preId, updateDependencies, dryRun]
     .map(x => `[${x}]`)
     .join(' ');
 
@@ -46,6 +47,9 @@ export default () => runStep({}, () => {
       )} for semver.inc() with 'prerelease' type (default: 'RC').`,
     ),
     '',
+    indent(`${updateDependencies}`),
+    indent('  Update dependencies or not (default: true).'),
+    '',
     indent(`-D, ${dryRun}`),
     indent('  Displays the steps without actually doing them.'),
     '',

+ 11 - 0
packages/slackbot-proxy/bump-versions.config.js

@@ -0,0 +1,11 @@
+/*
+ * Reference: https://community.algolia.com/shipjs/
+ */
+module.exports = {
+  monorepo: {
+    mainVersionFile: 'package.json',
+    packagesToBump: [
+      './',
+    ],
+  },
+};

+ 5 - 2
packages/slackbot-proxy/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@growi/slackbot-proxy",
-  "version": "4.4.6-RC.0",
+  "version": "4.4.6-slackbot-proxy.0",
   "license": "MIT",
   "scripts": {
     "build": "yarn tsc && tsc-alias -p tsconfig.build.json",
@@ -20,7 +20,9 @@
     "lint": "eslint src --ext .ts",
     "lint:fix": "eslint src --ext .ts --fix"
   },
-  "// comments for dependencies": {},
+  "// comments for dependencies": {
+    "read-pkg-up": "v8 doesn't support CommonJS anymore. https://github.com/sindresorhus/read-pkg-up/issues/17"
+  },
   "dependencies": {
     "@godaddy/terminus": "^4.8.0",
     "@growi/slack": "^4.4.6-RC.0",
@@ -43,6 +45,7 @@
     "http-errors": "^1.8.0",
     "method-override": "^3.0.0",
     "mysql2": "^2.2.5",
+    "read-pkg-up": "^7.0.1",
     "typeorm": "^0.2.31",
     "universal-bunyan": "^0.9.2"
   },

+ 4 - 2
packages/slackbot-proxy/src/controllers/top.ts

@@ -2,6 +2,8 @@ import {
   Controller, Get, Inject, View,
 } from '@tsed/common';
 
+import readPkgUp from 'read-pkg-up';
+
 import { requiredScopes } from '@growi/slack';
 import { InstallerService } from '~/services/InstallerService';
 
@@ -22,8 +24,8 @@ export class TopCtrl {
     });
 
     // use await import in order to avoid typescript-eslint error
-    const fs = await import('fs');
-    const growiBotVersion = JSON.parse(fs.readFileSync('../../package.json', 'utf8')).version;
+    const readPkgUpResult = await readPkgUp();
+    const growiBotVersion = readPkgUpResult?.packageJson.version;
 
     return { url, isOfficialMode, growiBotVersion };
   }

+ 1 - 0
packages/slackbot-proxy/src/index.ts

@@ -22,6 +22,7 @@ async function bootstrap() {
   }
   catch (er) {
     $log.error(er);
+    process.exit(1);
   }
 }