From d774c2ee459e5c11b9c56a97276d149be6b2b7d4 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 5 Nov 2024 11:07:08 +0900 Subject: [PATCH] Repo init --- .github/workflows/build_artifacts.yml | 85 +++++++++++++--------- .github/workflows/install_dependencies.yml | 19 +++++ .gitignore | 2 + automation_tools/install_dependencies.sh | 33 +++++++++ automation_tools/update_from_upstream.sh | 4 + flathub.json | 3 + 6 files changed, 113 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/install_dependencies.yml create mode 100644 .gitignore create mode 100755 automation_tools/install_dependencies.sh create mode 100755 automation_tools/update_from_upstream.sh create mode 100644 flathub.json diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml index 6a5f31b..9d7643a 100644 --- a/.github/workflows/build_artifacts.yml +++ b/.github/workflows/build_artifacts.yml @@ -6,23 +6,30 @@ name: "Build Artifacts for RetroDECK main manifest" on: - push: - branches: - - master workflow_dispatch: +env: + RUNNER_TAG: ${{ env.RUNNER_TAG || 'ubuntu-latest' }} + DATE: ${{ github.run_id }} + MANIFEST_FILENAME: ${{ env.MANIFEST_FILENAME || '' }} jobs: - Building_project: - runs-on: ${{ env.RUNNER_TAG || 'ubuntu-latest' }} + Check-variables: + runs-on: ubuntu-latest steps: + - name: Check MANIFEST_FILENAME is set + run: | + if [ -z "${{ env.MANIFEST_FILENAME }}" ]; then + echo "Error: MANIFEST_FILENAME is not set. This is required for the pipeline to run." + exit 1 + fi - # Circumventing this bug: https://github.com/flatpak/flatpak-builder/issues/317 - # - name: Remove stuck mounts - # run: sudo umount -f /home/ubuntu/solarus-runner/_work/RetroDECK-solarus/RetroDECK-solarus/.flatpak-builder/rofiles/* - # continue-on-error: true - + Building-project: + needs: Check-variables + runs-on: ${{ env.RUNNER_TAG }} + + steps: - name: Clone repo uses: actions/checkout@v3 with: @@ -30,16 +37,27 @@ jobs: token: ${{ secrets.TRIGGER_BUILD_TOKEN }} - name: "Install dependencies" - run: "automation_tools/install_dependencies.sh" + uses: RetroDECK/components-template/.github/workflows/install_dependencies.yml@main - - name: "Assembilng manifest" + - name: "Assembling manifest" if: ${{ env.DYNAMIC_MANIFEST == 'true' }} - run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/assemble_manifest.sh" + run: | + if [ -f "${GITHUB_WORKSPACE}/automation_tools/assemble_manifest.sh" ]; then + /bin/bash "${GITHUB_WORKSPACE}/automation_tools/assemble_manifest.sh" + else + echo "Manifest assembly script not found." + exit 1 + fi - name: "[DEBUG] Outputting manifest" - continue-on-error: true if: ${{ env.DYNAMIC_MANIFEST == 'true' }} - run: cat ${{ env.MANIFEST_FILENAME }} + run: | + if [ -f "${{ env.MANIFEST_FILENAME }}" ]; then + cat "${{ env.MANIFEST_FILENAME }}" + else + echo "ERROR: manifest file not found: ${{ env.MANIFEST_FILENAME }}" + exit 1 + fi - name: "Build flatpak" run: | @@ -47,22 +65,29 @@ jobs: flatpak-builder --user --force-clean \ --install-deps-from=flathub \ --install-deps-from=flathub-beta \ - --repo=${GITHUB_WORKSPACE}/artifacts-repo \ - "${GITHUB_WORKSPACE}"/artifacts-build-dir \ + --repo="${GITHUB_WORKSPACE}/artifacts-repo" \ + "${GITHUB_WORKSPACE}/artifacts-build-dir" \ "${{ env.MANIFEST_FILENAME }}" - name: "Exporting dir tree" id: tree - run: tree -H ./ > ${GITHUB_WORKSPACE}/tree.html + run: | + tree -H ./ > ${GITHUB_WORKSPACE}/tree.html + echo "Directory tree exported to tree.html" - - name: Create Artifact for RetroDECK - run: | + - name: "Create Artifact for RetroDECK" + run: | tar -czf ${GITHUB_WORKSPACE}/RetroDECK-Artifact.tar.gz -C ${GITHUB_WORKSPACE}/artifacts-build-dir . hash=($(sha256sum ${GITHUB_WORKSPACE}/RetroDECK-Artifact.tar.gz)) echo $hash > ${GITHUB_WORKSPACE}/RetroDECK-Artifact-cooker.sha - mv -f RetroDECK-Artifact-cooker.* ${{ secrets.ARTIFACT_REPO }} - continue-on-error: true - timeout-minutes: 1440 + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: RetroDECK-Artifacts + path: | + ${GITHUB_WORKSPACE}/RetroDECK-Artifact.tar.gz + ${GITHUB_WORKSPACE}/tree.html - name: Set environment variable with current branch name run: echo "GITHUB_REF_SLUG=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV @@ -71,21 +96,15 @@ jobs: id: branch_name run: echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's|refs/heads/||')" >> $GITHUB_ENV - - name: Get date - id: date - run: echo "DATE=$(date +'%d%m%y.%S')" >> $GITHUB_ENV - - name: Publish the artifacts in a new release uses: ncipollo/release-action@v1 with: - tag: "${{ github.ref_name }}-${{ github.event.date || github.run_id }}" + tag: "${{ github.ref_name }}-${{ github.run_id }}" body: | # Release Notes - These are the artifacts for RetroDECK of {{ github.repository }}, built from commit: ${{ github.repository }}@${{ github.sha }}. + These are the artifacts for RetroDECK from ${{ github.repository }}, built from commit: ${{ github.repository }}@${{ github.sha }}. On branch [${{ github.ref_name }}](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}). - - artifacts: "RetroDECK-Artifact.tar.gz, tree.html" + artifacts: "${GITHUB_WORKSPACE}/RetroDECK-Artifact.tar.gz, ${GITHUB_WORKSPACE}/tree.html" allowUpdates: true makeLatest: true - token: ${{ secrets.TRIGGER_BUILD_TOKEN }} - continue-on-error: true \ No newline at end of file + token: ${{ secrets.TRIGGER_BUILD_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/install_dependencies.yml b/.github/workflows/install_dependencies.yml new file mode 100644 index 0000000..f97f0fd --- /dev/null +++ b/.github/workflows/install_dependencies.yml @@ -0,0 +1,19 @@ +name: "Install dependencies" + +on: + workflow_dispatch: + workflow_call: + +jobs: + install-dependencies: + runs-on: ubuntu-latest + steps: + - name: "Install dependencies" + run: | + echo "Starting dependency installation..." + if [ -f "${GITHUB_WORKSPACE}/automation_tools/install_dependencies.sh" ]; then + /bin/bash "${GITHUB_WORKSPACE}/automation_tools/install_dependencies.sh" + else + echo "Dependency installation script not found." + exit 1 + fi \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c267f68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build-dir/ +.flatpak-builder/ diff --git a/automation_tools/install_dependencies.sh b/automation_tools/install_dependencies.sh new file mode 100755 index 0000000..882c666 --- /dev/null +++ b/automation_tools/install_dependencies.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# This script is installing the required dependencies to correctly run the pipeline and build the flatpak + +unset pkg_mgr + +# rpm-ostree must be checked before dnf because a dnf (wrapper) command also works on rpm-ostree distros (not what we want) +for potential_pkg_mgr in apt pacman rpm-ostree dnf; do + command -v "$potential_pkg_mgr" &> /dev/null && pkg_mgr="$potential_pkg_mgr" && break +done + +case "$pkg_mgr" in + apt) + sudo add-apt-repository -y ppa:flatpak/stable + sudo apt update + sudo apt install -y flatpak flatpak-builder p7zip-full xmlstarlet bzip2 curl jq + ;; + pacman) + sudo pacman -Syu --noconfirm flatpak flatpak-builder p7zip xmlstarlet bzip2 + ;; + rpm-ostree) + echo "When using a distro with rpm-ostree, you shouldn't build directly on the host. Try using a distrobox." + exit 1 + ;; + dnf) + sudo dnf install -y flatpak flatpak-builder p7zip p7zip-plugins xmlstarlet bzip2 curl + ;; + *) + echo "Package manager $pkg_mgr not supported. Please open an issue." + ;; +esac + +flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo \ No newline at end of file diff --git a/automation_tools/update_from_upstream.sh b/automation_tools/update_from_upstream.sh new file mode 100755 index 0000000..5b6a7fe --- /dev/null +++ b/automation_tools/update_from_upstream.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +git fetch https://github.com/flathub/net.rpcs3.RPCS3 master # Fetch the latest changes from the remote master branch +git merge FETCH_HEAD # Merge the fetched changes into your current branch \ No newline at end of file diff --git a/flathub.json b/flathub.json new file mode 100644 index 0000000..637604e --- /dev/null +++ b/flathub.json @@ -0,0 +1,3 @@ +{ + "only-arches": ["x86_64"] +}