fix: cover position event and bump version #17
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: | |
| paths: | |
| - 'custom_components/virtual_devices/manifest.json' | |
| release: | |
| types: [published] | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version from manifest | |
| id: extract_version | |
| if: github.event_name == 'push' | |
| run: | | |
| version=$(jq -r '.version' custom_components/virtual_devices/manifest.json) | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "version_number=${version#v}" >> $GITHUB_OUTPUT | |
| - name: Check if tag exists | |
| id: check_tag | |
| if: github.event_name == 'push' | |
| run: | | |
| version="${{ steps.extract_version.outputs.version }}" | |
| if git rev-parse "$version" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Tag $version already exists, skipping release" | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Tag $version does not exist, will create release" | |
| fi | |
| - name: Create tag and release | |
| if: github.event_name == 'push' && steps.check_tag.outputs.exists == 'false' | |
| run: | | |
| version="${{ steps.extract_version.outputs.version }}" | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git tag -a "$version" -m "Release $version" | |
| git push origin "$version" | |
| - name: Generate changelog | |
| id: changelog | |
| if: github.event_name == 'push' && steps.check_tag.outputs.exists == 'false' | |
| uses: Desmond-Dong/actions/bilingual-changelog@v1 | |
| with: | |
| llm-api-key: ${{ secrets.LLM_API_KEY }} | |
| - name: Create GitHub Release | |
| if: github.event_name == 'push' && steps.check_tag.outputs.exists == 'false' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.extract_version.outputs.version }} | |
| name: Release ${{ steps.extract_version.outputs.version }} | |
| body: ${{ steps.changelog.outputs.changelog }} | |
| draft: false | |
| prerelease: false | |
| - name: Create zip file | |
| run: | | |
| cd ${{ github.workspace }}/custom_components/virtual_devices | |
| zip -r virtual_devices.zip ./ | |
| - name: Upload release asset | |
| if: github.event_name == 'push' && steps.check_tag.outputs.exists == 'false' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ${{ github.workspace }}/custom_components/virtual_devices/virtual_devices.zip | |
| asset_name: virtual_devices.zip | |
| tag: ${{ steps.extract_version.outputs.version }} | |
| overwrite: true | |
| - name: Upload release asset to existing release | |
| if: github.event_name == 'release' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ${{ github.workspace }}/custom_components/virtual_devices/virtual_devices.zip | |
| asset_name: virtual_devices.zip | |
| tag: ${{ github.ref }} | |
| overwrite: true |