From 39a55eee30a2e0c6459643ee296ff15bd689760a Mon Sep 17 00:00:00 2001 From: Andy Zhang <37402126+AnzhiZhang@users.noreply.github.com> Date: Fri, 2 Feb 2024 21:14:47 +0000 Subject: [PATCH] =?UTF-8?q?build:=20=F0=9F=91=B7=20upgrade=20release-pleas?= =?UTF-8?q?e-action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 93 +++++++------------ .release-please/.release-please-manifest.json | 18 ++++ .release-please/release-please-config.json | 62 +++++++++++++ changeFinder.js | 38 -------- plugin_list.json | 18 ---- 5 files changed, 112 insertions(+), 117 deletions(-) create mode 100644 .release-please/.release-please-manifest.json create mode 100644 .release-please/release-please-config.json delete mode 100644 changeFinder.js delete mode 100644 plugin_list.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7fb59eb..126e857 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,100 +1,71 @@ -name: Release Please +name: Release on: push: branches: - master jobs: - change-finder: + release-please: runs-on: ubuntu-latest - name: Change Finder + name: Release Please outputs: - changed: ${{ steps.find.outputs.changed }} - plugins: ${{ steps.find.outputs.plugins }} + releases_created: ${{ steps.release-please.outputs.releases_created }} + tag_name: ${{ steps.release-please.outputs[format('{0}--tag_name', steps.set-outputs.outputs.path)] }} + path: ${{ steps.set-outputs.outputs.path }} steps: - - name: Check Out - uses: actions/checkout@v3 + - name: Release Please + uses: google-github-actions/release-please-action@v4 + id: release-please with: - fetch-depth: 0 + token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }} + config-file: .release-please/release-please-config.json + manifest-file: .release-please/.release-please-manifest.json - - name: Find - id: find + - name: Set Outputs + id: set-outputs run: | - npm i @actions/core - node changeFinder.js - - release-please-pr: - runs-on: ubuntu-latest - name: Release Please PR - needs: - - change-finder - - release-please-release - strategy: - fail-fast: false - matrix: - plugin: ${{ fromJson(needs.change-finder.outputs.plugins) }} + echo "path=${{ fromJson(steps.release-please.outputs.paths_released)[0] }}" >> $GITHUB_OUTPUT + echo "${{ fromJson(steps.release-please.outputs.paths_released)[0] }}" - steps: - - name: Release Please PR - uses: google-github-actions/release-please-action@v3 - with: - release-type: simple - package-name: ${{ matrix.plugin }} - path: ${{ matrix.plugin }} - monorepo-tags: true - command: release-pr - pull-request-title-pattern: 'chore${scope}: 🔖 release${component} ${version}' + - if: ${{ steps.release-please.outputs.releases_created == 'true' }} + run: | + echo "${{ steps.set-outputs.outputs.path }}" - release-please-release: + build: runs-on: ubuntu-latest - name: Release Please Release - needs: change-finder - if: ${{ needs.change-finder.outputs.changed == 'true' }} - strategy: - fail-fast: false - matrix: - plugin: ${{ fromJson(needs.change-finder.outputs.plugins) }} + name: Build + needs: release-please + if: ${{ needs.release-please.outputs.releases_created == 'true' }} steps: - - name: Release Please Release - uses: google-github-actions/release-please-action@v3 - id: release_please_release - with: - release-type: simple - package-name: ${{ matrix.plugin }} - path: ${{ matrix.plugin }} - monorepo-tags: true - command: github-release - pull-request-title-pattern: 'chore${scope}: 🔖 release${component} ${version}' + - run: | + echo "${{ needs.release-please.outputs.releases_created }}" + echo "${{ needs.release-please.outputs.tag_name }}" + echo "${{ needs.release-please.outputs.path }}" - name: Check Out - uses: actions/checkout@v3 - if: ${{ steps.release_please_release.outputs[format('{0}--release_created', matrix.plugin)] }} + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 - if: ${{ steps.release_please_release.outputs[format('{0}--release_created', matrix.plugin)] }} + uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.12' - name: Install Dependencies - if: ${{ steps.release_please_release.outputs[format('{0}--release_created', matrix.plugin)] }} run: | python -m pip install --upgrade pip pip install mcdreforged - name: Pack id: pack - if: ${{ steps.release_please_release.outputs[format('{0}--release_created', matrix.plugin)] }} run: | - python -m mcdreforged pack --ignore-patterns __pycache__ -i ${{ matrix.plugin }} + mcdreforged pack --ignore-patterns __pycache__ -i ${{ needs.release-please.outputs.path }} echo "name=$(ls *.mcdr)" >> $GITHUB_OUTPUT - name: Upload - if: ${{ steps.release_please_release.outputs[format('{0}--release_created', matrix.plugin)] }} env: GH_TOKEN: ${{ github.token }} run: | - gh release upload ${{ steps.release_please_release.outputs[format('{0}--tag_name', matrix.plugin)] }} ${{ steps.pack.outputs.name }} + gh release upload ${{ needs.release-please.outputs.tag_name }} ${{ steps.pack.outputs.name }} diff --git a/.release-please/.release-please-manifest.json b/.release-please/.release-please-manifest.json new file mode 100644 index 0000000..bb96e6c --- /dev/null +++ b/.release-please/.release-please-manifest.json @@ -0,0 +1,18 @@ +{ + "src/advanced_calculator": "0.3.1", + "src/bingo": "0.0.3", + "src/bot": "1.1.2", + "src/database_api": "0.1.1", + "src/dict_command_registration": "1.1.0", + "src/fastapi_mcdr": "1.0.0", + "src/gamemode": "1.1.0", + "src/info": "0.2.0", + "src/let_me_click_and_send": "1.0.0", + "src/lowercase_mcdr_command": "1.2.2", + "src/minecraft_command_register": "1.7.3", + "src/more_command_nodes": "1.1.0", + "src/online_player_api": "1.0.0", + "src/qq_api": "1.3.1", + "src/qq_chat": "2.1.0", + "src/uuid_api": "0.1.2" +} diff --git a/.release-please/release-please-config.json b/.release-please/release-please-config.json new file mode 100644 index 0000000..fc24b72 --- /dev/null +++ b/.release-please/release-please-config.json @@ -0,0 +1,62 @@ +{ + "release-type": "simple", + "pull-request-title-pattern": "chore${scope}: 🔖 release${component} ${version}", + "extra-files": [ + { + "type": "json", + "path": "mcdreforged.plugin.json", + "jsonpath": "$.version" + } + ], + "separate-pull-requests": true, + "packages": { + "src/advanced_calculator": { + "package-name": "advanced_calculator" + }, + "src/bingo": { + "package-name": "bingo" + }, + "src/bot": { + "package-name": "bot" + }, + "src/database_api": { + "package-name": "database_api" + }, + "src/dict_command_registration": { + "package-name": "dict_command_registration" + }, + "src/fastapi_mcdr": { + "package-name": "fastapi_mcdr" + }, + "src/gamemode": { + "package-name": "gamemode" + }, + "src/info": { + "package-name": "info" + }, + "src/let_me_click_and_send": { + "package-name": "let_me_click_and_send" + }, + "src/lowercase_mcdr_command": { + "package-name": "lowercase_mcdr_command" + }, + "src/minecraft_command_register": { + "package-name": "minecraft_command_register" + }, + "src/more_command_nodes": { + "package-name": "more_command_nodes" + }, + "src/online_player_api": { + "package-name": "online_player_api" + }, + "src/qq_api": { + "package-name": "qq_api" + }, + "src/qq_chat": { + "package-name": "qq_chat" + }, + "src/uuid_api": { + "package-name": "uuid_api" + } + } +} diff --git a/changeFinder.js b/changeFinder.js deleted file mode 100644 index cf4768b..0000000 --- a/changeFinder.js +++ /dev/null @@ -1,38 +0,0 @@ -const core = require('@actions/core'); -const execSync = require('child_process').execSync; -const pluginList = require('./plugin_list.json'); -const tagList = execSync('git tag', {encoding: 'utf-8'}).trim().split('\n').reverse(); - -function isAffectReleaseLog(log) { - return log.includes('fix') || log.includes('feat') || log.includes('!') || log.includes('Release-As: '); -} - -let changedList = []; -for (let pluginKey in pluginList) { - let pluginID = pluginList[pluginKey]; - let findTagFlag = false; - for (let tagKey in tagList) { - let tagName = tagList[tagKey]; - if (tagName.startsWith(pluginID)) { - let gitLog = execSync(`git log ${tagName}...HEAD ${pluginID}`, {encoding: 'utf-8'}); - if (isAffectReleaseLog(gitLog)) { - changedList.push(pluginID); - } - findTagFlag = true; - break; - } - } - if (!findTagFlag) { - let gitLog = execSync(`git log ${pluginID}`, {encoding: 'utf-8'}); - if (isAffectReleaseLog(gitLog)) { - changedList.push(pluginID); - } - } -} - -function isAffectReleaseLog(log) { - return log.includes('fix') || log.includes('feat') || log.includes('!') || log.includes('Release-As: '); -} - -core.setOutput('changed', changedList.length > 0); -core.setOutput('plugins', JSON.stringify(changedList)); diff --git a/plugin_list.json b/plugin_list.json deleted file mode 100644 index 82b61ca..0000000 --- a/plugin_list.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - "advanced_calculator", - "bingo", - "bot", - "database_api", - "dict_command_registration", - "fastapi_mcdr", - "gamemode", - "info", - "let_me_click_and_send", - "lowercase_mcdr_command", - "minecraft_command_register", - "more_command_nodes", - "online_player_api", - "qq_api", - "qq_chat", - "uuid_api" -]