Skip to content

Commit

Permalink
Updates setup.py and adds PyPi on GitHub Release
Browse files Browse the repository at this point in the history
Version is now incremented from the GitHub Action that triggers on
a release.
Classifiers have been added to the setup.py and .gitignore was updated
  • Loading branch information
gnikit committed Dec 13, 2021
1 parent da89523 commit b456b6a
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 16 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: PyPi Release

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
# see: https://github.community/t/how-to-get-just-the-tag-name/16241/7
- name: Get the version
id: get_version
shell: bash
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Set global variables
shell: bash
run: |
echo "VERSION=${{ steps.get_version.outputs.VERSION}}" >> $GITHUB_ENV
- name: Set __version__
shell: bash
run: sed -i "s/PLACEHOLDER/${VERSION}/g" "fortls/_version.py"

- name: Build package
run: python -m build

- name: Publish to Test PyPi
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish to PyPi
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.pyc
.vscode
.vscode
*.egg-info
dist/
3 changes: 1 addition & 2 deletions fortls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from .langserver import LangServer
from .jsonrpc import JSONRPC2Connection, ReadWriter, path_from_uri
from .parse_fortran import fortran_file, process_file

__version__ = "1.12.0"
from ._version import __version__


def error_exit(error_str):
Expand Down
1 change: 1 addition & 0 deletions fortls/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "PLACEHOLDER"
46 changes: 33 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
#!/usr/bin/env python
from setuptools import find_packages, setup
from fortls import __version__
import pathlib

README = open("README.rst", "r").read()
# The directory containing this file
HERE = pathlib.Path(__file__).resolve().parent

# The text of the README file is used as a description
README = (HERE / "README.md").read_text()

NAME = "fortls"

setup(
name="fortran-language-server",
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version="1.12.0",
description="FORTRAN Language Server for the Language Server Protocol",
long_description=README,
# The project's main homepage.
url="https://github.com/hansec/fortran-language-server",
download_url=(
"https://github.com/hansec/fortran-language-server/archive/v1.12.0.tar.gz"
),
name=NAME,
version=__version__,
url="https://github.com/gnikit/fortran-language-server",
author="Chris Hansen",
author_email="[email protected]",
description="FORTRAN Language Server - dev version",
long_description=README,
long_description_content_type="text/markdown",
license="MIT",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Fortran",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
],
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=["contrib", "docs", "test"]),
Expand Down

0 comments on commit b456b6a

Please sign in to comment.