From 3f9456dabf2d4c476ae39250aa9e5f8babbef271 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 5 Nov 2024 10:52:21 +0900 Subject: [PATCH] Creating a template wokflow for artifacts production --- .github/workflows/build_artifacts.yml | 91 +++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/build_artifacts.yml diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml new file mode 100644 index 0000000..6a5f31b --- /dev/null +++ b/.github/workflows/build_artifacts.yml @@ -0,0 +1,91 @@ +# Variables: +# - RUNNER_TAG: optional, defines on which runner the workflow will use, default ubuntu-latest +# - DYNAMIC_MANIFEST: optional, if set it will build the manifest from header.yml and module.yml files (json not yet supported) +# - MANIFEST_FILENAME: needed, the manifest name such as net.retrodeck.retrodeck.yaml + +name: "Build Artifacts for RetroDECK main manifest" + +on: + push: + branches: + - master + workflow_dispatch: + + +jobs: + + Building_project: + runs-on: ${{ env.RUNNER_TAG || 'ubuntu-latest' }} + steps: + + # 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 + + - name: Clone repo + uses: actions/checkout@v3 + with: + submodules: 'true' + token: ${{ secrets.TRIGGER_BUILD_TOKEN }} + + - name: "Install dependencies" + run: "automation_tools/install_dependencies.sh" + + - name: "Assembilng manifest" + if: ${{ env.DYNAMIC_MANIFEST == 'true' }} + run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/assemble_manifest.sh" + + - name: "[DEBUG] Outputting manifest" + continue-on-error: true + if: ${{ env.DYNAMIC_MANIFEST == 'true' }} + run: cat ${{ env.MANIFEST_FILENAME }} + + - name: "Build flatpak" + run: | + git config --global protocol.file.allow always + flatpak-builder --user --force-clean \ + --install-deps-from=flathub \ + --install-deps-from=flathub-beta \ + --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 + + - 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: Set environment variable with current branch name + run: echo "GITHUB_REF_SLUG=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV + + - name: Get branch name + 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 }}" + body: | + # Release Notes + These are the artifacts for RetroDECK of {{ 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" + allowUpdates: true + makeLatest: true + token: ${{ secrets.TRIGGER_BUILD_TOKEN }} + continue-on-error: true \ No newline at end of file