variables: # Application id of the app, should be same as id used in flatpak manifest and MetaInfo APP_ID: org.suyu_emu.suyu # Location of the flatpak manifest, root of git repository MANIFEST_PATH: $CI_PROJECT_DIR/${APP_ID}.json # Name of flatpak bundle BUNDLE: "${APP_ID}.flatpak" # Docker image to use DOCKER_REGISTRY: "docker.io/bilelmoussaoui/flatpak-github-actions" # Runtime to use, https://github.com/flatpak/flatpak-github-actions#docker-image RUNTIME_NAME: "freedesktop" # Runtime version to use RUNTIME_VRESION: "23.08" DOCKER_IMAGE: ${DOCKER_REGISTRY}:${RUNTIME_NAME}-${RUNTIME_VRESION} SCHEDULE_TASK: default stages: - setup - build - deploy # This will check for updates using external data checker and send PRs to the repo update-sources: stage: setup image: # https://github.com/flathub/flatpak-external-data-checker name: ghcr.io/flathub/flatpak-external-data-checker # Open shell rather than the bin entrypoint: [""] before_script: - git config --global user.name "${GITLAB_USER_LOGIN}" - git config --global user.email "${GITLAB_USER_EMAIL}" script: - /app/flatpak-external-data-checker --update --commit-only $MANIFEST_PATH # Creates a merge request targetting the default repo branch and sets up auto merge when pipeline succeeds - git push -o merge_request.create -o merge_request.target=${CI_DEFAULT_BRANCH} -o merge_request.merge_when_pipeline_succeeds "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" || true artifacts: paths: - $MANIFEST_PATH expire_in: 1 week rules: # Set up a pipeline schedule for this https://docs.gitlab.com/ee/ci/pipelines/schedules.html - if: $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "trigger" when: always - when: never flatpak: stage: build image: ${DOCKER_IMAGE} variables: # Stable Flathub repo RUNTIME_REPO: "https://flathub.org/repo/flathub.flatpakrepo" before_script: # Sets up the stable Flathub repository for dependencies - flatpak remote-add --user --if-not-exists flathub ${RUNTIME_REPO} script: # Sets up GPG signing - gpg --list-keys --with-keygrip - echo "allow-preset-passphrase" >> ~/.gnupg/gpg-agent.conf - gpg-connect-agent reloadagent /bye - cat $GPG_PASSPHRASE | /usr/libexec/gpg-preset-passphrase --preset $GPG_KEY_GREP - gpg --import --batch ${GPG_PRIVATE_KEY} # Build & install build dependencies - flatpak-builder build --user --install-deps-from=flathub --gpg-sign=${GPG_KEY_ID} --disable-rofiles-fuse --disable-updates --force-clean --repo=repo ${BRANCH:+--default-branch=$BRANCH} ${MANIFEST_PATH} # Generate a Flatpak bundle - flatpak build-bundle --gpg-sign=${GPG_KEY_ID} repo ${BUNDLE} --runtime-repo=${RUNTIME_REPO} ${APP_ID} ${BRANCH} - flatpak build-update-repo --gpg-sign=${GPG_KEY_ID} --generate-static-deltas --prune repo/ artifacts: paths: - repo expire_in: 1 week tags: [""] rules: - if: $CI_PIPELINE_SOURCE == "schedule" when: never - when: always - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH when: always - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH when: manual # Deploys the generated package to Gitlab pages name.gitlab.io/repo_name pages: variables: BUILD_OUTPUT_PATH: ${CI_PROJECT_DIR}/repo stage: deploy image: alpine:latest before_script: - apk add rsync # replace html assets relative path with pages absolute path - find $BUILD_OUTPUT_PATH \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i -e "s#href=\"\/#href=\"$CI_PAGES_URL/#g" -e "s#src=\"\/#src=\"$CI_PAGES_URL/#g" script: - mkdir public || true - rsync -av --exclude='public' --exclude='.git' $BUILD_OUTPUT_PATH/ public artifacts: paths: - public expire_in: 1 week rules: - if: $CI_PIPELINE_SOURCE == "schedule" when: never - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH when: always