Skip to content

fix: implement proper Flatpak package creation and GitHub Packages in… #28

fix: implement proper Flatpak package creation and GitHub Packages in…

fix: implement proper Flatpak package creation and GitHub Packages in… #28

Workflow file for this run

name: Build Flatpak
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
release:
types: [published]
workflow_dispatch:
permissions:
contents: write # Needed to upload to releases
actions: read # Needed to read workflow artifacts
packages: write # Needed to publish packages
jobs:
build-flatpak:
name: Build Flatpak Package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read version from file
id: version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT
- 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 bash-script-maker.flatpak org.securebits.bashscriptmaker
- name: Rename Bundle with Version
run: |
mv build/flatpak/bash-script-maker.flatpak BashScriptMaker-${{ steps.version.outputs.VERSION }}.flatpak
- name: Upload Flatpak Bundle as Artifact
uses: actions/upload-artifact@v4
with:
name: flatpak-bundle
path: BashScriptMaker-${{ steps.version.outputs.VERSION }}.flatpak
retention-days: 7
- name: Upload to GitHub Packages (Container Registry)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
# Login to GitHub Container Registry
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# Create OCI image from Flatpak bundle
mkdir -p oci-build
cd oci-build
# Create a simple Dockerfile to package the Flatpak
cat > Dockerfile << EOF
FROM scratch
COPY BashScriptMaker-${{ steps.version.outputs.VERSION }}.flatpak /BashScriptMaker.flatpak
LABEL org.opencontainers.image.title="Bash-Script-Maker Flatpak"
LABEL org.opencontainers.image.description="Flatpak package for Bash-Script-Maker"
LABEL org.opencontainers.image.version="${{ steps.version.outputs.VERSION }}"
LABEL org.opencontainers.image.source="https://github.com/securebitsorg/bash-script-maker"
EOF
# Copy Flatpak bundle
cp ../BashScriptMaker-${{ steps.version.outputs.VERSION }}.flatpak .
# Build and push container
docker build -t ghcr.io/securebitsorg/bash-script-maker-flatpak:${{ steps.version.outputs.VERSION }} .
docker push ghcr.io/securebitsorg/bash-script-maker-flatpak:${{ steps.version.outputs.VERSION }}
# Tag as latest
docker tag ghcr.io/securebitsorg/bash-script-maker-flatpak:${{ steps.version.outputs.VERSION }} ghcr.io/securebitsorg/bash-script-maker-flatpak:latest
docker push ghcr.io/securebitsorg/bash-script-maker-flatpak:latest
- name: Upload to Latest Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: BashScriptMaker-${{ steps.version.outputs.VERSION }}.flatpak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release for Tags
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
with:
files: BashScriptMaker-${{ steps.version.outputs.VERSION }}.flatpak
body: |
## Flatpak Package für Version ${{ steps.version.outputs.VERSION }}
### Installation:
```bash
# Direkt installieren
flatpak install --user BashScriptMaker-${{ steps.version.outputs.VERSION }}.flatpak
# Oder über Container Registry
docker pull ghcr.io/securebitsorg/bash-script-maker-flatpak:${{ steps.version.outputs.VERSION }}
```
### Ausführen:
```bash
flatpak run org.securebits.bashscriptmaker
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}