Skip to content

Commit

Permalink
Generate flatpak manifest for release and upload it
Browse files Browse the repository at this point in the history
  • Loading branch information
equeim committed Dec 28, 2024
1 parent 1e9d096 commit 5c61ff6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ jobs:
run: |
flatpak-builder --user --install-deps-from=flathub build-dir org.equeim.Tremotesf.json
- name: Check that generation of release manifest works
run: |
readonly archive="$(.github/workflows/make-source-archive.py zstd)"
.github/workflows/make-flatpak-manifest-for-release.py test "$archive"
echo "Release Flatpak manifest:"
cat org.equeim.Tremotesf.json
build-windows-msvc:
strategy:
fail-fast: false
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/make-flatpak-manifest-for-release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python3

# SPDX-FileCopyrightText: 2015-2024 Alexey Rochev
#
# SPDX-License-Identifier: CC0-1.0

import argparse
import json
from hashlib import sha256
from pathlib import PurePath

MANIFEST_FILENAME = "org.equeim.Tremotesf.json"


def main():
parser = argparse.ArgumentParser()
parser.add_argument("tag",
help="Git tag")
parser.add_argument("archive",
help="Release archive filename")
args = parser.parse_args()
with open(MANIFEST_FILENAME, "r", encoding="utf-8") as f:
manifest = json.load(f)
tremotesf_module = next(module for module in manifest["modules"] if module["name"] == "tremotesf")
del tremotesf_module["build-options"]["env"]["ASAN_OPTIONS"]
tremotesf_module["config-opts"].remove("-DTREMOTESF_ASAN=ON")

with open(args.archive, "rb") as f:
archive_sha256 = sha256(f.read()).hexdigest()

tremotesf_module["sources"] = [
{"type": "archive", "url": f"https://github.com/equeim/tremotesf2/releases/download/{args.tag}/{PurePath(args.archive).name}",
"sha256": archive_sha256}]
with open(MANIFEST_FILENAME, "w", encoding="utf-8") as f:
json.dump(manifest, f, indent=4)


if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
readarray -t archives < <(.github/workflows/make-source-archive.py gzip zstd)
echo "Uploading source archives ${archives[@]}"
gh release upload '${{ github.event.release.tag_name }}' "${archives[@]}"
.github/workflows/make-flatpak-manifest-for-release.py '${{ github.event.release.tag_name }}' "${archives[-1]}"
echo "Release Flatpak manifest:"
cat org.equeim.Tremotesf.json
gh release upload '${{ github.event.release.tag_name }}' org.equeim.Tremotesf.json
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down

0 comments on commit 5c61ff6

Please sign in to comment.