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

Backend for auto-updating APK #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

rtsisyk
Copy link
Member

@rtsisyk rtsisyk commented Feb 9, 2024

curl -vv -H 'x-om-appversion: 2022.08.01-1-Web' http://localhost:59830/releases
{
	"published_at": "2024-02-06T15:08:00Z",
	"code": 24020611,
	"news": {
		"en-US": "<TEXT>"
	},
	"apk": {
		"name": "OrganicMaps-24020611-web-release.apk",
		"size": 62334329,
		"url": "https://github.com/organicmaps/organicmaps/releases/download/2024.02.06-11-android/OrganicMaps-24020611-web-release.apk"
	}
}

```bash
curl -vv -H 'x-om-appversion: 2022.08.01-1-Web' http://localhost:59830/releases
```

```json
{
    "published_at": "2024-02-06T15:08:00Z",
    "code": 24020611,
    "news": {
        "en-US": "<TEXT>"
    },
    "apk": {
        "name": "OrganicMaps-24020611-web-release.apk",
        "size": 62334329,
        "url": "https://github.com/organicmaps/organicmaps/releases/download/2024.02.06-11-android/OrganicMaps-24020611-web-release.apk"
    }
}
```

Signed-off-by: Roman Tsisyk <[email protected]>
@rtsisyk rtsisyk force-pushed the github-releases-updater branch from f21156b to 1f49ae1 Compare February 9, 2024 18:33
Copy link
Member

@biodranik biodranik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Введём новый app id или переименуем web? Переименование поломает текущих пользователей.

const GITHUB_RELEASES_URL: string = 'https://api.github.com/repos/organicmaps/organicmaps/releases';
// https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api?apiVersion=2022-11-28#authenticating-with-a-personal-access-token
const GITHUB_BEARER_TOKEN: string =
'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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может лучше его из секретов подтягивать? Мало ли опенсорснем потом? Тогда лучше перегенерить.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я посмотрю как убрать в секреты. Вообще пока кажется, что работает даже без него.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда убрать, если не нужно. Релизы же публичные, ключ тоже тогда публичный может быть или вообще ненужен.

// 2022.11.20 for iOS versions released before November 21 (without donate menu)
// 2022.11.24-4-ios for newer iOS versions (with donate menu)
// 2022.12.24-10-Google for Android
// 2022.12.24-10-Google-beta for Android
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Web-beta supported?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'2022.08.23-5-Google-debug',
'2022.08.23-1-fdroid-beta',
'2022.08.23-1-fdroid-debug',
'2022.08.23-1-web-beta',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот надо поддерживать.

Или ввести новый флейвор, придумать хорошее название и сделать другой app id, чтобы ставился рядом с уже имеющимися fdroid и web и google и мог их заменить легко. Может даже импортнуть метки автоматом.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Текущий PR добавляет проверку релизов на GitHub. На GitHub выкладывается "web-release". Ничего другого туда не выкладывается.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Будет работать сейчас, после переименования?

@rtsisyk
Copy link
Member Author

rtsisyk commented Feb 10, 2024

Введём новый app id или переименуем web? Переименование поломает текущих пользователей.

Это отдельная проблема, которая никак не затрагивается в этом PR.

@biodranik
Copy link
Member

Это отдельная проблема, которая никак не затрагивается в этом PR.

Мы просто так тратим время, или решаем задачу, как дать людям замену версии в фдроиде? Удаление приложения (с удалением меток), чтобы установить его же версию из другого стора — не сработает, сам же понимаешь.

@rtsisyk
Copy link
Member Author

rtsisyk commented Feb 11, 2024

Это отдельная проблема, которая никак не затрагивается в этом PR.

Мы просто так тратим время, или решаем задачу, как дать людям замену версии в фдроиде? Удаление приложения (с удалением меток), чтобы установить его же версию из другого стора — не сработает, сам же понимаешь.

Я пришлю PR в основную репу. Давай здесь закончим хотя бы с автообновлением web. Потом посмотрим стоит ли эту APK совать юзерам в F-Droid напрямую или надо еще что-нибудь там сделать. Может быть какую-нибудь магическую кнопку, которая сама всё поставит и мигрирует. Посмотри плз формат json в api - это будет трудно менять. Я добавил то, что технически нужно.

const GITHUB_RELEASES_URL: string = 'https://api.github.com/repos/organicmaps/organicmaps/releases';
// https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api?apiVersion=2022-11-28#authenticating-with-a-personal-access-token
const GITHUB_BEARER_TOKEN: string =
'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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда убрать, если не нужно. Релизы же публичные, ключ тоже тогда публичный может быть или вообще ненужен.

src/releases.ts Show resolved Hide resolved
type?: string;
apk: {
url: string;
name: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что будет в имени?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Название файла. Пока не уверен что прям остро необходимо, может не понадобится.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filename тогда?

Что там ещё есть полезного?

src/releases.ts Show resolved Hide resolved
published_at: Date;
draft: boolean;
prerelease: boolean;
body: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это описание воцнью на гитхабе? В каком формате? Ссылка на него есть?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это текст из релиза на гитхабе в формате markdown текста.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Херово что маркдаун, у нас же нет рендерера на девайсе, верно?
Если простого решения нет, то придётся присылать ссылку на гитхаб страницу с этим текстом.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Рендерить маркдаун пока не будем, верно?

const appVersion = parseAppVersion(request.headers.get('x-om-appversion'));
if (!appVersion) return new Response('Unknown app version', { status: 400 });

// The release version doesn't have `-release` suffix, thus type should be `undefined`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пояснишь, о каких версиях речь? У нас же много разных билдов и сборок, плюс не забывай, что все, кто нас форкает, будут тоже автоматом стучаться на мета сервер с их собственными версиями и названиями. Мы видели их уже в юзер агентах.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Релизные версии не имеют суффикса "-Release" в версии, поэтому type == undefined => "release".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А если в type мусор от всяких форков? Лучше явно проверять на наши типы.

@@ -18,6 +18,22 @@ describe('parseDataVersion', () => {
test('', () => expect(parseDataVersion(null)).toEqual(null));
});

describe('parseApkName', () => {
const tests: { [key: string]: object | null } = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В моём PR было больше тестов на не поддерживаемые кейзы https://github.com/organicmaps/meta/pull/65/files#diff-4a1ee83ef3a98a79eeaeb2506070a86479a12bad67c28ba34045f71159794373R35

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разве там был парсинг имени APK?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Там тесты на кривые x-om-appversion.

@biodranik
Copy link
Member

@rtsisyk давай проверим, что работает с новой веб апк и замержим?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants