From 0a00c2f8873d2129e59e45410e2c723f1839e140 Mon Sep 17 00:00:00 2001 From: itanka9 Date: Fri, 22 May 2026 21:21:08 +0300 Subject: [PATCH 1/6] release workflow --- .github/workflows/release.yml | 72 ++++++++++++++++++++++++++++++++ scripts/update-loader-version.js | 21 ++++++++++ 2 files changed, 93 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 scripts/update-loader-version.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..819f2605 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: Release Preparation + +on: + workflow_dispatch: + inputs: + version_type: + description: 'Version type' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + # 1. Клонируем репозиторий + - name: Checkout code + uses: actions/checkout@v5 + with: + # Remove this before merge, it's for testing purposes only + ref: automate-release + fetch-depth: 0 + + # 2. Настраиваем Node.js + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: '12' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Bump version + run: | + npm version ${{ github.event.inputs.version_type }} --no-git-tag-version + + - name: Update loader.js + run: node scripts/update-loader-version.js + + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + commit-message: Release ${{ steps.version.outputs.version }} + title: Release ${{ steps.version.outputs.version }} + branch: release-${{ steps.version.outputs.version }} + base: master + body: | + ## Release ${{ steps.version.outputs.version }} + + **Что изменилось:** + - Обновлен `package.json` + - Обновлен `app/loader.js` + - Обновлен `package-lock.json` + + **Проверка:** + - [ ] Локальный запуск (`npm run start`) + - [ ] Проверка на staging (после мержа) + + Closes #issue_number # (если есть) + labels: | + release + automated-pr \ No newline at end of file diff --git a/scripts/update-loader-version.js b/scripts/update-loader-version.js new file mode 100644 index 00000000..becc17cc --- /dev/null +++ b/scripts/update-loader-version.js @@ -0,0 +1,21 @@ +const fs = require('fs'); +const path = require('path'); + +// Читаем новую версию из package.json (который мы только что обновили) +const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); +const newVersion = pkg.version; + +const loaderPath = path.join(__dirname, '../app/loader.js'); + +let content = fs.readFileSync(loaderPath, 'utf8'); + +const regex = /const version = '.*?'/; + +if (regex.test(content)) { + content = content.replace(regex, `const version = '${newVersion}'`); + fs.writeFileSync(loaderPath, content); + console.log(`✅ Версия в loader.js обновлена на ${newVersion}`); +} else { + console.error('❌ Не удалось найти версию в app/loader.js. Проверьте регулярное выражение в скрипте.'); + process.exit(1); +} \ No newline at end of file From c81517389e5c0455e37d66d1e8ae8889c523ea9f Mon Sep 17 00:00:00 2001 From: itanka9 Date: Fri, 22 May 2026 21:28:56 +0300 Subject: [PATCH 2/6] rm debug --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 819f2605..ee73fab2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,8 +25,6 @@ jobs: - name: Checkout code uses: actions/checkout@v5 with: - # Remove this before merge, it's for testing purposes only - ref: automate-release fetch-depth: 0 # 2. Настраиваем Node.js From ce4db6da36de7d1c114ea1d04c0a13726fd3fc0c Mon Sep 17 00:00:00 2001 From: itanka9 Date: Fri, 22 May 2026 21:34:30 +0300 Subject: [PATCH 3/6] f --- scripts/update-loader-version.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/update-loader-version.js b/scripts/update-loader-version.js index becc17cc..b52d718e 100644 --- a/scripts/update-loader-version.js +++ b/scripts/update-loader-version.js @@ -9,12 +9,12 @@ const loaderPath = path.join(__dirname, '../app/loader.js'); let content = fs.readFileSync(loaderPath, 'utf8'); -const regex = /const version = '.*?'/; +const regex = /var version = '.*?'/; if (regex.test(content)) { - content = content.replace(regex, `const version = '${newVersion}'`); + content = content.replace(regex, `var version = 'v${newVersion}'`); fs.writeFileSync(loaderPath, content); - console.log(`✅ Версия в loader.js обновлена на ${newVersion}`); + console.log(`✅ Версия в loader.js обновлена на v${newVersion}`); } else { console.error('❌ Не удалось найти версию в app/loader.js. Проверьте регулярное выражение в скрипте.'); process.exit(1); From b89c943fc717eb3fdc65ed507e6acda817698ec9 Mon Sep 17 00:00:00 2001 From: itanka9 Date: Fri, 22 May 2026 21:56:48 +0300 Subject: [PATCH 4/6] fix version, preview demo --- .github/workflows/preview.yml | 53 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 12 ++++---- 2 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 00000000..0d5857e9 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,53 @@ +name: Preview Deployment + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + +jobs: + preview: + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: '12' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v2 + with: + path: './dist' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 + + - name: Add PR comment with preview link + if: github.event.action != 'closed' + uses: peter-evans/create-or-update-comment@v3 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + [демка](${{ steps.deployment.outputs.page_url }}) + reactions: rocket + + - name: Clean up preview + if: github.event.action == 'closed' + run: | + echo "Превью для PR #${{ github.event.pull_request.number }} будет удалено" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee73fab2..64f0f4fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release Preparation +name: Release on: workflow_dispatch: @@ -38,8 +38,10 @@ jobs: run: npm ci - name: Bump version + id: bump run: | npm version ${{ github.event.inputs.version_type }} --no-git-tag-version + echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - name: Update loader.js run: node scripts/update-loader-version.js @@ -48,12 +50,12 @@ jobs: id: cpr uses: peter-evans/create-pull-request@v5 with: - commit-message: Release ${{ steps.version.outputs.version }} - title: Release ${{ steps.version.outputs.version }} - branch: release-${{ steps.version.outputs.version }} + commit-message: Release ${{ steps.bump.outputs.version }} + title: Release ${{ steps.bump.outputs.version }} + branch: release-${{ steps.bump.outputs.version }} base: master body: | - ## Release ${{ steps.version.outputs.version }} + ## Release ${{ steps.bump.outputs.version }} **Что изменилось:** - Обновлен `package.json` From 65362670ba35fae6cc6e0dbeeeb528bcffbe8944 Mon Sep 17 00:00:00 2001 From: itanka9 Date: Fri, 22 May 2026 22:06:51 +0300 Subject: [PATCH 5/6] f --- .github/workflows/preview.yml | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 0d5857e9..d0d63d3b 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -29,25 +29,8 @@ jobs: - name: Build project run: npm run build - - name: Upload Pages artifact - uses: actions/upload-pages-artifact@v2 + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 with: - path: './dist' - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 - - - name: Add PR comment with preview link - if: github.event.action != 'closed' - uses: peter-evans/create-or-update-comment@v3 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - [демка](${{ steps.deployment.outputs.page_url }}) - reactions: rocket - - - name: Clean up preview - if: github.event.action == 'closed' - run: | - echo "Превью для PR #${{ github.event.pull_request.number }} будет удалено" + source-dir: ./dist/ + preview-branch: gh-pages \ No newline at end of file From 49a8d254f0d30152dd71c7807a141ec57b5ec0f2 Mon Sep 17 00:00:00 2001 From: itanka9 Date: Fri, 22 May 2026 22:29:39 +0300 Subject: [PATCH 6/6] rm preview --- .github/workflows/preview.yml | 36 ----------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index d0d63d3b..00000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Preview Deployment - -on: - pull_request: - types: [opened, synchronize, reopened, closed] - -jobs: - preview: - runs-on: ubuntu-latest - permissions: - contents: read - pages: write - id-token: write - pull-requests: write - - steps: - - name: Checkout code - uses: actions/checkout@v5 - - - name: Setup Node.js - uses: actions/setup-node@v6 - with: - node-version: '12' - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Build project - run: npm run build - - - name: Deploy preview - uses: rossjrw/pr-preview-action@v1 - with: - source-dir: ./dist/ - preview-branch: gh-pages \ No newline at end of file