name: Release on: push: branches: [main] paths: - custom_components/nvidia_shield/manifest.json workflow_dispatch: jobs: release: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Read version from manifest.json id: version run: | VERSION=$(jq -r .version custom_components/nvidia_shield/manifest.json) echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" - name: Check if tag already exists id: check run: | if git ls-remote --tags origin "refs/tags/${{ steps.version.outputs.tag }}" | grep -q .; then echo "exists=true" >> "$GITHUB_OUTPUT" else echo "exists=false" >> "$GITHUB_OUTPUT" fi - name: Create tag if: steps.check.outputs.exists == 'false' run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}" git push origin "${{ steps.version.outputs.tag }}" - name: Create GitHub Release if: steps.check.outputs.exists == 'false' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release create "${{ steps.version.outputs.tag }}" \ --title "${{ steps.version.outputs.tag }}" \ --generate-notes