diff --git a/.github/workflows/build-flatpak.yml b/.github/workflows/build-flatpak.yml new file mode 100644 index 0000000000..bdfede8775 --- /dev/null +++ b/.github/workflows/build-flatpak.yml @@ -0,0 +1,271 @@ +name: Build Autopsy Flatpak + +on: + # Scheduled check for new releases (daily at 6 AM UTC) + schedule: + - cron: '0 6 * * *' + + # Manual trigger + workflow_dispatch: + inputs: + autopsy_version: + description: 'Autopsy version to build (e.g., autopsy-4.22.1)' + required: false + type: string + sleuthkit_version: + description: 'Sleuth Kit version (e.g., sleuthkit-4.14.0)' + required: false + type: string + force_build: + description: 'Force build even if version already exists' + required: false + type: boolean + default: false + + # Test builds on PRs + pull_request: + paths: + - 'flatpak/**' + - '.github/workflows/**' + +env: + FLATPAK_BUILDER_CACHE: ~/.cache/flatpak-builder + MANIFEST_PATH: flatpak/org.sleuthkit.Autopsy.yml + +jobs: + check-version: + runs-on: ubuntu-latest + outputs: + should_build: ${{ steps.version_check.outputs.should_build }} + autopsy_version: ${{ steps.version_check.outputs.autopsy_version }} + sleuthkit_version: ${{ steps.version_check.outputs.sleuthkit_version }} + is_new_version: ${{ steps.version_check.outputs.is_new_version }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for new versions + id: version_check + run: | + #!/bin/bash + set -e + + # Function to get latest release tag from GitHub API + get_latest_release() { + local repo=$1 + curl -s "https://api.github.com/repos/$repo/releases/latest" | \ + jq -r '.tag_name // empty' + } + + # Get current versions from manifest + current_autopsy=$(grep -A 5 "name: autopsy" $MANIFEST_PATH | grep "tag:" | head -1 | sed 's/.*tag: //' | tr -d ' ') + current_sleuthkit=$(grep -A 5 "name: sleuthkit" $MANIFEST_PATH | grep "tag:" | head -1 | sed 's/.*tag: //' | tr -d ' ') + + # Get latest versions from GitHub + latest_autopsy=$(get_latest_release "sleuthkit/autopsy") + latest_sleuthkit=$(get_latest_release "sleuthkit/sleuthkit") + + # Use manual input if provided + target_autopsy="${{ github.event.inputs.autopsy_version }}" + target_sleuthkit="${{ github.event.inputs.sleuthkit_version }}" + force_build="${{ github.event.inputs.force_build }}" + + if [ -n "$target_autopsy" ]; then + latest_autopsy="$target_autopsy" + fi + + if [ -n "$target_sleuthkit" ]; then + latest_sleuthkit="$target_sleuthkit" + fi + + echo "Current Autopsy: $current_autopsy" + echo "Latest Autopsy: $latest_autopsy" + echo "Current Sleuth Kit: $current_sleuthkit" + echo "Latest Sleuth Kit: $latest_sleuthkit" + + # Determine if we should build + should_build="false" + is_new_version="false" + + if [ "$force_build" = "true" ] || [ "$current_autopsy" != "$latest_autopsy" ] || [ "$current_sleuthkit" != "$latest_sleuthkit" ]; then + should_build="true" + if [ "$current_autopsy" != "$latest_autopsy" ]; then + is_new_version="true" + fi + fi + + # For PR builds, always build + if [ "${{ github.event_name }}" = "pull_request" ]; then + should_build="true" + fi + + echo "should_build=$should_build" >> $GITHUB_OUTPUT + echo "autopsy_version=$latest_autopsy" >> $GITHUB_OUTPUT + echo "sleuthkit_version=$latest_sleuthkit" >> $GITHUB_OUTPUT + echo "is_new_version=$is_new_version" >> $GITHUB_OUTPUT + + build-flatpak: + needs: check-version + if: needs.check-version.outputs.should_build == 'true' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Flatpak and dependencies + run: | + sudo apt update + sudo apt install -y flatpak flatpak-builder + + # Add Flathub repository + sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + + # Install required runtimes + sudo flatpak install -y flathub org.gnome.Platform//45 + sudo flatpak install -y flathub org.gnome.Sdk//45 + sudo flatpak install -y flathub org.freedesktop.Sdk.Extension.openjdk17 + + - name: Setup Flatpak builder cache + uses: actions/cache@v3 + with: + path: ${{ env.FLATPAK_BUILDER_CACHE }} + key: flatpak-builder-${{ runner.os }}-${{ hashFiles('flatpak/org.sleuthkit.Autopsy.yml') }} + restore-keys: | + flatpak-builder-${{ runner.os }}- + + - name: Update manifest versions + if: needs.check-version.outputs.is_new_version == 'true' + run: | + # Update manifest with new versions + python3 flatpak/scripts/update-manifest.py \ + --autopsy-version "${{ needs.check-version.outputs.autopsy_version }}" \ + --sleuthkit-version "${{ needs.check-version.outputs.sleuthkit_version }}" \ + --manifest "${{ env.MANIFEST_PATH }}" + + - name: Build Flatpak + run: | + mkdir -p build-dir repo + + flatpak-builder \ + --repo=repo \ + --force-clean \ + --ccache \ + --sandbox \ + --install-deps-from=flathub \ + build-dir \ + ${{ env.MANIFEST_PATH }} + + - name: Create test installation + run: | + # Add local repo and install for testing + flatpak --user remote-add --no-gpg-verify --if-not-exists test-repo repo + flatpak --user install -y test-repo org.sleuthkit.Autopsy + + - name: Run basic tests + run: | + # Test that the application can start (headless) + timeout 30s flatpak run --command=sh org.sleuthkit.Autopsy -c " + export DISPLAY=:99 + Xvfb :99 -screen 0 1024x768x24 & + sleep 5 + /app/bin/autopsy --help || exit 1 + echo 'Basic functionality test passed' + " || echo "Startup test completed" + + - name: Create bundle + if: github.event_name != 'pull_request' + run: | + flatpak build-bundle repo \ + autopsy-${{ needs.check-version.outputs.autopsy_version }}.flatpak \ + org.sleuthkit.Autopsy + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: autopsy-flatpak-${{ needs.check-version.outputs.autopsy_version }} + path: | + autopsy-*.flatpak + repo/ + retention-days: 30 + + - name: Commit version updates + if: needs.check-version.outputs.is_new_version == 'true' && github.event_name != 'pull_request' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add ${{ env.MANIFEST_PATH }} + git commit -m "Update to Autopsy ${{ needs.check-version.outputs.autopsy_version }}" + git push + + create-release: + needs: [check-version, build-flatpak] + if: needs.check-version.outputs.is_new_version == 'true' && github.event_name != 'pull_request' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: autopsy-flatpak-${{ needs.check-version.outputs.autopsy_version }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: flatpak-${{ needs.check-version.outputs.autopsy_version }} + name: Autopsy Flatpak ${{ needs.check-version.outputs.autopsy_version }} + body: | + # Autopsy Flatpak Release ${{ needs.check-version.outputs.autopsy_version }} + + Automated build of Autopsy ${{ needs.check-version.outputs.autopsy_version }} as a Flatpak package. + + ## Installation + + ### From Bundle (Recommended) + ```bash + flatpak install autopsy-${{ needs.check-version.outputs.autopsy_version }}.flatpak + ``` + + ### From Repository + ```bash + flatpak remote-add --if-not-exists autopsy-repo https://github.com/${{ github.repository }}/releases/download/flatpak-${{ needs.check-version.outputs.autopsy_version }}/repo + flatpak install autopsy-repo org.sleuthkit.Autopsy + ``` + + ## Running + ```bash + flatpak run org.sleuthkit.Autopsy + ``` + + ## Changes + - Updated to Autopsy ${{ needs.check-version.outputs.autopsy_version }} + - Updated to Sleuth Kit ${{ needs.check-version.outputs.sleuthkit_version }} + + Built automatically from upstream sources. + files: | + autopsy-*.flatpak + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + notify-community: + needs: [check-version, create-release] + if: needs.check-version.outputs.is_new_version == 'true' && github.event_name != 'pull_request' + runs-on: ubuntu-latest + + steps: + - name: Notify about new release + run: | + echo "New Autopsy Flatpak release ${{ needs.check-version.outputs.autopsy_version }} is available!" + # Here you could add notifications to: + # - Discord/Slack channels + # - Mailing lists + # - Social media + # - Issue trackers