From 719d90bfdde2588e0500da510851e153d50b6756 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:02:07 -0400 Subject: [PATCH] Rework Actions --- .github/workflows/build.yml | 31 ++---- .github/workflows/codeberg-mirror.yml | 34 +++--- .github/workflows/reportBrokenPlugins.yml | 104 +++++++++--------- .github/workflows/syncDev.yml | 36 +++--- .github/workflows/syncMain.yml | 36 +++--- .github/workflows/test.yml | 96 ++++++++-------- .github/workflows/uploadBuilds.yml | 94 ++++++++++++++++ .github/workflows/uploadPlugins.yml | 46 ++++++++ scripts/generatePluginList.ts | 13 +-- .../PluginSettings/ContributorModal.tsx | 2 +- src/plugins/userMessagesPronouns/README.md | 5 - 11 files changed, 308 insertions(+), 189 deletions(-) create mode 100644 .github/workflows/uploadBuilds.yml create mode 100644 .github/workflows/uploadPlugins.yml delete mode 100644 src/plugins/userMessagesPronouns/README.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dba126dd..5dd6bdbe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,8 @@ env: FORCE_COLOR: true GITHUB_TOKEN: ${{ secrets.ETOKEN }} +permissions: write-all + jobs: Build: name: Build Equicord @@ -16,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v3 # Install pnpm using packageManager key in package.json + - uses: pnpm/action-setup@v3 - name: Use Node.js 20 uses: actions/setup-node@v4 @@ -34,7 +36,7 @@ jobs: run: pnpm buildStandalone - name: Generate plugin list - run: pnpm generatePluginJson dist/plugins.json dist/plugin-readmes.json + run: pnpm generatePluginJson dist/vencordplugins.json - name: Generate Equicord plugin list run: pnpm generateEquicordPluginJson dist/equicordplugins.json @@ -69,26 +71,15 @@ jobs: - name: Upload Equicord Stable if: ${{ github.ref_name == 'main' }} run: | - gh release upload latest --clobber dist/release/* + gh release upload latest --clobber dist/release/* - name: Upload Equicord Dev if: ${{ github.ref_name == 'dev' }} run: | - gh release upload devbuild --clobber dist/release/* + gh release upload devbuild --clobber dist/release/* - - name: Upload Plugins JSON to Equibored repo - if: ${{ github.ref_name == 'main' }} - run: | - git config --global user.name "$USERNAME" - git config --global user.email "78185467+thororen1234@users.noreply.github.com" - git clone https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git upload - cd upload - rm plugins.json - cp -r ../dist/equicordplugins.json plugins.json - git add -A - git commit -m "Plugins for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" - git push --force https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git - env: - API_TOKEN: ${{ secrets.ETOKEN }} - GH_REPO: Equicord/Equibored - USERNAME: thororen1234 + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: "build" + path: "dist/release/*" diff --git a/.github/workflows/codeberg-mirror.yml b/.github/workflows/codeberg-mirror.yml index 9bbb434d..cbfef07a 100644 --- a/.github/workflows/codeberg-mirror.yml +++ b/.github/workflows/codeberg-mirror.yml @@ -1,22 +1,22 @@ name: Sync to Codeberg concurrency: - group: ${{ github.ref }} - cancel-in-progress: true + group: ${{ github.ref }} + cancel-in-progress: true on: - push: - workflow_dispatch: - schedule: - - cron: "0 */6 * * *" + push: + workflow_dispatch: + schedule: + - cron: "0 */6 * * *" jobs: - codeberg: - name: Sync Codeberg and Github - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1 - with: - target_repo_url: "git@codeberg.org:thororen/Equicord.git" - ssh_private_key: ${{ secrets.CODEBERG }} + codeberg: + name: Sync Codeberg and Github + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1 + with: + target_repo_url: "git@codeberg.org:thororen/Equicord.git" + ssh_private_key: ${{ secrets.CODEBERG }} diff --git a/.github/workflows/reportBrokenPlugins.yml b/.github/workflows/reportBrokenPlugins.yml index c396c3e9..0abfee5b 100644 --- a/.github/workflows/reportBrokenPlugins.yml +++ b/.github/workflows/reportBrokenPlugins.yml @@ -1,67 +1,67 @@ name: Test Patches on: - workflow_dispatch: - schedule: - # Every day at midnight - - cron: 0 0 * * * + workflow_dispatch: + schedule: + # Every day at midnight + - cron: 0 0 * * * jobs: - TestPlugins: - name: Test Patches - runs-on: ubuntu-latest + TestPlugins: + name: Test Patches + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - if: ${{ github.event_name == 'schedule' }} - with: - ref: dev + steps: + - uses: actions/checkout@v4 + if: ${{ github.event_name == 'schedule' }} + with: + ref: dev - - uses: actions/checkout@v4 - if: ${{ github.event_name == 'workflow_dispatch' }} + - uses: actions/checkout@v4 + if: ${{ github.event_name == 'workflow_dispatch' }} - - uses: pnpm/action-setup@v3 # Install pnpm using packageManager key in package.json + - uses: pnpm/action-setup@v3 # Install pnpm using packageManager key in package.json - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "pnpm" + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" - - name: Install dependencies - run: | - pnpm install --frozen-lockfile + - name: Install dependencies + run: | + pnpm install --frozen-lockfile - - name: Install Google Chrome - id: setup-chrome - uses: browser-actions/setup-chrome@82b9ce628cc5595478a9ebadc480958a36457dc2 - with: - chrome-version: stable + - name: Install Google Chrome + id: setup-chrome + uses: browser-actions/setup-chrome@82b9ce628cc5595478a9ebadc480958a36457dc2 + with: + chrome-version: stable - - name: Build Equicord Reporter Version - run: pnpm buildReporter + - name: Build Equicord Reporter Version + run: pnpm buildReporter - - name: Create Report - timeout-minutes: 10 - run: | - export PATH="$PWD/node_modules/.bin:$PATH" - export CHROMIUM_BIN=${{ steps.setup-chrome.outputs.chrome-path }} + - name: Create Report + timeout-minutes: 10 + run: | + export PATH="$PWD/node_modules/.bin:$PATH" + export CHROMIUM_BIN=${{ steps.setup-chrome.outputs.chrome-path }} - esbuild scripts/generateReport.ts > dist/report.mjs - node dist/report.mjs >> $GITHUB_STEP_SUMMARY - env: - DISCORD_TOKEN: ${{ secrets.DTOKEN }} - DISCORD_WEBHOOK: ${{ secrets.WEBHOOK }} + esbuild scripts/generateReport.ts > dist/report.mjs + node dist/report.mjs >> $GITHUB_STEP_SUMMARY + env: + DISCORD_TOKEN: ${{ secrets.DTOKEN }} + DISCORD_WEBHOOK: ${{ secrets.WEBHOOK }} - - name: Create Report (Canary) - timeout-minutes: 10 - if: success() || failure() # even run if previous one failed - run: | - export PATH="$PWD/node_modules/.bin:$PATH" - export CHROMIUM_BIN=${{ steps.setup-chrome.outputs.chrome-path }} - export USE_CANARY=true + - name: Create Report (Canary) + timeout-minutes: 10 + if: success() || failure() # even run if previous one failed + run: | + export PATH="$PWD/node_modules/.bin:$PATH" + export CHROMIUM_BIN=${{ steps.setup-chrome.outputs.chrome-path }} + export USE_CANARY=true - esbuild scripts/generateReport.ts > dist/report.mjs - node dist/report.mjs >> $GITHUB_STEP_SUMMARY - env: - DISCORD_TOKEN: ${{ secrets.DTOKEN }} - DISCORD_WEBHOOK: ${{ secrets.WEBHOOK }} + esbuild scripts/generateReport.ts > dist/report.mjs + node dist/report.mjs >> $GITHUB_STEP_SUMMARY + env: + DISCORD_TOKEN: ${{ secrets.DTOKEN }} + DISCORD_WEBHOOK: ${{ secrets.WEBHOOK }} diff --git a/.github/workflows/syncDev.yml b/.github/workflows/syncDev.yml index 1c106318..9890bbbd 100644 --- a/.github/workflows/syncDev.yml +++ b/.github/workflows/syncDev.yml @@ -1,25 +1,25 @@ name: Sync Vencord Dev env: - WORKFLOW_TOKEN: ${{ secrets.ETOKEN }} - UPSTREAM_URL: "https://github.com/Vendicated/Vencord.git" - UPSTREAM_BRANCH: "dev" - DOWNSTREAM_BRANCH: "dev" + WORKFLOW_TOKEN: ${{ secrets.ETOKEN }} + UPSTREAM_URL: "https://github.com/Vendicated/Vencord.git" + UPSTREAM_BRANCH: "dev" + DOWNSTREAM_BRANCH: "dev" on: - schedule: - - cron: "0 * * * *" - workflow_dispatch: + schedule: + - cron: "0 * * * *" + workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Sync Vencord Dev - id: sync - uses: verticalsync/sync-upstream-repo@master - with: - upstream_repo: ${{ env.UPSTREAM_URL }} - upstream_branch: ${{ env.UPSTREAM_BRANCH }} - downstream_branch: ${{ env.DOWNSTREAM_BRANCH }} - token: ${{ env.WORKFLOW_TOKEN }} + build: + runs-on: ubuntu-latest + steps: + - name: Sync Vencord Dev + id: sync + uses: verticalsync/sync-upstream-repo@master + with: + upstream_repo: ${{ env.UPSTREAM_URL }} + upstream_branch: ${{ env.UPSTREAM_BRANCH }} + downstream_branch: ${{ env.DOWNSTREAM_BRANCH }} + token: ${{ env.WORKFLOW_TOKEN }} diff --git a/.github/workflows/syncMain.yml b/.github/workflows/syncMain.yml index 147c949f..b549a0d7 100644 --- a/.github/workflows/syncMain.yml +++ b/.github/workflows/syncMain.yml @@ -1,25 +1,25 @@ name: Sync Vencord Main env: - WORKFLOW_TOKEN: ${{ secrets.ETOKEN }} - UPSTREAM_URL: "https://github.com/Vendicated/Vencord.git" - UPSTREAM_BRANCH: "main" - DOWNSTREAM_BRANCH: "main" + WORKFLOW_TOKEN: ${{ secrets.ETOKEN }} + UPSTREAM_URL: "https://github.com/Vendicated/Vencord.git" + UPSTREAM_BRANCH: "main" + DOWNSTREAM_BRANCH: "main" on: - schedule: - - cron: "0 * * * *" - workflow_dispatch: + schedule: + - cron: "0 * * * *" + workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Sync Vencord Main - id: sync - uses: verticalsync/sync-upstream-repo@master - with: - upstream_repo: ${{ env.UPSTREAM_URL }} - upstream_branch: ${{ env.UPSTREAM_BRANCH }} - downstream_branch: ${{ env.DOWNSTREAM_BRANCH }} - token: ${{ env.WORKFLOW_TOKEN }} + build: + runs-on: ubuntu-latest + steps: + - name: Sync Vencord Main + id: sync + uses: verticalsync/sync-upstream-repo@master + with: + upstream_repo: ${{ env.UPSTREAM_URL }} + upstream_branch: ${{ env.UPSTREAM_BRANCH }} + downstream_branch: ${{ env.DOWNSTREAM_BRANCH }} + token: ${{ env.WORKFLOW_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f550f151..923a74fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,65 +1,65 @@ name: Test on: - push: - branches: - - main - - dev - pull_request: - branches: - - main - - dev + push: + branches: + - main + - dev + pull_request: + branches: + - main + - dev jobs: - Test: - name: Test For Pushes - if: ${{ github.event_name == 'push' }} - runs-on: ubuntu-latest + Test: + name: Test For Pushes + if: ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v3 # Install pnpm using packageManager key in package.json + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 # Install pnpm using packageManager key in package.json - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "pnpm" + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Install dependencies + run: pnpm install --frozen-lockfile - - name: Lint & Test if desktop version compiles - run: pnpm test + - name: Lint & Test if desktop version compiles + run: pnpm test - - name: Test if web version compiles - run: pnpm buildWeb + - name: Test if web version compiles + run: pnpm buildWeb - - name: Test if plugin structure is valid - run: pnpm generatePluginJson + - name: Test if plugin structure is valid + run: pnpm generatePluginJson - TestForPRs: - name: Test For Pull Requests - if: ${{ github.event_name == 'pull_request' }} - runs-on: ubuntu-latest + TestForPRs: + name: Test For Pull Requests + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v3 # Install pnpm using packageManager key in package.json + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 # Install pnpm using packageManager key in package.json - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "pnpm" + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Install dependencies + run: pnpm install --frozen-lockfile - - name: Lint & Test if desktop version compiles - run: pnpm test + - name: Lint & Test if desktop version compiles + run: pnpm test - - name: Test if web version compiles - run: pnpm buildWeb + - name: Test if web version compiles + run: pnpm buildWeb - - name: Test if plugin structure is valid - run: pnpm generatePluginJson + - name: Test if plugin structure is valid + run: pnpm generatePluginJson diff --git a/.github/workflows/uploadBuilds.yml b/.github/workflows/uploadBuilds.yml new file mode 100644 index 00000000..989db697 --- /dev/null +++ b/.github/workflows/uploadBuilds.yml @@ -0,0 +1,94 @@ +name: Upload Builds +on: + workflow_run: + workflows: [Release] + types: [completed] + branches: [main, dev] +env: + FORCE_COLOR: true + REPO: Equicord/Builds + TOKEN: ${{ secrets.ETOKEN }} + USERNAME: GitHub-Actions +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + +permissions: write-all + +jobs: + Date: + name: Date + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + outputs: + DATE: ${{ steps.combined.outputs.DATE }} + TIME: ${{ steps.combined.outputs.TIME }} + + steps: + - name: Get Month Day Year + id: date + uses: Kaven-Universe/github-action-current-date-time@v1 + with: + timezone-offset: 240 + + - name: Combine Time + id: combined + run: | + echo "DATE=$YEAR/$MONTH/$DAY" >> $GITHUB_OUTPUT + echo "TIME=$HOURS-$MINUTES-$SECONDS" >> $GITHUB_OUTPUT + env: + YEAR: ${{ steps.date.outputs.year }} + MONTH: ${{ steps.date.outputs.month }} + DAY: ${{ steps.date.outputs.day }} + HOURS: ${{ steps.date.outputs.hours }} + MINUTES: ${{ steps.date.outputs.minutes }} + SECONDS: ${{ steps.date.outputs.seconds }} + + Upload: + name: Upload Build + runs-on: ubuntu-latest + needs: Date + env: + DATE: ${{ needs.Date.outputs.DATE }} + TIME: ${{ needs.Date.outputs.TIME }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup Actions User + run: | + git config --global user.name "GitHub-Actions" + git config --global user.email actions@github.com + + - name: Download build artifact from triggered workflow + uses: dawidd6/action-download-artifact@v2 + with: + run_id: ${{ github.event.workflow_run.id }} + name: build + path: ./release + search_artifacts: true + + - name: Upload Stable Build to Builds repo + if: ${{ github.event.workflow_run.head_branch == 'main' }} + run: | + git clone https://$USERNAME:$TOKEN@github.com/$REPO.git builds + cd builds + + mkdir -p stable/$DATE/$TIME + cp -r ../release/* ./stable/$DATE/$TIME + + git add -A + git commit -m "Stable Build for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" + git push --force https://$USERNAME:$TOKEN@github.com/$REPO.git + + - name: Upload Dev Build To Builds Repo + if: ${{ github.event.workflow_run.head_branch == 'dev' }} + run: | + git clone https://$USERNAME:$TOKEN@github.com/$REPO.git builds + cd builds + + mkdir -p devbuilds/$DATE/$TIME + cp -r ../release/* ./devbuilds/$DATE/$TIME + + git add -A + git commit -m "Dev Build for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" + git push --force https://$USERNAME:$TOKEN@github.com/$REPO.git diff --git a/.github/workflows/uploadPlugins.yml b/.github/workflows/uploadPlugins.yml new file mode 100644 index 00000000..8edd474f --- /dev/null +++ b/.github/workflows/uploadPlugins.yml @@ -0,0 +1,46 @@ +name: Upload Plugins JSONs +on: + workflow_run: + workflows: [Release] + types: [completed] + branches: [main] +env: + FORCE_COLOR: true + REPO: Equicord/Equibored + TOKEN: ${{ secrets.ETOKEN }} + USERNAME: GitHub-Actions + +permissions: write-all + +jobs: + Upload: + name: Upload Plugins + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup Actions User + run: | + git config --global user.name "GitHub-Actions" + git config --global user.email actions@github.com + + - name: Download build artifact from triggered workflow + uses: dawidd6/action-download-artifact@v2 + with: + run_id: ${{ github.event.workflow_run.id }} + name: build + path: ./release + search_artifacts: true + + - name: Upload Plugins JSON to Equibored repo + run: | + git clone https://$USERNAME:$TOKEN@github.com/$REPO.git plugins + cd plugins + + cp ../release/*plugins.json . + git add -A + + git commit -m "Plugins for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" + git push --force https://$USERNAME:$TOKEN@github.com/$REPO.git diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index 2d5befeb..b757386f 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -225,11 +225,7 @@ async function parseFile(fileName: string) { .replace(/\/index\.([jt]sx?)$/, "") .replace(/^src\/plugins\//, ""); - let readme = ""; - try { - readme = readFileSync(join(fileName, "..", "README.md"), "utf-8"); - } catch { } - return [data, readme] as const; + return [data] as const; } throw fail("no default export called 'definePlugin' found"); @@ -260,23 +256,20 @@ function isPluginFile({ name }: { name: string; }) { parseEquicordDevs(); const plugins = [] as PluginData[]; - const readmes = {} as Record; await Promise.all(["src/plugins", "src/plugins/_core", "src/equicordplugins"].flatMap(dir => readdirSync(dir, { withFileTypes: true }) .filter(isPluginFile) .map(async dirent => { - const [data, readme] = await parseFile(await getEntryPoint(dir, dirent)); + const [data] = await parseFile(await getEntryPoint(dir, dirent)); plugins.sort().push(data); - if (readme) readmes[data.name] = readme; }) )); const data = JSON.stringify(plugins); - if (process.argv.length > 3) { + if (process.argv.length > 2) { writeFileSync(process.argv[2], data); - writeFileSync(process.argv[3], JSON.stringify(readmes)); } else { console.log(data); } diff --git a/src/components/PluginSettings/ContributorModal.tsx b/src/components/PluginSettings/ContributorModal.tsx index 5feda2d7..b298a70f 100644 --- a/src/components/PluginSettings/ContributorModal.tsx +++ b/src/components/PluginSettings/ContributorModal.tsx @@ -94,7 +94,7 @@ function ContributorModal({ user }: { user: User; }) { ) : ( - {user.username} has not made any plugins. They likely {ContributedHyperLink} to Vencord in other ways! + {user.username} has not made any plugins. They likely {ContributedHyperLink} in other ways! )} diff --git a/src/plugins/userMessagesPronouns/README.md b/src/plugins/userMessagesPronouns/README.md deleted file mode 100644 index 455f9c44..00000000 --- a/src/plugins/userMessagesPronouns/README.md +++ /dev/null @@ -1,5 +0,0 @@ -User Messages Pronouns - -Adds pronouns to chat user messages - -![](https://github.com/user-attachments/assets/34dc373d-faf4-4420-b49b-08b2647baa3b)