From 540969be219ea09df0749da8be472c080439a51f Mon Sep 17 00:00:00 2001 From: koenkk Date: Thu, 4 Jan 2024 22:30:28 +0100 Subject: [PATCH] chore: fix release-please --- .github/workflows/ci.yml | 37 +++++++++++++++++--- .github/workflows/release_please.yml | 51 +--------------------------- .release-please-manifest.json | 3 +- release-please-config.json | 8 ++--- 4 files changed, 37 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5b3c65e..2adb6e9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: uses: docker/setup-buildx-action@v3 with: version: latest - - name: Docker build dev + - name: "dev: Docker build" if: github.ref == 'refs/heads/dev' && github.event_name == 'push' run: | docker buildx build \ @@ -52,7 +52,7 @@ jobs: --push \ -t koenkk/zigbee2mqtt:latest-dev -t ghcr.io/koenkk/zigbee2mqtt:latest-dev \ . - - name: Docker build release + - name: "release: Docker build" if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' run: | TAG="$(git describe --tags)" @@ -64,12 +64,12 @@ jobs: --push \ -t koenkk/zigbee2mqtt:latest -t "koenkk/zigbee2mqtt:$TAG" -t ghcr.io/koenkk/zigbee2mqtt:latest -t "ghcr.io/koenkk/zigbee2mqtt:$TAG" \ . - - name: Publish to npm + - name: "release: Publish to npm" if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN }} - - name: Trigger zigbee2mqtt/hassio-zigbee2mqtt build + - name: "dev: Trigger zigbee2mqtt/hassio-zigbee2mqtt build" if: github.ref == 'refs/heads/dev' && github.event_name == 'push' run: | curl \ @@ -78,6 +78,35 @@ jobs: -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/zigbee2mqtt/hassio-zigbee2mqtt/actions/workflows/ci.yml/dispatches \ -d '{"ref":"master","inputs":{}}' + - name: "release: Trigger zigbee2mqtt/hassio-zigbee2mqtt build" + if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' + run: | + TAG=${GITHUB_REF#refs/*/} + echo "Triggering with tag '$TAG'" + curl \ + -X POST \ + -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ + -H "Accept: application/vnd.github.everest-preview+json" \ + -H "Content-Type: application/json" \ + https://api.github.com/repos/zigbee2mqtt/hassio-zigbee2mqtt/dispatches \ + --data "{\"event_type\": \"release\", \"client_payload\": { \"version\": \"$TAG-1\"}}" + - name: "release: merge dev -> master and promote dev" + if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git fetch origin + git checkout master + git merge -m 'chore: merge dev to master' dev + git push origin master + git checkout dev + jq '.version = "${{ needs.release-please.outputs.version }}-dev"' package.json > package.json.tmp + jq '.version = "${{ needs.release-please.outputs.version }}-dev"' package-lock.json > package-lock.json.tmp + mv package.json.tmp package.json + mv package-lock.json.tmp package-lock.json + git add -A + git commit -m "chore: promote to dev" + git push origin dev tests: strategy: diff --git a/.github/workflows/release_please.yml b/.github/workflows/release_please.yml index 301a97e6..5a63a7d2 100644 --- a/.github/workflows/release_please.yml +++ b/.github/workflows/release_please.yml @@ -57,63 +57,14 @@ jobs: node scripts/generateChangelog.js $MASTER_Z2M_VERSION $MASTER_ZHC_VERSION $MASTER_ZH_VERSION $MASTER_FRONTEND_VERSION >> ../changelog.md env: GH_TOKEN: ${{secrets.GH_TOKEN}} - - name: Update changelog in release PR + - name: Update changelog gist run: | gh gist edit bfd4c3d1725a2cccacc11d6ba51008ba -a changelog.md env: GH_TOKEN: ${{secrets.GH_TOKEN}} - - name: Upload changelog - uses: actions/upload-artifact@v4 - with: - name: changelog - path: changelog.md - name: Save cache commit-user-lookup.json uses: actions/cache/save@v3 if: always() with: path: z2m/scripts/commit-user-lookup.json key: commit-user-lookup-${{ hashFiles('z2m/scripts/commit-user-lookup.json') }} - - create_release: - runs-on: ubuntu-latest - needs: [release-please] - if: ${{ needs.release-please.outputs.release_created }} - steps: - - uses: actions/checkout@v4 - with: - ref: dev - token: ${{secrets.GH_TOKEN}} - - name: Merge dev -> master - run: | - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git fetch origin - git checkout master - git merge -m 'chore: merge dev to master' dev - git push origin master - git checkout dev - - name: Promote to dev - run: | - jq '.version = "${{ needs.release-please.outputs.version }}-dev"' package.json > package.json.tmp - jq '.version = "${{ needs.release-please.outputs.version }}-dev"' package-lock.json > package-lock.json.tmp - mv package.json.tmp package.json - mv package-lock.json.tmp package-lock.json - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "chore: promote to dev" - - name: Download changelog - uses: actions/download-artifact@v4 - with: - name: changelog - path: ../changelog - - name: update release - id: update_release - uses: tubone24/update_release@v1.0 - env: - GITHUB_TOKEN: ${{ github.token }} - TAG_NAME: ${{ needs.release-please.outputs.version }} - with: - body_path: ../changelog/changelog.md - - name: Trigger HA addon update - run: | - curl -XPOST -H "Authorization: token ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/zigbee2mqtt/hassio-zigbee2mqtt/dispatches --data "{\"event_type\": \"release\", \"client_payload\": { \"version\": \"${{ needs.release-please.outputs.version }}-1\"}}" diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5c1d9cef..0092036d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,4 @@ { ".": "1.35.0", - "bootstrap-sha": "7ee207fc0e05f32c9636c0298b48eea1b91ed9e1", - "include-v-in-tag": false + "bootstrap-sha": "7ee207fc0e05f32c9636c0298b48eea1b91ed9e1" } \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json index 63f883de..d6ff4a4d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,14 +1,10 @@ { "packages": { ".": { - "changelog-path": "CHANGELOG.md", "release-type": "node", - "bump-minor-pre-major": false, - "bump-patch-for-minor-pre-major": false, - "draft": false, + "include-component-in-tag": false, "include-v-in-tag": false, - "prerelease": true, - "skip-github-release": false + "draft": true } }, "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"