summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2021-04-15 18:00:37 +0200
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2021-04-16 00:44:23 +0200
commiteeeda76092ed2b73738081170fdaa0a9b7265b41 (patch)
treec669206a384778ae5ad125755464aea790e737af
parentc0271b3bff99f7746a8c7d0504d4db90001fdbb4 (diff)
CI: Use better paths for branch and tag build artifacts
-rw-r--r--.github/workflows/build.yml16
-rw-r--r--tools/deploy.py31
2 files changed, 38 insertions, 9 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d47e0814f7..8ca1e5ddc2 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -339,10 +339,16 @@ jobs:
if: github.event_name == 'push'
shell: bash
run: >
+ if [[ "${GITHUB_REF}" =~ ^refs/tags/.* ]];
+ then
+ export DEPLOY_PATH='mixxx-{git_describe}/mixxx-{git_describe}-{package_slug}{ext}';
+ else
+ export DEPLOY_PATH='builds/{git_branch}/mixxx-{git_describe}-{package_slug}{ext}';
+ fi;
python3 tools/deploy.py prepare-deployment
--slug '${{ matrix.artifacts_slug }}'
--output-dir 'deploy/'
- --dest-path 'builds/{branch}/mixxx-{describe}-{package_slug}.{ext}'
+ --dest-path "${DEPLOY_PATH}"
--dest-url 'https://downloads.mixxx.org'
${{ matrix.artifacts_path }}
@@ -394,9 +400,15 @@ jobs:
# single JSON document and then deploy to the server.
if: github.event_name == 'push' && env.SSH_PASSWORD != null
run: >
+ if [[ "${GITHUB_REF}" =~ ^refs/tags/.* ]];
+ then
+ export DEPLOY_PATH='mixxx-{git_describe}/manifest.json';
+ else
+ export DEPLOY_PATH='builds/{git_branch}/manifest.json';
+ fi;
python3 tools/deploy.py generate-manifest
--output-dir 'deploy/'
- --dest-path 'builds/{branch}/manifest.json'
+ --dest-path "${DEPLOY_PATH}"
--dest-url 'https://downloads.mixxx.org'
env:
JOB_DATA: ${{ toJSON(needs.build) }}
diff --git a/tools/deploy.py b/tools/deploy.py
index c33cc74007..372968027e 100644
--- a/tools/deploy.py
+++ b/tools/deploy.py
@@ -77,6 +77,20 @@ def git_info(info, path="."):
).strip()
+def splitext(filename):
+ """
+ Split filename into name without extenstion and file extension.
+
+ This includes a workaround for ".tar.gz" files.
+ """
+ filename_without_ext, file_ext = os.path.splitext(filename)
+ filename_without_ext2, file_ext2 = os.path.splitext(filename_without_ext)
+ if file_ext2 == ".tar":
+ filename_without_ext = filename_without_ext2
+ file_ext = f"{file_ext2}{file_ext}"
+ return filename_without_ext, file_ext
+
+
def tree(path):
for dirpath, dirnames, filenames in os.walk(top=path):
relpath = os.path.relpath(dirpath, start=path)
@@ -131,15 +145,18 @@ def prepare_deployment(args):
}
)
+ filename_without_ext, file_ext = splitext(args.file)
download_slug, package_slug = args.slug
+
# Build destination path scheme
print(f"Destination path pattern: {args.dest_path}")
destpath = args.dest_path.format(
filename=os.path.basename(args.file),
- ext=os.path.splitext(args.file)[1],
- branch=metadata["git_branch"],
- commit_id=metadata["git_commit"],
- describe=metadata["git_describe"],
+ filename_without_ext=filename_without_ext,
+ ext=file_ext,
+ git_branch=metadata["git_branch"],
+ git_commit_id=metadata["git_commit"],
+ git_describe=metadata["git_describe"],
package_slug=package_slug,
download_slug=download_slug,
)
@@ -216,9 +233,9 @@ def generate_manifest(args):
commit_id = git_info("commit")
format_data = {
- "branch": git_info("branch"),
- "commit_id": commit_id,
- "describe": git_info("describe"),
+ "git_branch": git_info("branch"),
+ "git_commit_id": commit_id,
+ "git_describe": git_info("describe"),
}
# Build destination path scheme