From f059d856ae1fa252d42a22f995e806575b3062c9 Mon Sep 17 00:00:00 2001 From: Logan McNaughton Date: Sun, 6 Feb 2022 06:53:21 -0700 Subject: [PATCH] Better snap scripts --- .github/workflows/snap.yml | 9 +++++++++ .github/workflows/toolbox.yml | 8 ++++++++ scripts/get_linux_asset.py | 19 +++++++++++++++++++ snap/snapcraft.yaml | 4 ++-- toolbox/Containerfile | 2 +- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100755 scripts/get_linux_asset.py diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml index 310149c..73f8d61 100644 --- a/.github/workflows/snap.yml +++ b/.github/workflows/snap.yml @@ -10,6 +10,8 @@ on: env: SNAPCRAFT_BUILD_ENVIRONMENT: host + PYTHON_VERSION: "3.9" + VERSION: "v2022.2.3" jobs: build-snap: @@ -17,6 +19,11 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Get snapcraft login run: echo "$SNAPCRAFT_LOGIN" > $GITHUB_WORKSPACE/SNAPCRAFT_LOGIN.txt env: @@ -29,5 +36,7 @@ jobs: - name: Run snapcraft run: | + pip install requests + export M64P_LINUX_URL=$(python3 ../scripts/get_linux_asset.py ${{ env.VERSION }}) snapcraft --enable-experimental-extensions snapcraft upload --release=stable *.snap diff --git a/.github/workflows/toolbox.yml b/.github/workflows/toolbox.yml index 4273934..aff5a3c 100644 --- a/.github/workflows/toolbox.yml +++ b/.github/workflows/toolbox.yml @@ -12,6 +12,7 @@ env: REGISTRY_USER: loganmc10 IMAGE_REGISTRY: quay.io REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + PYTHON_VERSION: "3.9" VERSION: "v2022.2.3" jobs: @@ -20,6 +21,11 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Log in to Quay.io uses: redhat-actions/podman-login@v1 with: @@ -29,6 +35,8 @@ jobs: - name: Run podman run: | + pip install requests + export M64P_LINUX_URL=$(python3 ../scripts/get_linux_asset.py ${{ env.VERSION }}) podman build . --tag quay.io/loganmc10/m64p:latest --tag quay.io/loganmc10/m64p:${{ env.VERSION }} podman push quay.io/loganmc10/m64p:latest podman push quay.io/loganmc10/m64p:${{ env.VERSION }} diff --git a/scripts/get_linux_asset.py b/scripts/get_linux_asset.py new file mode 100755 index 0000000..17f5170 --- /dev/null +++ b/scripts/get_linux_asset.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 + +import requests +import sys + + +def main(): + resp = requests.get( + f"https://api.github.com/repos/m64p/m64p/releases/tags/{sys.argv[1]}" + ) + resp.raise_for_status() + for item in resp.json()["assets"]: + if "m64p-linux64" in item["name"]: + print(item["browser_download_url"]) + break + + +if __name__ == "__main__": + main() diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 8fdfb03..4156a5f 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: m64p base: core20 -version: "v2022.2.3" +version: $VERSION compression: lzo summary: An easy to use N64 emulator. Available for Windows and Linux description: | @@ -56,5 +56,5 @@ parts: override-prime: | snapcraftctl prime cp -f $SNAPCRAFT_STAGE/usr/lib/p7zip/7za $SNAPCRAFT_STAGE/usr/bin/7za - source: https://github.com/m64p/m64p/releases/download/v2022.2.3/m64p-linux64-8fd720f.zip + source: $M64P_LINUX_URL plugin: dump diff --git a/toolbox/Containerfile b/toolbox/Containerfile index 96d2f0a..4b7e8ed 100644 --- a/toolbox/Containerfile +++ b/toolbox/Containerfile @@ -1,6 +1,6 @@ FROM registry.fedoraproject.org/fedora-toolbox:35 -RUN wget -q https://github.com/m64p/m64p/releases/download/v2022.2.3/m64p-linux64-8fd720f.zip -O /m64p.zip && unzip /m64p.zip && rm /m64p.zip && \ +RUN wget -q ${M64P_LINUX_URL} -O /m64p.zip && unzip /m64p.zip && rm /m64p.zip && \ ln -s /mupen64plus/mupen64plus-gui /usr/bin/start RUN dnf -y update && dnf -y install qt5-qtbase-gui qt5-qtwebsockets SDL2_net minizip-compat hidapi libatomic pipewire-libs p7zip && dnf clean all -y RUN ln -s /run/host/usr/share/vulkan/icd.d/nvidia_icd.json /usr/share/vulkan/icd.d/nvidia_icd.json && \