Explorar o código

support(slackbot-proxy): Bump slackbot proxy version independentry (#4385)

* support a new option "--update-dependencies" for bump-version

* add bump-versions.config.js for slackbot-proxy

* update release.yml

* update release-slackbot-proxy.yml
Yuki Takei %!s(int64=4) %!d(string=hai) anos
pai
achega
02abaedec6

+ 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: [
+      './',
+    ],
+  },
+};