Skip to content

Commit

Permalink
Added version
Browse files Browse the repository at this point in the history
  • Loading branch information
desiena committed Dec 19, 2024
1 parent 6d8c9ab commit 05e5ca9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
38 changes: 33 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Python 🐍 distribution 📦 to PyPI
name: Build and publish

on:
workflow_dispatch:
Expand All @@ -7,6 +7,10 @@ on:
- main
tags:
- 'v*.*.*' # Example: v1.2.3
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
PRE_RELEASE_VERSION: true
DRAFT_VERSION: true

jobs:
build-and-publish:
Expand All @@ -18,7 +22,30 @@ jobs:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Sets env vars for main
if: ${{ env.BRANCH_NAME == 'main' }}
run: |
echo "PRE_RELEASE_VERSION=false" >> $GITHUB_ENV
echo "DRAFT_VERSION=false" >> $GITHUB_ENV
- name: Get next version
uses: reecetech/[email protected]
id: version
with:
scheme: semver
release_branch: main

- name: Set PACKAGE_VERSION Environment Variable
run: echo "PACKAGE_VERSION=${{ steps.version.outputs.version }}" >> $GITHUB_ENV

- name: Release version
uses: softprops/action-gh-release@v2
with:
draft: ${{ env.DRAFT_VERSION }}
prerelease: ${{ env.PRE_RELEASE_VERSION }}
tag_name: "${{ steps.version.outputs.version }}"

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -41,15 +68,16 @@ jobs:
pip install -r requirements.txt
# (Optional) Run tests
# - name: Run tests
# run: |
# pytest
# - name: Run tests
# run: |
# pytest

# Build the package
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish package distributions to PyPI
if: ${{ env.PRE_RELEASE_VERSION == false }}
uses: pypa/gh-action-pypi-publish@release/v1

6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import os

from setuptools import setup

with open('README.md', 'r', encoding='utf-8') as ld:
long_description = ld.read()

version = os.getenv('PACKAGE_VERSION', '0.0.1-dev')

setup(
name='fmdata',
version='0.0.1',
version=version,
python_requires='>=3.8',
author='Lorenzo De Siena',
author_email='[email protected]',
Expand Down

0 comments on commit 05e5ca9

Please sign in to comment.