diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81739d96f7..5f8072284f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,14 @@ -name: CI +name: ci -on: [push, pull_request] +on: + pull_request: + push: + branches-ignore: + - deps/* permissions: - contents: read + contents: write + pull-requests: write jobs: ci: @@ -12,9 +17,9 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 20 registry-url: https://registry.npmjs.org/ - cache: 'npm' + cache: npm - name: Install dependencies run: npm ci - name: Build @@ -28,7 +33,7 @@ jobs: run: echo ${{ secrets.DOCKER_KEY }} | docker login -u koenkk --password-stdin - name: Docker login ghcr.io if: (github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' - run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u koenkk --password-stdin + run: echo ${{ secrets.GH_TOKEN }} | docker login ghcr.io -u koenkk --password-stdin - name: Docker setup - QEMU if: (github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' uses: docker/setup-qemu-action@v2 @@ -73,7 +78,7 @@ jobs: run: | curl \ -X POST \ - -H "Authorization: token ${{ secrets.CR_PAT }}" \ + -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/zigbee2mqtt/hassio-zigbee2mqtt/actions/workflows/ci.yml/dispatches \ -d '{"ref":"master","inputs":{}}' @@ -95,8 +100,6 @@ jobs: - name: Install dependencies # --ignore-scripts prevents the serialport build which often fails on Windows run: npm ci --ignore-scripts - - name: Lint - run: npm run eslint - name: Build run: npm run build - name: Test diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index b480753f2c..15f07a5883 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -1,34 +1,23 @@ -name: "Code Scanning - Action" +name: codeql on: - pull_request: push: + branches: + - dev jobs: CodeQL-Build: - # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest runs-on: ubuntu-latest permissions: - # required for all workflows security-events: write steps: - name: Checkout repository uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below). - name: Autobuild uses: github/codeql-action/autobuild@v2 - - #- run: | - # make bootstrap - # make release - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/depsreview.yaml b/.github/workflows/deps_review.yaml similarity index 91% rename from .github/workflows/depsreview.yaml rename to .github/workflows/deps_review.yaml index defcfabfa8..93b96b47a5 100644 --- a/.github/workflows/depsreview.yaml +++ b/.github/workflows/deps_review.yaml @@ -1,4 +1,4 @@ -name: 'Dependency review' +name: deps-review on: [pull_request] permissions: diff --git a/.github/workflows/ghcr_cleanup.yml b/.github/workflows/ghcr_cleanup.yml index ccb296e19e..31e5789e91 100644 --- a/.github/workflows/ghcr_cleanup.yml +++ b/.github/workflows/ghcr_cleanup.yml @@ -1,7 +1,7 @@ on: workflow_dispatch: -name: GHCR cleanup +name: ghcr-cleanup permissions: {} jobs: @@ -12,7 +12,7 @@ jobs: - name: Delete untagged images uses: actions/github-script@v6 with: - github-token: ${{ secrets.CR_PAT }} + github-token: ${{ secrets.GH_TOKEN }} script: | const response = await github.request("GET /${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions", { per_page: ${{ env.PER_PAGE }} diff --git a/.github/workflows/release_please.yml b/.github/workflows/release_please.yml index a6dd0c1e66..c436ffeb75 100644 --- a/.github/workflows/release_please.yml +++ b/.github/workflows/release_please.yml @@ -13,9 +13,56 @@ jobs: release-please: runs-on: ubuntu-latest steps: + - uses: actions/setup-node@v3 + with: + node-version: 20 + cache: npm + - uses: google-github-actions/release-please-action@v3 with: release-type: node package-name: release-please-action - default-branch: master - token: ${{secrets.CR_PAT}} \ No newline at end of file + default-branch: dev + token: ${{secrets.GH_TOKEN}} + + # Checkout repos + - uses: actions/checkout@v3 + with: + repository: koenkk/zigbee2mqtt + path: ./z2m + - uses: actions/checkout@v3 + with: + repository: koenkk/zigbee2mqtt + path: ./z2m-master + ref: master + - uses: actions/checkout@v3 + with: + repository: koenkk/zigbee2mqtt + path: ./z2m-changelog + ref: release-please--branches--dev--components--release-please-action + + - name: Update latest-dev tag + run: | + cd z2m + git push --delete origin latest-dev + git tag latest-dev + git push origin latest-dev + - name: Update latest-dev release changelog + run: | + PR=$(echo '${{ steps.release.outputs.pr }}' | jq -r '.number') + MASTER_Z2M_VERSION=$(cat z2m-master/package.json | jq -r '.version') + MASTER_ZHC_VERSION=$(cat z2m-master/package.json | jq -r '.dependencies."zigbee-herdsman-converters"') + MASTER_ZH_VERSION=$(cat z2m-master/package.json | jq -r '.dependencies."zigbee-herdsman"') + cp z2m-changelog/CHANGELOG.md z2m + cd z2m + npm ci + node scripts/generateChangelog.js $MASTER_Z2M_VERSION $MASTER_ZHC_VERSION $MASTER_ZH_VERSION >> ../changelog + env: + GH_TOKEN: ${{secrets.GH_TOKEN}} + - uses: ncipollo/release-action@v1 + with: + bodyFile: changelog + prerelease: true + name: latest-dev + allowUpdates: true + tag: latest-dev diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 8b73dc8f60..59395bc232 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,17 +1,12 @@ -name: "Close stale issues/pull requests" +name: stale + on: schedule: - cron: "0 0 * * *" workflow_dispatch: -permissions: - contents: read - jobs: stale: - permissions: - issues: write # for actions/stale to close stale issues - pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest steps: - uses: actions/stale@v8 @@ -21,5 +16,5 @@ jobs: stale-pr-message: 'This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days' days-before-stale: 30 days-before-close: 7 - operations-per-run: 500 exempt-issue-labels: dont-stale + operations-per-run: 500 diff --git a/.github/workflows/update_dependency.yml b/.github/workflows/update_dep.yml similarity index 89% rename from .github/workflows/update_dependency.yml rename to .github/workflows/update_dep.yml index cdd90aa457..65d0a1cf40 100644 --- a/.github/workflows/update_dependency.yml +++ b/.github/workflows/update_dep.yml @@ -1,10 +1,12 @@ on: repository_dispatch: - types: update_dependency + types: update_dep + +name: update-dep permissions: {} jobs: - update_dependency: + update_dep: permissions: contents: write pull-requests: write @@ -24,7 +26,7 @@ jobs: id: cpr with: commit-message: "fix(ignore): update ${{ github.event.client_payload.package }} to ${{ github.event.client_payload.version }}" - branch: "update_dependency_${{ github.event.client_payload.package }}" + branch: "deps/${{ github.event.client_payload.package }}" title: Update ${{ github.event.client_payload.package }} to ${{ github.event.client_payload.version }} - run: sleep 5 # Otherwise pull request may not exist yet causing automerge to fail - uses: peter-evans/enable-pull-request-automerge@v3 diff --git a/.github/workflows/update_deps.yml b/.github/workflows/update_deps.yml index fd7b5ca820..ff1c1fe1dc 100644 --- a/.github/workflows/update_deps.yml +++ b/.github/workflows/update_deps.yml @@ -17,14 +17,15 @@ jobs: - uses: actions/checkout@v3 with: ref: dev - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + token: ${{ secrets.GH_TOKEN }} - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 20 + cache: npm - run: npx npm-check-updates -u -x connect-gzip-static # connect-gzip-static only supports node 16 - run: npm install - uses: peter-evans/create-pull-request@v5 with: - commit-message: "feat(ignore): update dependencies" - branch: "update_deps" + commit-message: "fix(ignore): update dependencies" + branch: "deps/all" title: Update dependencies diff --git a/.github/workflows/update_frontend.yml b/.github/workflows/update_frontend.yml deleted file mode 100644 index c04884264a..0000000000 --- a/.github/workflows/update_frontend.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Update zigbee-frontend -on: - repository_dispatch: - types: update_frontend - -permissions: {} -jobs: - update_frontend: - permissions: - contents: write # to create branch (peter-evans/create-pull-request) - pull-requests: write # to create a PR (peter-evans/create-pull-request) - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: dev - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: npm install zigbee2mqtt-frontend@${{ github.event.client_payload.version }} --save-exact - - uses: peter-evans/create-pull-request@v5 - id: cpr - with: - commit-message: "feat(ignore): update zigbee2mqtt-frontend to ${{ github.event.client_payload.version }}" - branch: "update_frontend" - title: Update zigbee-frontend to ${{ github.event.client_payload.version }} - - run: sleep 5 # Otherwise pull request may not exist yet causing automerge to fail - - uses: peter-evans/enable-pull-request-automerge@v3 - if: steps.cpr.outputs.pull-request-operation == 'created' - with: - token: ${{ secrets.CR_PAT }} - pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} - merge-method: squash diff --git a/.github/workflows/update_zh.yml b/.github/workflows/update_zh.yml deleted file mode 100644 index 1127f11de7..0000000000 --- a/.github/workflows/update_zh.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Update zigbee-herdsman -on: - repository_dispatch: - types: update_zh - -permissions: {} -jobs: - update_zh: - permissions: - contents: write # to create branch (peter-evans/create-pull-request) - pull-requests: write # to create a PR (peter-evans/create-pull-request) - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: dev - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: npm install zigbee-herdsman@${{ github.event.client_payload.version }} --save-exact - - uses: peter-evans/create-pull-request@v5 - id: cpr - with: - commit-message: "feat(ignore): update zigbee-herdsman to ${{ github.event.client_payload.version }}" - branch: "update_zh" - title: Update zigbee-herdsman to ${{ github.event.client_payload.version }} - - run: sleep 5 # Otherwise pull request may not exist yet causing automerge to fail - - uses: peter-evans/enable-pull-request-automerge@v3 - if: steps.cpr.outputs.pull-request-operation == 'created' - with: - token: ${{ secrets.CR_PAT }} - pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} - merge-method: squash \ No newline at end of file diff --git a/.github/workflows/update_zhc.yml b/.github/workflows/update_zhc.yml deleted file mode 100644 index 3dc5594ed1..0000000000 --- a/.github/workflows/update_zhc.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Update zigbee-herdsman-converters -on: - repository_dispatch: - types: update_zhc - -permissions: {} -jobs: - update_zhc: - permissions: - contents: write # to create branch (peter-evans/create-pull-request) - pull-requests: write # to create a PR (peter-evans/create-pull-request) - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: dev - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: npm install zigbee-herdsman-converters@${{ github.event.client_payload.version }} --save-exact - - uses: peter-evans/create-pull-request@v5 - id: cpr - with: - commit-message: "feat(ignore): update zigbee-herdsman-converters to ${{ github.event.client_payload.version }}" - branch: "update_zhc" - title: Update zigbee-herdsman-converters to ${{ github.event.client_payload.version }} - - run: sleep 5 # Otherwise pull request may not exist yet causing automerge to fail - - uses: peter-evans/enable-pull-request-automerge@v3 - if: steps.cpr.outputs.pull-request-operation == 'created' - with: - token: ${{ secrets.CR_PAT }} - pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} - merge-method: squash \ No newline at end of file