Make entity naming and entity_id independent of pet name (#80) #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| prepare-release: | |
| name: Prepare Release PR | |
| runs-on: ubuntu-latest | |
| # Skip when the release PR itself is being merged | |
| if: "!startsWith(github.event.head_commit.message, 'chore: release v')" | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Compute next version | |
| id: version | |
| run: | | |
| CURRENT=$(python3 -c "import json; print(json.load(open('custom_components/pettracer/manifest.json'))['version'])") | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" | |
| NEXT="$MAJOR.$MINOR.$((PATCH + 1))" | |
| echo "current=$CURRENT" >> $GITHUB_OUTPUT | |
| echo "next=$NEXT" >> $GITHUB_OUTPUT | |
| echo "Bumping $CURRENT → $NEXT" | |
| - name: Generate release notes | |
| id: notes | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const { data } = await github.rest.repos.generateReleaseNotes({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: 'v${{ steps.version.outputs.next }}', | |
| target_commitish: 'master', | |
| }); | |
| return data.body; | |
| result-encoding: string | |
| - name: Update version files | |
| run: | | |
| NEXT="${{ steps.version.outputs.next }}" | |
| python3 -c " | |
| import json | |
| with open('custom_components/pettracer/manifest.json') as f: | |
| d = json.load(f) | |
| d['version'] = '$NEXT' | |
| with open('custom_components/pettracer/manifest.json', 'w') as f: | |
| json.dump(d, f, indent=2) | |
| f.write('\n') | |
| " | |
| echo "$NEXT" > version.txt | |
| - name: Create or update release PR | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore: release v${{ steps.version.outputs.next }}" | |
| branch: release/next | |
| title: "chore: release v${{ steps.version.outputs.next }}" | |
| body: ${{ steps.notes.outputs.result }} | |
| labels: release | |
| publish-release: | |
| name: Publish Release | |
| runs-on: ubuntu-latest | |
| if: "startsWith(github.event.head_commit.message, 'chore: release v')" | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Get version | |
| id: version | |
| run: | | |
| VERSION=$(python3 -c "import json; print(json.load(open('custom_components/pettracer/manifest.json'))['version'])") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create ZIP package | |
| run: | | |
| cd custom_components | |
| zip -r ../pettracer-${{ steps.version.outputs.version }}.zip pettracer/ \ | |
| -x "*.pyc" -x "__pycache__/*" -x "*.pyo" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: v${{ steps.version.outputs.version }} | |
| generate_release_notes: true | |
| files: pettracer-${{ steps.version.outputs.version }}.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |