Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.15.4
current_version = 0.1.1
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
121 changes: 121 additions & 0 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Manual Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0)'
required: true
type: string
target:
description: 'Target PyPI repository'
required: true
default: 'test'
type: choice
options:
- test
- production

env:
PYTHON_VERSION: "3.10"

jobs:
manual-release:
name: Manual Release to ${{ inputs.target }} PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Update VERSION file
run: |
echo "${{ inputs.version }}" > VERSION
echo "Updated VERSION to ${{ inputs.version }}"

- name: Update version in files
run: |
# Update .bumpversion.cfg
sed -i "s/current_version = .*/current_version = ${{ inputs.version }}/" .bumpversion.cfg

# Update src/permifrost/__init__.py
sed -i "s/__version__ = \".*\"/__version__ = \"${{ inputs.version }}\"/" src/permifrost/__init__.py

# Update pyproject.toml
sed -i "s/version = \".*\"/version = \"${{ inputs.version }}\"/" pyproject.toml

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'

- name: Build package
run: |
make dist-local

- name: Check package
run: |
twine check dist/*

- name: Publish to Test PyPI
if: inputs.target == 'test'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Publish to Production PyPI
if: inputs.target == 'production'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true

- name: Create Release
if: inputs.target == 'production'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ inputs.version }}
release_name: Release v${{ inputs.version }}
body: |
## Release v${{ inputs.version }}

This release has been manually published to PyPI.

**Install:**
```bash
pip install gemma.permifrost
```

**PyPI URL:** https://pypi.org/project/gemma.permifrost/
draft: false
prerelease: false

- name: Commit version changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add VERSION .bumpversion.cfg src/permifrost/__init__.py pyproject.toml
git commit -m "Bump version to ${{ inputs.version }}"
git tag v${{ inputs.version }}
git push origin HEAD
git push origin v${{ inputs.version }}

- name: Success message
run: |
if [ "${{ inputs.target }}" = "test" ]; then
echo "✅ Successfully published version ${{ inputs.version }} to Test PyPI"
echo "🔗 Test PyPI URL: https://test.pypi.org/project/gemma.permifrost/"
echo "📦 Install: pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ gemma.permifrost"
else
echo "✅ Successfully published version ${{ inputs.version }} to Production PyPI"
echo "🔗 PyPI URL: https://pypi.org/project/gemma.permifrost/"
echo "📦 Install: pip install gemma.permifrost"
fi
161 changes: 161 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Release to PyPI

on:
pull_request:
types: [opened, synchronize, reopened, closed]
paths:
- 'VERSION'
push:
branches:
- main
- master
paths:
- 'VERSION'

env:
PYTHON_VERSION: "3.10"

jobs:
test-release:
name: Release to Test PyPI
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.state == 'open'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'

- name: Check if VERSION file changed
id: check_version
run: |
if git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | grep -q "VERSION"; then
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "version_changed=false" >> $GITHUB_OUTPUT
fi

- name: Build package
if: steps.check_version.outputs.version_changed == 'true'
run: |
make dist-local

- name: Check package
if: steps.check_version.outputs.version_changed == 'true'
run: |
twine check dist/*

- name: Publish to Test PyPI
if: steps.check_version.outputs.version_changed == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Comment on PR
if: steps.check_version.outputs.version_changed == 'true'
uses: actions/github-script@v7
with:
script: |
const version = require('fs').readFileSync('VERSION', 'utf8').trim();
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 **Test Release Published!**

Version \`${version}\` has been published to Test PyPI.

**Install from Test PyPI:**
\`\`\`bash
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ gemma.permifrost
\`\`\`

**Test PyPI URL:** https://test.pypi.org/project/gemma.permifrost/

Once this PR is merged, it will be automatically published to production PyPI.`
});

production-release:
name: Release to Production PyPI
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'

- name: Check if VERSION file changed
id: check_version
run: |
if git diff --name-only HEAD~1..HEAD | grep -q "VERSION"; then
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "version_changed=false" >> $GITHUB_OUTPUT
fi

- name: Build package
if: steps.check_version.outputs.version_changed == 'true'
run: |
make dist-local

- name: Check package
if: steps.check_version.outputs.version_changed == 'true'
run: |
twine check dist/*

- name: Publish to Production PyPI
if: steps.check_version.outputs.version_changed == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true

- name: Create Release
if: steps.check_version.outputs.version_changed == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Release v${{ steps.get_version.outputs.version }}
body: |
## Release v${{ steps.get_version.outputs.version }}

This release has been automatically published to PyPI.

**Install:**
```bash
pip install gemma.permifrost
```

**PyPI URL:** https://pypi.org/project/gemma.permifrost/
draft: false
prerelease: false

- name: Get version
if: steps.check_version.outputs.version_changed == 'true'
id: get_version
run: |
version=$(cat VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
100 changes: 100 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Test Package

on:
pull_request:
paths:
- 'VERSION'
- 'src/**'
- 'tests/**'
- 'setup.py'
- 'pyproject.toml'
push:
branches:
- main
- master
paths:
- 'VERSION'
- 'src/**'
- 'tests/**'
- 'setup.py'
- 'pyproject.toml'

env:
PYTHON_VERSION: "3.10"

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'

- name: Run linting
run: |
make ci-show-lint

- name: Run tests
run: |
pytest -v --cov-report= --cov permifrost -m "$PYTEST_MARKERS"
coverage report
coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella

build-test:
name: Test Build
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'

- name: Build package
run: |
make dist-local

- name: Check package
run: |
twine check dist/*

- name: Test package installation
run: |
pip install dist/*.whl
permifrost --help

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-files
path: dist/
retention-days: 1
Loading