Skip to content

Commit

Permalink
Description support
Browse files Browse the repository at this point in the history
  • Loading branch information
EricKotato committed May 16, 2020
1 parent ab2c801 commit 0ec5a1c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 15 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/appimage-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,11 @@ jobs:
TELETHON_API_ID: ${{ secrets.TELETHON_API_ID }}
TELETHON_API_HASH: ${{ secrets.TELETHON_API_HASH }}
TELETHON_SESSION: ${{ secrets.TELETHON_SESSION }}
run: python3 buildscripts/scripts/uploader.py "@ktgbuilds" "${{ env.REPO_NAME }}/artifact/${{ env.ARTIFACT_NAME }}"
run: >
python3 buildscripts/scripts/uploader.py
"@ktgbuilds"
"${{ env.REPO_NAME }}/artifact/${{ env.ARTIFACT_NAME }}"
"${{ github.event.client_payload.options.description }}"
- name: Parse built version.
if: >
Expand Down Expand Up @@ -702,4 +706,8 @@ jobs:
TELETHON_API_ID: ${{ secrets.TELETHON_API_ID }}
TELETHON_API_HASH: ${{ secrets.TELETHON_API_HASH }}
TELETHON_SESSION: ${{ secrets.TELETHON_SESSION }}
run: python3 buildscripts/scripts/uploader.py "@ktghbcfiles" "${{ env.REPO_NAME }}/tappimageupd${{ env.PACKER_VERSION }}"
run: >
python3 buildscripts/scripts/uploader.py
"@ktghbcfiles"
"${{ env.REPO_NAME }}/tappimageupd${{ env.PACKER_VERSION }}"
"${{ github.event.client_payload.options.description }}"
21 changes: 16 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,25 @@ jobs:
console.log("Current description:");
console.log(context.payload.release.body);
let descriptionArray = context.payload.release.body.trim().split("\n\n");
let [description, params] = ["", ""];
if (descriptionArray.length == 1) {
params = descriptionArray[0].trim();
} else if (descriptionArray.length >= 2) {
params = descriptionArray[descriptionArray.length-1].trim();
description = descriptionArray.slice(0, -1).join("\n\n").trim();
}
let requestParams = {
ref: parseRef(context.payload.release.body),
ref: parseRef(params),
display_version: context.payload.release.tag_name,
release_url: context.payload.release.upload_url,
update: parseUpdate(context.payload.release.body),
packer: parsePacker(context.payload.release.body),
telegram: parseTelegramUploader(context.payload.release.body),
installer: parseInstaller(context.payload.release.body),
update: parseUpdate(params),
packer: parsePacker(params),
telegram: parseTelegramUploader(params),
installer: parseInstaller(params),
description: description,
};
console.log("Parsed parameters:");
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/win-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ jobs:
TELETHON_API_ID: ${{ secrets.TELETHON_API_ID }}
TELETHON_API_HASH: ${{ secrets.TELETHON_API_HASH }}
TELETHON_SESSION: ${{ secrets.TELETHON_SESSION }}
run: python buildscripts/scripts/uploader.py "@ktgbuilds" "${{ env.REPO_NAME }}/artifact/${{ env.ARTIFACT_NAME }}"
run: >
python buildscripts/scripts/uploader.py
"@ktgbuilds"
"${{ env.REPO_NAME }}/artifact/${{ env.ARTIFACT_NAME }}"
"${{ github.event.client_payload.options.description }}"
- name: Make installer.
if: >
Expand Down Expand Up @@ -436,7 +440,11 @@ jobs:
TELETHON_API_ID: ${{ secrets.TELETHON_API_ID }}
TELETHON_API_HASH: ${{ secrets.TELETHON_API_HASH }}
TELETHON_SESSION: ${{ secrets.TELETHON_SESSION }}
run: python buildscripts/scripts/uploader.py "@ktgbuilds" "${{ env.REPO_NAME }}/artifact/Kotatogram/ksetup.${{ env.INSTALLER_VERSION_FULL }}.exe"
run: >
python buildscripts/scripts/uploader.py
"@ktgbuilds"
"${{ env.REPO_NAME }}/artifact/Kotatogram/ksetup.${{ env.INSTALLER_VERSION_FULL }}.exe"
"${{ github.event.client_payload.options.description }}"
- name: Package update.
if: >
Expand Down Expand Up @@ -479,4 +487,8 @@ jobs:
TELETHON_API_ID: ${{ secrets.TELETHON_API_ID }}
TELETHON_API_HASH: ${{ secrets.TELETHON_API_HASH }}
TELETHON_SESSION: ${{ secrets.TELETHON_SESSION }}
run: python buildscripts/scripts/uploader.py "@ktghbcfiles" "${{ env.REPO_NAME }}/tupdate${{ env.PACKER_VERSION }}"
run: >
python buildscripts/scripts/uploader.py
"@ktghbcfiles"
"${{ env.REPO_NAME }}/tupdate${{ env.PACKER_VERSION }}"
"${{ github.event.client_payload.options.description }}"
16 changes: 14 additions & 2 deletions docs/release_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
When creating a release, it will make all release builds from `master` branch. If you want to change the way it builds, you can specify options in release description:

```
Branch: dev
Updater: yes
Packer: false
```

Boolean options (like `Updater` and `Packer`) support multiple variants of setting its options:
Expand All @@ -21,6 +19,20 @@ Boolean options (like `Updater` and `Packer`) support multiple variants of setti

They are also case-insensitive, like any option name and values.

You can also specify an optional description, like this:

```
This is an optional description for release.
And some more description.
Branch: dev
Updater: yes
Packer: false
```

Please note that parameters should always be **in the end of description** and should be **separated by empty line**.

## Supported options

### Reference
Expand Down
7 changes: 4 additions & 3 deletions scripts/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from telethon.sync import TelegramClient
from telethon.sessions import StringSession

def upload(api_id, api_hash, session, target, file):
def upload(api_id, api_hash, session, target, file, description = ""):
with TelegramClient(StringSession(session), api_id, api_hash) as client:
client.send_file(target, file)
client.send_file(target, file, description)

if __name__ == '__main__':
if len(sys.argv) <= 2:
Expand All @@ -16,4 +16,5 @@ def upload(api_id, api_hash, session, target, file):
api_id = int(os.environ['TELETHON_API_ID'])
api_hash = os.environ['TELETHON_API_HASH']
session = os.environ['TELETHON_SESSION']
upload(api_id, api_hash, session, sys.argv[1], sys.argv[2])
description = sys.argv[3] if len(sys.argv) > 2 else ""
upload(api_id, api_hash, session, sys.argv[1], sys.argv[2], description)

0 comments on commit 0ec5a1c

Please sign in to comment.