Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI #4

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build

on:
push:
branches-ignore:
- rebase-pull-request**
- cherry-pick-rebase-pull-request**
- flatpak-repository
pull_request:

concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: |
DEBIAN_FRONTEND=noninteractive sudo apt-get update -y
sudo apt-get install --no-install-recommends -y \
icoutils \
flatpak \
flatpak-builder \
elfutils
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Cache Flatpak builder
id: cache-flatpak-builder
uses: actions/cache@v3
with:
path: .flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ hashFiles('com.jagex.Launcher.yaml') }}
- name: Build Flatpak
run: |
./build.sh
86 changes: 86 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release

on:
push:
branches:
- main
tags:
- v*

concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: false

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout Flatpak repository
uses: actions/checkout@v4
with:
fetch-depth: 0
branch: flatpak-repository
path: repo
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Setup GPG
id: gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Install dependencies
run: |
DEBIAN_FRONTEND=noninteractive sudo apt-get update -y
sudo apt-get install --no-install-recommends -y \
icoutils \
flatpak \
flatpak-builder \
elfutils
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Cache Flatpak builder
id: cache-flatpak-builder
uses: actions/cache@v3
with:
path: .flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ hashFiles('com.jagex.Launcher.yaml') }}
- name: Build Flatpak
run: |
./build.sh sign
# Now we have a com.jagex.Launcher.flatpak file in the root of the repository and an updated repo/ repository.
- name: Create release
id: create-release
uses: actions/create-release@v1
with:
tag_name: ${{ github.run_id }}${{ github.run_attempt }}
release_name: ${{ github.run_id }}${{ github.run_attempt }}
draft: false
prerelease: false
- name: Upload Flatpak
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: com.jagex.Launcher.flatpak
asset_name: com.jagex.Launcher.flatpak
asset_content_type: application/x-flatpak
- name: Push Flatpak repository
run: |
git config --global user.name "GitHub Actions"
git config --global user.email 'bot@noreply.github.com'
- name: Commit changes to databases
run: |
cd repo
git add -A
git commit --signoff -m "Update com.jagex.Launcher"
git push
env:
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ out/
export/
resources/icons/*.png
*.flatpak
repo/
bak/
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ This is a Flatpak package for the Jagex Launcher. It packages the [official upst

### Installing the Launcher

It is unlikely that Flathub would accept a proprietary application like the Jagex Launcher, paricularly one that is wrapped in Wine. As such, this Flatpak is not available on Flathub. You can install it by downloading the [latest release](https://github.com/USA-RedDragon/jagex-launcher-flatpak/releases/latest) and installing it with the following command:
It is unlikely that Flathub would accept a proprietary application like the Jagex Launcher, paricularly one that is wrapped in Wine. As such, this Flatpak is not available on Flathub.

### Flatpak Remote

You can install it by adding the remote and installing it with the following commands:

```bash
flatpak remote-add --if-not-exists usareddragon https://jagexlauncher.flatpak.mcswain.dev/.flatpakrepo
flatpak install --user usareddragon com.jagex.Launcher
```

### Manual Download

You can install it by downloading the [latest release](https://github.com/USA-RedDragon/jagex-launcher-flatpak/releases/latest) and installing it with the following command:

```bash
flatpak install --user com.jagex.Launcher.flatpak
Expand Down
47 changes: 44 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

set -euo pipefail

# Dosign should be 1 if $1 is set
DOSIGN=0
if [[ ! -z ${1+x} ]]; then
DOSIGN=1
fi

# renovate: datasource=git-tags depName=https://gitlab.com/freedesktop-sdk/freedesktop-sdk.git
FREEDESKTOP_SDK_GIT_VERSION=freedesktop-sdk-23.08.6
FREEDESKTOP_SDK_VERSION=$(echo ${FREEDESKTOP_SDK_GIT_VERSION} | cut -d'-' -f3 | cut -d'.' -f1-2)
Expand Down Expand Up @@ -33,8 +39,43 @@ if [[ ${HAS_NVIDIA} -eq 1 ]]; then
org.freedesktop.Platform.GL32.nvidia-${NVIDIA_VERISON}/x86_64
fi

flatpak-builder --user --force-clean out com.jagex.Launcher.yaml
flatpak build-export export out
flatpak build-bundle -vv export com.jagex.Launcher.flatpak com.jagex.Launcher --repo-url=https://flatpak.mcswain.dev --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
REPO_ARGS=""
GPG_ARGS=""
if [[ ${DOSIGN} -eq 1 ]]; then
REPO_ARGS="--repo ./repo"
GPG_ARGS="--gpg-sign=7ADE1CA57A2E2272"
fi

flatpak-builder ${REPO_ARGS} ${GPG_ARGS} --default-branch=stable --user --ccache --force-clean out com.jagex.Launcher.yaml
if [[ ${DOSIGN} -eq 0 ]]; then
flatpak build-export repo out stable
fi
flatpak build-update-repo ${GPG_ARGS} repo --title="Jagex Launcher" --generate-static-deltas --default-branch=stable

flatpak build-bundle ${GPG_ARGS} --repo-url=https://jagexlauncher.flatpak.mcswain.dev --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo repo com.jagex.Launcher.flatpak com.jagex.Launcher stable &
PID=$!

COUNTER=0
# Timeout after 1 hour
MAX_COUNTER=3600
while kill -0 $PID 2> /dev/null; do
NUM_DOT=$((COUNTER%5))
DOTS=$(printf '.%.0s' $(seq 0 $NUM_DOT))
# Overwrite the line
echo "Exporting flatpak${DOTS}"
COUNTER=$((COUNTER+1))
if [[ ${COUNTER} -gt ${MAX_COUNTER} ]]; then
echo "Timed out after 1 hour"
exit 1
fi
sleep 1
done

# Check exit code
wait $PID
if [[ $? -ne 0 ]]; then
echo "Failed to export flatpak"
exit 1
fi

echo "Built flatpak to com.jagex.Launcher.flatpak"