summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml28
-rw-r--r--tools/collect_artifacts_metadata.py55
2 files changed, 83 insertions, 0 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c7d610cd13..00804f8cab 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -368,3 +368,31 @@ jobs:
with:
name: ${{ matrix.artifacts_name }}
path: ${{ matrix.artifacts_path }}
+
+ update_manifest:
+ name: "Update manifest file on download server"
+ runs-on: ubuntu-latest
+ needs: build
+ if: github.event_name == 'push'
+ steps:
+ - name: "Check out repository"
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: "Collect Artifacts Metadata & Write Manifest"
+ if: github.event_name == 'push'
+ run: python3 tools/collect_artifacts_metadata.py
+ env:
+ JOB_DATA: ${{ toJSON(needs.build) }}
+ DEPLOY_DESTPATH: "builds/{git_branch}"
+
+ - name: "Deploy Manifest"
+ if: github.event_name == 'push' && env.SSH_PASSWORD != null
+ run: echo ${{ toJSON(needs) }}
+ env:
+ DESTDIR: public_html/downloads/
+ SSH_HOST: downloads-hostgator.mixxx.org
+ SSH_KEY: packaging/certificates/downloads-hostgator.mixxx.org.key
+ SSH_PASSWORD: ${{ secrets.DOWNLOADS_HOSTGATOR_DOT_MIXXX_DOT_ORG_KEY_PASSWORD }}
+ SSH_USER: mixxx
diff --git a/tools/collect_artifacts_metadata.py b/tools/collect_artifacts_metadata.py
new file mode 100644
index 0000000000..2757afb4a0
--- /dev/null
+++ b/tools/collect_artifacts_metadata.py
@@ -0,0 +1,55 @@
+import os
+import json
+import subprocess
+import urllib.request
+import urllib.error
+
+
+def url_exists(url):
+ req = urllib.request.Request(url, method="HEAD")
+ try:
+ resp = urllib.request.urlopen(req, timeout=10)
+ except urllib.error.URLError:
+ return False
+ return resp.status == 200
+
+
+job_data = json.loads(os.environ["JOB_DATA"])
+job_result = job_data["result"]
+print(f"Build job result: {job_result}")
+assert job_result == "success"
+
+manifest_data = {}
+for output_name, output_data in job_data["outputs"].items():
+ prefix, _, slug = output_name.partition("-")
+ if prefix != "artifact" or not slug:
+ print(f"Ignoring output '{output_name}'...")
+ continue
+ artifact_data = json.loads(output_data)
+
+ print("Checking if package actually exists...", end="")
+ url = artifact_data["file_url"]
+ package_exists = url_exists(url)
+ if not package_exists:
+ print(f"fail ({url})")
+ continue
+ print("ok")
+
+ manifest_data[slug] = artifact_data
+
+print(json.dumps(manifest_data, indent=2, sort_keys=True))
+
+assert manifest_data
+
+with open("manifest.json", mode="w") as fp:
+ json.dump(manifest_data, fp, indent=2, sort_keys=True)
+
+if os.getenv("CI") == "true":
+ git_branch = (
+ subprocess.check_output(("git", "rev-parse", "--abbrev-ref", "HEAD"))
+ .decode()
+ .strip()
+ )
+ deploy_dir = os.environ["DEPLOY_DESTPATH"].format(git_branch=git_branch)
+ with open(os.environ["GITHUB_ENV"], mode="a") as fp:
+ fp.write(f"DEPLOY_DIR={deploy_dir}\n")