fix: improve Flatpak version appearance and correct application name #7
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: Auto Release on Push | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - 'README.md' | |
| - 'docs/**' | |
| - '*.md' | |
| permissions: | |
| contents: write # Needed to create releases and push tags | |
| actions: read # Needed to read workflow artifacts | |
| packages: write # Needed for package publishing | |
| id-token: write # Needed for PyPI trusted publishing (optional) | |
| jobs: | |
| check-for-release: | |
| name: Check for Release Triggers | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| release_type: ${{ steps.check.outputs.release_type }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check commit message for release triggers | |
| id: check | |
| run: | | |
| COMMIT_MSG="${{ github.event.head_commit.message }}" | |
| echo "Commit message: $COMMIT_MSG" | |
| # Aktuelle Version lesen | |
| CURRENT_VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0") | |
| echo "Current version: $CURRENT_VERSION" | |
| # Release-Typ bestimmen basierend auf Commit-Message | |
| SHOULD_RELEASE="false" | |
| RELEASE_TYPE="" | |
| NEW_VERSION="" | |
| if [[ "$COMMIT_MSG" =~ ^(feat|feature)(\(.+\))?!: ]] || [[ "$COMMIT_MSG" =~ BREAKING[[:space:]]CHANGE ]]; then | |
| # Major release (breaking change) | |
| SHOULD_RELEASE="true" | |
| RELEASE_TYPE="major" | |
| NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1+1".0.0"}') | |
| elif [[ "$COMMIT_MSG" =~ ^(feat|feature)(\(.+\))?: ]]; then | |
| # Minor release (new feature) | |
| SHOULD_RELEASE="true" | |
| RELEASE_TYPE="minor" | |
| NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2+1".0"}') | |
| elif [[ "$COMMIT_MSG" =~ ^(fix|bugfix)(\(.+\))?: ]]; then | |
| # Patch release (bug fix) | |
| SHOULD_RELEASE="true" | |
| RELEASE_TYPE="patch" | |
| NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2"."$3+1}') | |
| elif [[ "$COMMIT_MSG" =~ \[release\] ]]; then | |
| # Manueller Release-Trigger | |
| SHOULD_RELEASE="true" | |
| RELEASE_TYPE="patch" | |
| NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2"."$3+1}') | |
| elif [[ "$COMMIT_MSG" =~ \[major\] ]]; then | |
| SHOULD_RELEASE="true" | |
| RELEASE_TYPE="major" | |
| NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1+1".0.0"}') | |
| elif [[ "$COMMIT_MSG" =~ \[minor\] ]]; then | |
| SHOULD_RELEASE="true" | |
| RELEASE_TYPE="minor" | |
| NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2+1".0"}') | |
| fi | |
| echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT | |
| echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "Should release: $SHOULD_RELEASE" | |
| echo "Release type: $RELEASE_TYPE" | |
| echo "New version: $NEW_VERSION" | |
| create-release: | |
| name: Create Automatic Release | |
| needs: check-for-release | |
| runs-on: ubuntu-latest | |
| if: needs.check-for-release.outputs.should_release == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| - name: Update version files | |
| run: | | |
| NEW_VERSION="${{ needs.check-for-release.outputs.version }}" | |
| # VERSION-Datei aktualisieren | |
| echo "$NEW_VERSION" > VERSION | |
| # __version__.py aktualisieren | |
| cat > __version__.py << EOF | |
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Version information for Bash-Script-Maker | |
| """ | |
| __version__ = "$NEW_VERSION" | |
| __version_info__ = ($(echo $NEW_VERSION | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1, \2, \3/')) | |
| EOF | |
| # pyproject.toml aktualisieren | |
| sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" pyproject.toml | |
| - name: Generate release notes | |
| id: release_notes | |
| run: | | |
| NEW_VERSION="${{ needs.check-for-release.outputs.version }}" | |
| RELEASE_TYPE="${{ needs.check-for-release.outputs.release_type }}" | |
| COMMIT_MSG="${{ github.event.head_commit.message }}" | |
| # Basis Release-Notes erstellen | |
| cat > release_notes.txt << EOF | |
| ## Version $NEW_VERSION | |
| **Release-Typ:** $RELEASE_TYPE | |
| ### Änderungen | |
| $COMMIT_MSG | |
| ### Installation | |
| \`\`\`bash | |
| # Via pip | |
| pip install bash-script-maker==$NEW_VERSION | |
| # Via Flatpak | |
| flatpak install BashScriptMaker-$NEW_VERSION.flatpak | |
| # Aus Quellcode | |
| git clone https://github.com/securebitsorg/bash-script-maker.git | |
| cd bash-script-maker | |
| git checkout v$NEW_VERSION | |
| ./install.sh | |
| \`\`\` | |
| ### Artefakte | |
| - Python Wheel (.whl) | |
| - Source Distribution (.tar.gz) | |
| - Flatpak Bundle (.flatpak) | |
| - Vollständiger Quellcode | |
| EOF | |
| echo "Release-Notes erstellt für Version $NEW_VERSION" | |
| - name: Commit version changes | |
| run: | | |
| NEW_VERSION="${{ needs.check-for-release.outputs.version }}" | |
| git add VERSION __version__.py pyproject.toml | |
| git commit -m "chore: bump version to $NEW_VERSION [skip ci]" | |
| - name: Create and push tag | |
| run: | | |
| NEW_VERSION="${{ needs.check-for-release.outputs.version }}" | |
| git tag -a "v$NEW_VERSION" -m "Automatic release v$NEW_VERSION" | |
| git push origin main | |
| git push origin "v$NEW_VERSION" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-for-release.outputs.version }} | |
| name: Release ${{ needs.check-for-release.outputs.version }} | |
| body_path: release_notes.txt | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-and-upload: | |
| name: Build and Upload Assets | |
| needs: [check-for-release, create-release] | |
| runs-on: ubuntu-latest | |
| if: needs.check-for-release.outputs.should_release == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.check-for-release.outputs.version }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install twine wheel setuptools | |
| - name: Build Python packages | |
| run: | | |
| python setup.py sdist bdist_wheel | |
| - name: Create source archive | |
| run: | | |
| VERSION=${{ needs.check-for-release.outputs.version }} | |
| git archive --format=tar.gz --prefix=bash-script-maker-$VERSION/ HEAD > bash-script-maker-$VERSION-source.tar.gz | |
| - name: Upload to release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-for-release.outputs.version }} | |
| files: | | |
| dist/*.whl | |
| dist/*.tar.gz | |
| bash-script-maker-${{ needs.check-for-release.outputs.version }}-source.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-flatpak: | |
| name: Build Flatpak | |
| needs: [check-for-release, create-release] | |
| runs-on: ubuntu-latest | |
| if: needs.check-for-release.outputs.should_release == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.check-for-release.outputs.version }} | |
| - name: Set up Flatpak builder | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y flatpak flatpak-builder | |
| flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | |
| - name: Clear Flatpak cache | |
| run: | | |
| rm -rf ~/.cache/flatpak-builder || true | |
| - name: Create build directory and files | |
| run: | | |
| mkdir -p build/flatpak | |
| cp bash_script_maker_flatpak.py build/flatpak/ | |
| cp flatpak/org.securebits.bashscriptmaker.appdata.xml build/flatpak/ | |
| # Create the correct manifest | |
| cat > build/flatpak/org.securebits.bashscriptmaker.yml << 'EOF' | |
| app-id: org.securebits.bashscriptmaker | |
| runtime: org.freedesktop.Platform | |
| runtime-version: '23.08' | |
| sdk: org.freedesktop.Sdk | |
| command: bash-script-maker | |
| finish-args: | |
| - --share=ipc | |
| - --socket=wayland | |
| - --socket=x11 | |
| - --socket=pulseaudio | |
| - --device=dri | |
| - --filesystem=home | |
| - --filesystem=host | |
| - --talk-name=org.freedesktop.Notifications | |
| modules: | |
| - name: bash-script-maker | |
| buildsystem: simple | |
| build-commands: | |
| - mkdir -p /app/bin | |
| - cp bash_script_maker_flatpak.py /app/bin/bash-script-maker | |
| - chmod +x /app/bin/bash-script-maker | |
| sources: | |
| - type: dir | |
| path: . | |
| EOF | |
| - name: Build Flatpak | |
| run: | | |
| cd build/flatpak | |
| flatpak-builder --user --install-deps-from=flathub --force-clean --repo=repo build-dir org.securebits.bashscriptmaker.yml | |
| - name: Create Flatpak Bundle | |
| run: | | |
| cd build/flatpak | |
| flatpak build-bundle repo BashScriptMaker-${{ needs.check-for-release.outputs.version }}.flatpak org.securebits.bashscriptmaker | |
| - name: Upload Flatpak to release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-for-release.outputs.version }} | |
| files: build/flatpak/BashScriptMaker-${{ needs.check-for-release.outputs.version }}.flatpak | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: [check-for-release, build-and-upload] | |
| runs-on: ubuntu-latest | |
| if: needs.check-for-release.outputs.should_release == 'true' && !contains(needs.check-for-release.outputs.version, '-') | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.check-for-release.outputs.version }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install twine wheel setuptools | |
| - name: Build packages | |
| run: python setup.py sdist bdist_wheel | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| skip-existing: true |