From 06c7ba0a0dba6844233bdadeacc162b77eaa92f8 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Fri, 18 Jul 2025 22:52:12 +0300 Subject: [PATCH] github actions: update all actions --- .github/workflows/lint.yml | 42 +++++++++---- .github/workflows/manual-release.yml | 23 ++++--- .github/workflows/pr-comment.yml | 91 ++++++++++++++++----------- .github/workflows/publish-release.yml | 24 +++---- .github/workflows/stale.yml | 20 +++--- .github/workflows/update-nightly.yml | 79 ----------------------- .github/workflows/update-proto.yml | 19 +++--- 7 files changed, 131 insertions(+), 167 deletions(-) delete mode 100644 .github/workflows/update-nightly.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 29829526..8d7e6fd9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,10 @@ -name: Check PR health +name: Linting Check -on: [pull_request] +on: + push: + branches: + - master + pull_request: jobs: check-lint: @@ -8,15 +12,29 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Install Node - uses: actions/setup-node@v1 - with: - node-version: 20.x + - name: Setup Node and Corepack + uses: actions/setup-node@v3.6.0 + with: + node-version: 20.x - - name: Install packages - run: yarn - - - name: Check linting - run: yarn lint + - name: Enable Corepack and Set Yarn Version + run: | + corepack enable + corepack prepare yarn@4.x --activate + + - name: Restore Yarn Cache + uses: actions/cache@v3 + id: yarn-cache + with: + path: .yarn/cache + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install packages + run: yarn install --immutable + + - name: Check linting + run: yarn lint diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index 0aa9298c..3618a4ff 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -5,9 +5,10 @@ on: inputs: increment: type: string - description: "Must be: patch, minor, major, pre* or " + description: 'Must be: patch, minor, major, pre* or ' required: true - default: "patch" + default: 'patch' + jobs: manual-release: runs-on: ubuntu-latest @@ -27,20 +28,22 @@ jobs: with: node-version: 20.x - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + - name: Enable Corepack and Set Yarn Version + run: | + corepack enable + corepack prepare yarn@4.x --activate - - uses: actions/cache@v3 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + - name: Restore Yarn Cache + uses: actions/cache@v3 + id: yarn-cache with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + path: .yarn/cache key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - name: Install Dependencies - run: yarn + run: yarn install --immutable - name: Release - run: "npx release-it --increment ${{ github.event.inputs.increment }}" + run: npx release-it --increment ${{ github.event.inputs.increment }} diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 95c5402a..42c64d8e 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -1,38 +1,53 @@ -name: PR Comment - -on: - pull_request_target: - types: - - opened - - synchronize - - reopened - - unlocked - -jobs: - pr-comment: - runs-on: ubuntu-latest - timeout-minutes: 10 - permissions: write-all - steps: - - uses: actions/checkout@v3 - - - uses: mshick/add-pr-comment@v2 - with: - repo-token: ${{ secrets.PERSONAL_TOKEN}} - message-id: pr-test - message: | - Thanks for your contribution. - - The next step is to wait for review and approval to merge it to main repository - - The community can help reacting with a thumb up (:thumbsup:) for approval and rocket (:rocket:) for who has tested it. - - To test this PR you can run the following command below: - ``` - # NPM - npm install @whiskeysockets/baileys@${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }} - # YARN v2 - yarn add @whiskeysockets/baileys@${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }} - # PNPM - pnpm add @whiskeysockets/baileys@${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }} - ``` +name: PR Comment + +on: + pull_request_target: + types: + - opened + - synchronize + - reopened + - unlocked + +jobs: + pr-comment: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: write-all + steps: + - uses: actions/checkout@v3 + + - uses: mshick/add-pr-comment@v2 + with: + repo-token: ${{ secrets.PERSONAL_TOKEN }} + message-id: pr-test + message: | + Thanks for opening this pull request and contributing to the project! + + The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch. + + In the meantime, anyone in the community is encouraged to test this pull request and provide feedback. + + ### ✅ How to confirm it works + + If you’ve tested this PR, please comment below with: + + ``` + Tested and working ✅ + ``` + + This helps us speed up the review and merge process. + + ### 📦 To test this PR locally: + + ``` + # NPM + npm install @whiskeysockets/baileys@${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }} + + # Yarn (v2+) + yarn add @whiskeysockets/baileys@${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }} + + # PNPM + pnpm add @whiskeysockets/baileys@${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }} + ``` + + If you encounter any issues or have feedback, feel free to comment as well. diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index d72619d4..02014256 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -3,7 +3,7 @@ name: Publish Release on: push: tags: - - "v*" + - 'v*' permissions: write-all @@ -23,24 +23,26 @@ jobs: uses: actions/setup-node@v3.6.0 with: node-version: 20.x - registry-url: "https://registry.npmjs.org" + registry-url: 'https://registry.npmjs.org' env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + - name: Enable Corepack and Set Yarn Version + run: | + corepack enable + corepack prepare yarn@4.x --activate - - uses: actions/cache@v3 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + - name: Restore Yarn Cache + uses: actions/cache@v3 + id: yarn-cache with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + path: .yarn/cache key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - name: Install Dependencies - run: yarn + run: yarn install --immutable env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -48,7 +50,7 @@ jobs: run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - + - name: Publish in NPM (whiskeysockets scope) run: | npx json -I -f package.json -e "this.name='@whiskeysockets/baileys'" @@ -66,7 +68,7 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT - name: Make Package - run: npm pack + run: yarn pack - name: Rename Pack run: mv *.tgz baileys.tgz diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index deaf85c1..ced38cfe 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,7 +2,7 @@ name: Mark stale issues and pull requests on: schedule: - - cron: "30 1 * * *" + - cron: '30 1 * * *' permissions: issues: write pull-requests: write @@ -10,12 +10,12 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue is stale because it has been open 15 days with no activity. Remove the stale label or comment or this will be closed in 15 days' - stale-pr-message: 'This PR is stale because it has been open 15 days with no activity. Remove the stale label or comment or this will be closed in 15 days' - days-before-stale: 15 - days-before-close: 30 - exempt-issue-labels: 'bug,enhancement' - exempt-pr-labels: 'bug,enhancement' + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days.' + stale-pr-message: 'This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days' + days-before-stale: 14 + days-before-close: 28 + exempt-issue-labels: 'bug,enhancement,unstale' + exempt-pr-labels: 'bug,enhancement,unstale' diff --git a/.github/workflows/update-nightly.yml b/.github/workflows/update-nightly.yml deleted file mode 100644 index be05fbf8..00000000 --- a/.github/workflows/update-nightly.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: Update Nightly - -permissions: - contents: write - -on: - push: - branches: - - master - -jobs: - update-nightly: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Fetching tags - run: git fetch --tags -f || true - - - name: Setup Node - uses: actions/setup-node@v3.6.0 - with: - node-version: 20.x - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Install Dependencies - run: yarn - - - name: Update version to alpha - run: yarn version --prerelease --preid=alpha --no-git --no-git-tag-version - - - name: Build NPM package - run: yarn pack && mv baileys-*.tgz baileys-nightly.tgz - - - name: Generate Changelog - id: generate_changelog - run: | - changelog=$(yarn run --silent changelog:preview) - echo "changelog<> $GITHUB_OUTPUT - echo "${changelog}" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Update Nightly TAG - uses: richardsimko/update-tag@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: nightly - - - name: Update Nightly Release - uses: meeDamian/github-release@2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - tag: nightly - commitish: ${{ github.sha }} - name: Nightly Release - body: ${{ steps.generate_changelog.outputs.changelog }} - draft: false - prerelease: true - files: > - baileys-nightly.tgz - gzip: folders - allow_override: true diff --git a/.github/workflows/update-proto.yml b/.github/workflows/update-proto.yml index 38d44e27..439face8 100644 --- a/.github/workflows/update-proto.yml +++ b/.github/workflows/update-proto.yml @@ -2,7 +2,7 @@ name: Update WAProto on: schedule: - - cron: "10 1 * * *" + - cron: '10 1 * * *' workflow_dispatch: permissions: @@ -22,10 +22,15 @@ jobs: with: node-version: 20.x + - name: Enable Corepack and Set Yarn Version + run: | + corepack enable + corepack prepare yarn@4.x --activate + - name: Install packages run: | - yarn - yarn --pure-lockfile --cwd proto-extract + yarn install --immutable + yarn --cwd proto-extract install --immutable - name: Update WAProto.proto id: wa_proto_info @@ -48,11 +53,11 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v5 with: - commit-message: "chore: updated proto/version to v${{steps.wa_proto_info.outputs.wa_version}}" - title: "Whatsapp v${{steps.wa_proto_info.outputs.wa_version}} proto/version change" - branch: "update-proto/stable" + commit-message: 'chore: updated proto/version to v${{steps.wa_proto_info.outputs.wa_version}}' + title: 'Whatsapp v${{steps.wa_proto_info.outputs.wa_version}} proto/version change' + branch: 'update-proto/stable' delete-branch: true - labels: "update-proto" + labels: 'update-proto' body: "Automated changes\nFound source JS URL: ${{steps.wa_proto_info.outputs.wa_js_url}}\nCurrent version: v${{steps.wa_proto_info.outputs.wa_version}}" add-paths: | WAProto/*