name: Release on: push: tags: - 'v*.*.*' permissions: contents: write jobs: create-release: name: Create Release runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout Code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Validate Tag Format run: | if [[ ! "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "❌ Invalid tag format. Expected: v1.2.3" exit 1 fi echo "✅ Valid semantic version tag: ${{ github.ref_name }}" - name: Extract Version id: version run: | VERSION=${{ github.ref_name }} VERSION_NUMBER=${VERSION#v} echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "version_number=${VERSION_NUMBER}" >> $GITHUB_OUTPUT - name: Update Manifest Version run: | sed -i 's/"version": ".*"/"version": "${{ steps.version.outputs.version_number }}"/' custom_components/adguard_hub/manifest.json - name: Run Tests Before Release run: | python -m pip install --upgrade pip pip install homeassistant==2025.9.4 pip install -r requirements-dev.txt mkdir -p custom_components touch custom_components/__init__.py python -m pytest tests/ -v --tb=short - name: Create Release Archive run: | cd custom_components zip -r ../adguard-control-hub-${{ steps.version.outputs.version_number }}.zip adguard_hub/ - name: Generate Changelog id: changelog run: | PREVIOUS_TAG=$(git tag --sort=-version:refname | head -2 | tail -1 2>/dev/null || echo "") if [ -z "$PREVIOUS_TAG" ]; then echo "changelog=Initial release of AdGuard Control Hub" >> $GITHUB_OUTPUT else echo "changelog=Changes since $PREVIOUS_TAG" >> $GITHUB_OUTPUT fi - name: Success Message run: | echo "🎉 Release ${{ steps.version.outputs.version }} created!" echo "📦 Archive: adguard-control-hub-${{ steps.version.outputs.version_number }}.zip"