mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-23 19:55:38 +01:00
Switch to github actions
This commit is contained in:
parent
7c2b93bcc4
commit
295d924a44
85
.github/workflows/tests.yaml
vendored
Normal file
85
.github/workflows/tests.yaml
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
name: Tests
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- {name: '3.8', python: '3.8', os: ubuntu-latest, architecture: 'x64', cibuild: "yes"}
|
||||
- {name: '3.7', python: '3.7', os: ubuntu-latest, architecture: 'x64', cibuild: "no"}
|
||||
- {name: '3.6', python: '3.6', os: ubuntu-latest, architecture: 'x64', cibuild: "no"}
|
||||
- {name: Windows, python: '3.8', os: windows-latest, architecture: 'x64', arch-cx: 'win-amd64', cx_name: 'amd64', cibuild: "no"}
|
||||
- {name: WindowsX86, python: '3.8', os: windows-latest, architecture: 'x86', arch-cx: 'win32', cx_name: 'win32', cibuild: "no"}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
architecture: ${{ matrix.architecture }}
|
||||
- name: update pip
|
||||
run: |
|
||||
pip install -U wheel
|
||||
pip install -U setuptools
|
||||
python -m pip install -U pip
|
||||
- name: get pip cache dir
|
||||
id: pip-cache
|
||||
run: echo "::set-output name=dir::$(pip cache dir)"
|
||||
- name: cache pip
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements*.txt') }}
|
||||
- name: set full Python version in PY env var
|
||||
# See https://pre-commit.com/#github-actions-example
|
||||
run: echo "::set-env name=PY::$(python -VV | sha256sum | cut -d' ' -f1)"
|
||||
- name: install deps
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-dev.txt
|
||||
- name: cache pre-commit
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
- name: pre-commit
|
||||
run: pre-commit run --all-files --show-diff-on-failure
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
- name: pytest
|
||||
run: pytest -v --cov
|
||||
|
||||
- name: set version
|
||||
run: python setversion.py
|
||||
|
||||
# Build .zip fil for *nix
|
||||
- run: make
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
# Build .exe for windows
|
||||
- name: build .exe
|
||||
run: python setup.py build_exe
|
||||
if: matrix.os == 'windows-latest'
|
||||
- name: run the .exe file
|
||||
run: build\\exe.${{ matrix.arch-cx }}-${{ matrix.python }}\\svtplay-dl.exe --version
|
||||
if: matrix.os == 'windows-latest'
|
||||
- run: |
|
||||
mkdir svtplay-dl
|
||||
xcopy /s build\\exe.${{ matrix.arch-cx }}-${{ matrix.python }} svtplay-dl
|
||||
if: matrix.os == 'windows-latest'
|
||||
- run: 7z a -tzip svtplay-dl-${{ matrix.cx_name }}.zip svtplay-dl
|
||||
if: matrix.os == 'windows-latest'
|
||||
|
||||
- name: cibuild
|
||||
run: python scripts/cibuild.py
|
||||
env:
|
||||
CIBUILD: ${{ matrix.cibuild }}
|
||||
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
|
||||
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
@ -1,49 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] < 7:
|
||||
from backports.datetime_fromisoformat import MonkeyPatch
|
||||
|
||||
MonkeyPatch.patch_fromisoformat()
|
||||
|
||||
|
||||
root = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger("cibuild")
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(prog="cibuild")
|
||||
general = parser.add_argument_group()
|
||||
general.add_argument("-s", "--snapshots", action="store_true", dest="snapshot", default=False)
|
||||
general.add_argument("-r", "--release", action="store_true", dest="release", default=False)
|
||||
options = parser.parse_args()
|
||||
|
||||
|
||||
twine_username = os.environ.get("TWINE_USERNAME")
|
||||
twine_password = os.environ.get("TWINE_PASSWORD")
|
||||
docker_username = os.environ.get("DOCKER_USERNAME")
|
||||
docker_password = os.environ.get("DOCKER_PASSWORD")
|
||||
aws_creds = os.environ.get("AWS_ACCESS_KEY_ID")
|
||||
|
||||
travis = os.environ.get("TRAVIS", "")
|
||||
travis_tag = os.environ.get("TRAVIS_TAG", "")
|
||||
travis_branch = os.environ.get("TRAVIS_BRANCH", "")
|
||||
appveyor_tag = os.environ.get("APPVEYOR_REPO_TAG_NAME", "")
|
||||
appveyor_branch = os.environ.get("APPVEYOR_REPO_BRANCH", "")
|
||||
|
||||
|
||||
def tag():
|
||||
return travis_tag or appveyor_tag
|
||||
match = re.search("refs/tags/(.*)", os.environ.get("GITHUB_REF"))
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def branch():
|
||||
return travis_branch or appveyor_branch
|
||||
match = re.search("refs/heads/(.*)", os.environ.get("GITHUB_REF"))
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def docker_name(version):
|
||||
@ -99,7 +86,7 @@ def aws_upload():
|
||||
folder = "snapshots"
|
||||
version = snapshot_folder()
|
||||
logger.info("Upload to aws {}/{}".format(folder, version))
|
||||
for file in ["svtplay-dl", "svtplay-dl.zip"]:
|
||||
for file in ["svtplay-dl", "svtplay-dl-amd64.zip", "svtplay-dl-win32.zip"]:
|
||||
if os.path.isfile(file):
|
||||
subprocess.check_call(["aws", "s3", "cp", "{}".format(file), "s3://svtplay-dl/{}/{}/{}".format(folder, version, file)])
|
||||
|
||||
@ -120,9 +107,9 @@ if not tag() and branch() != "master":
|
||||
sys.exit(0)
|
||||
|
||||
build_package()
|
||||
if travis:
|
||||
if os.environ.get("CIBUILD") == "yes":
|
||||
build_docker()
|
||||
aws_upload()
|
||||
|
||||
if tag() and travis:
|
||||
if tag() and os.environ.get("CIBUILD") == "yes":
|
||||
pypi_upload()
|
||||
|
Loading…
Reference in New Issue
Block a user