diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dd83887 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + ci: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + + - name: Get yarn cache + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Cache python modules + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + yarn --dev + python -m pip install -r requirements.txt + python -m pip install -r requirements-dev.txt + + - name: Lint + run: | + yarn run lint + flake8 + + - name: Package + run: | + python setup.py bdist_wheel + pip install --no-cache-dir dist/legunto-*.whl diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b428de --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Upload Release Asset + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + + - name: Cache python modules + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install -r requirements.txt + python -m pip install -r requirements-dev.txt + + - name: Package + run: | + python setup.py bdist_wheel + pip install --no-cache-dir dist/legunto-*.whl + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: true + prerelease: false + + - name: Set file name + id: file_name + run: echo "::set-output name=file_name::$(ls dist)" + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/${{ steps.file_name.outputs.file_name }} + asset_name: ${{ steps.file_name.outputs.file_name }} + asset_content_type: application/zip diff --git a/legunto b/legunto new file mode 100755 index 0000000..07728b6 --- /dev/null +++ b/legunto @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +def main(): + print("Hello legunto!") + + +if __name__ == '__main__': + main() diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..43c5a43 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +flake8==3.8.3 +pytest==5.4.3 +wheel==0.34.2 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fad3e27 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +mwclient==0.10.1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..356fdef --- /dev/null +++ b/setup.py @@ -0,0 +1,15 @@ +import setuptools + +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup( + name="legunto", + version="0.0.1", + scripts=["legunto"], + description="Fetch MediaWiki Scribunto modules from wikis", + long_description=long_description, + long_description_content_type="text/markdown", + packages=setuptools.find_packages(), + install_requires=["mwclient"], +)