Skip to content

Commit

Permalink
Create preview builds
Browse files Browse the repository at this point in the history
  • Loading branch information
thetestgame committed Nov 12, 2024
1 parent 649e9c5 commit 3d65400
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,31 @@ jobs:
major_pattern: "(MAJOR)"
minor_pattern: "(MINOR)"

# Build the package using the version
# Export the version as an environment variable and also export
# the current release vs prerelease state as an environment variable.
# This is determined if the event_name is release or not. Finally
# build the package.
- name: Build package
if: github.event_name != 'pull_request'
run: |
export MAJOR=${{ steps.package-version.outputs.major }}
export MINOR=${{ steps.package-version.outputs.minor }}
export PATCH=${{ steps.package-version.outputs.patch }}
if [ "${{ github.event_name }}" == "release" ]; then
export RELEASE="true"
else
export RELEASE="false"
fi
echo "Building version $MAJOR.$MINOR.$PATCH"
python -m build
# Load the secret from 1Password
- name: Load secret
id: op-load-secret
uses: 1password/load-secrets-action@v2
if: github.event_name != 'pull_request'
with:
export-env: false
env:
Expand All @@ -63,7 +74,7 @@ jobs:
# Publish the package to PyPi if a release is created
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
if: github.event_name == 'release'
if: github.event_name != 'pull_request'
with:
user: __token__
password: ${{ steps.op-load-secret.outputs.SECRET }}
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ def get_version() -> str:
minor = os.environ.get('MINOR', '0')
patch = os.environ.get('PATCH', '0')

return f'{major}.{minor}.{patch}'
# Determine if this is a pre-release version
release_flag = os.environ.get('RELEASE', 'true').lower()
prerelease = not bool(release_flag)

if not prerelease:
return f'{major}.{minor}.{patch}'
else:
return f'{major}.{minor}.{patch}.dev'

def get_readme(filename: str = 'README.md') -> str:
"""
Expand Down

0 comments on commit 3d65400

Please sign in to comment.