Create HACS Release #23
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: Create HACS Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| description: 'Choose the type of release you want to create' | |
| required: true | |
| default: 'pre-release' | |
| type: choice | |
| options: | |
| - pre-release | |
| - full-release | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate Version Number | |
| id: version | |
| run: | | |
| VERSION=$(date +'%Y.%m.%d') | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Update manifest.json | |
| run: | | |
| MANIFEST_PATH="custom_components/luxtronik2/manifest.json" | |
| jq --arg ver "$VERSION" '.version = $ver' $MANIFEST_PATH > tmp.json | |
| mv tmp.json $MANIFEST_PATH | |
| - name: Validate HACS Compliance | |
| uses: hacs/action@main | |
| with: | |
| category: integration | |
| - name: Commit and Push Changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add custom_components/luxtronik2/manifest.json | |
| git diff --quiet && git diff --staged --quiet || git commit -m "chore: bump version to ${{ env.VERSION }}" | |
| git push | |
| - name: Zip integration | |
| run: | | |
| cd custom_components/luxtronik2 | |
| zip -r ../../luxtronik2.zip . | |
| # Fetch the latest full release tag so pre-releases can also list every PR since then | |
| - name: Get Latest Full Release Tag | |
| id: stable_tag | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Fetches the 'latest' release (this automatically ignores pre-releases on GitHub) | |
| LATEST_TAG=$(gh api repos/${{ github.repository }}/releases/latest --jq '.tag_name') | |
| echo "PREVIOUS_STABLE=$LATEST_TAG" >> $GITHUB_ENV | |
| # Creates the release based on your choice | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: ${{ env.VERSION }} | |
| name: ${{ env.VERSION }} | |
| generate_release_notes: true | |
| # Always compare against the previous full release, so pre-release notes include | |
| # every PR merged since the last full release too | |
| previous_tag: ${{ env.PREVIOUS_STABLE }} | |
| # Prerelease is enabled (true) when you choose pre-release, and disabled (false) for a full-release | |
| prerelease: ${{ github.event.inputs.release_type == 'pre-release' }} | |
| # Ensures a full-release is actually marked as the official 'latest' on GitHub | |
| make_latest: ${{ github.event.inputs.release_type == 'full-release' && 'true' || 'false' }} | |
| files: luxtronik2.zip |