diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d8189b8bd..822041feb 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -71,102 +71,19 @@ jobs: curl --connect-timeout 10 --max-time 20 --retry 5 --retry-delay 10 --retry-max-time 60 --retry-connrefused http://127.0.0.1:9001/p/test pnpm exec playwright install chromium --with-deps pnpm run test-ui --project=chromium - - build-exe: - if: | - (github.event_name != 'pull_request') - || (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id) - name: Build .exe - needs: build-zip - runs-on: windows-latest - steps: - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Download .zip - uses: actions/download-artifact@v4 - with: - name: etherpad-win.zip - path: .. - - - name: Extract .zip - working-directory: .. - run: 7z x etherpad-win.zip -oetherpad-zip - - - name: Create installer - uses: joncloud/makensis-action@v4.1 - with: - script-file: 'bin/nsis/etherpad.nsi' - - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - with: - name: etherpad-win.exe - path: etherpad-win.exe - - deploy-zip: - # run on pushes to any branch - # run on PRs from external forks - permissions: - contents: write - if: | - (github.event_name != 'pull_request') - || (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id) - name: Deploy - needs: build-zip - runs-on: windows-latest - steps: - - - name: Download zip - uses: actions/download-artifact@v4 - with: - name: etherpad-win.zip - - - name: Extract Etherpad - run: 7z x etherpad-win.zip -oetherpad - - - uses: actions/setup-node@v4 - with: - node-version: 20 - - uses: pnpm/action-setup@v4 - name: Install pnpm - with: - version: 9.0.4 - run_install: false - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Only install direct dependencies - run: pnpm config set auto-install-peers false - - name: Install all dependencies and symlink for ep_etherpad-lite - run: .\bin\installOnWindows.bat - working-directory: etherpad - - - name: Run Frontend Tests - working-directory: etherpad/src - run: | - pnpm i - pnpm exec playwright install --with-deps - pnpm run prod & - curl --connect-timeout 10 --max-time 20 --retry 5 --retry-delay 10 --retry-max-time 60 --retry-connrefused http://127.0.0.1:9001/p/test - pnpm exec playwright install chromium --with-deps - pnpm run test-ui --project=chromium - # On release, upload windows zip to GitHub release tab + # On release, create release - name: Rename to etherpad-lite-win.zip shell: powershell run: mv etherpad-win.zip etherpad-lite-win.zip + - name: Generate Changelog + if: ${{startsWith(github.ref, 'refs/tags/v') }} + working-directory: bin + run: pnpm run generateChangelog ${{github.ref}} > ${{ github.workspace }}-CHANGELOG.txt + with: + tag: ${{ github.ref }} - name: Release next version uses: marvinpinto/action-automatic-releases@latest if: ${{startsWith(github.ref, 'refs/tags/v') }} with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" + body_path: ${{ github.workspace }}-CHANGELOG.txt diff --git a/bin/generateReleaseNotes.ts b/bin/generateReleaseNotes.ts new file mode 100644 index 000000000..132853cd6 --- /dev/null +++ b/bin/generateReleaseNotes.ts @@ -0,0 +1,41 @@ +import {readFileSync} from "node:fs"; + +const changelog = readFileSync('../changelog.md') +const changelogText = changelog.toString() +const changelogLines = changelogText.split('\n') + + +let cliArgs = process.argv.slice(2) + +let tagVar = cliArgs[0] + +if (!tagVar) { + console.error("No tag provided") + process.exit(1) +} + +console.log("Tag",tagVar) + +tagVar = tagVar.replace("refs/tags/v", "") + +let startNum = -1 +let endline = 0 + +let counter = 0 +for (const line of changelogLines) { + if (line.trim().startsWith("#") && (line.match(new RegExp("#", "g"))||[]).length === 1) { + if (startNum !== -1) { + endline = counter-1 + break + } + + const sanitizedLine = line.replace("#","").trim() + if(sanitizedLine.includes(tagVar)) { + startNum = counter + } + } + counter++ +} + +let currentReleaseNotes = changelogLines.slice(startNum, endline).join('\n') +console.log("Generated changelog",currentReleaseNotes) diff --git a/bin/package.json b/bin/package.json index 051e27589..cd411393e 100644 --- a/bin/package.json +++ b/bin/package.json @@ -32,7 +32,8 @@ "rebuildPad": "node --import tsx rebuildPad.ts", "stalePlugins": "node --import tsx ./plugins/stalePlugins.ts", "checkPlugin": "node --import tsx ./plugins/checkPlugin.ts", - "plugins": "node --import tsx ./plugins.ts" + "plugins": "node --import tsx ./plugins.ts", + "generateChangelog": "node --import tsx generateReleaseNotes.ts" }, "author": "", "license": "ISC"