Skip to content

Commit

Permalink
Merge pull request #61 from PolicyEngine/fix/improve-versioning
Browse files Browse the repository at this point in the history
Fix version checking
  • Loading branch information
anth-volk authored Sep 18, 2024
2 parents bf17d84 + 85fdf34 commit 05db145
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 10 deletions.
11 changes: 5 additions & 6 deletions .github/fetch_version.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from policyengine_us_data.__version__ import __version__
# Note: Action must be run in Python 3.11 or later
import tomllib


def fetch_version():
try:
return __version__
except Exception as e:
print(f"Error fetching version: {e}")
return None
with open("pyproject.toml", "rb") as f:
pyproject = tomllib.load(f)
return pyproject["project"]["version"]


if __name__ == "__main__":
Expand Down
63 changes: 59 additions & 4 deletions .github/workflows/ci_cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' ||
(
github.repository == 'PolicyEngine/policyengine-us-data'
&& github.event.head_commit.message == 'Update PolicyEngine US data'
)
name: Lint
steps:
- uses: actions/checkout@v4
Expand All @@ -22,9 +28,50 @@ jobs:
pip install black
- name: Check formatting
run: black . -l 79 --check
check-version:
name: Check version
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' ||
(
github.repository == 'PolicyEngine/policyengine-us-data'
&& github.event.head_commit.message != 'Update PolicyEngine US data'
)
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Build changelog
run: pip install "yaml-changelog>=0.1.7" && make changelog
- name: Preview changelog update
run: ".github/get-changelog-diff.sh"
- name: Check version number has been properly updated
run: ".github/is-version-number-acceptable.sh"
- name: Update changelog
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: EndBug/add-and-commit@v9
with:
add: "."
committer_name: Github Actions[bot]
author_name: Github Actions[bot]
message: Update PolicyEngine US data
github_token: ${{ secrets.POLICYENGINE_GITHUB }}
test:
name: Build and test
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' ||
(
github.repository == 'PolicyEngine/policyengine-us-data'
&& github.event.head_commit.message == 'Update PolicyEngine US data'
)
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -51,7 +98,9 @@ jobs:
publish-to-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
github.repository == 'PolicyEngine/policyengine-us-data'
&& github.event.head_commit.message == 'Update PolicyEngine US data'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -76,7 +125,9 @@ jobs:
docker:
name: Docker
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
github.repository == 'PolicyEngine/policyengine-us-data'
&& github.event.head_commit.message == 'Update PolicyEngine US data'
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -93,7 +144,9 @@ jobs:
publish-docs:
name: Publish documentation
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
github.repository == 'PolicyEngine/policyengine-us-data'
&& github.event.head_commit.message == 'Update PolicyEngine US data'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -117,7 +170,9 @@ jobs:
name: Upload data
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >
github.repository == 'PolicyEngine/policyengine-us-data'
&& github.event.head_commit.message == 'Update PolicyEngine US data'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
fixed:
- Corrected versioning issues

0 comments on commit 05db145

Please sign in to comment.