Skip to content

Commit

Permalink
Merge pull request #47 from gsinghjay/test/verify-workflows
Browse files Browse the repository at this point in the history
ci: standardize Poetry usage across workflows
  • Loading branch information
gsinghjay authored Jan 2, 2025
2 parents d3798a3 + b809859 commit 77d897d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 50 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip'
cache: "pip"

- name: Set up Node (for Commitlint)
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install npm dependencies
- name: Install Poetry
run: |
npm ci
pip install poetry==1.8.5
poetry config virtualenvs.create false
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry==1.8.5
poetry install --no-root
run: poetry install

- name: Run Black
run: poetry run black --check .
Expand Down
49 changes: 16 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ permissions:
id-token: write

jobs:
# Call the lint workflow first
lint:
name: Lint Check
uses: ./.github/workflows/lint.yml
permissions:
contents: read
pull-requests: read

# Call the test workflow next
test:
name: Run Tests
needs: [lint]
Expand All @@ -47,11 +45,9 @@ jobs:
contents: read
checks: write

# Finally run the release job
release:
name: Create Release
runs-on: ubuntu-latest
# Only run release on main branch and when not triggered by automated commits
if: |
github.ref == 'refs/heads/main' &&
github.actor != 'github-actions[bot]' &&
Expand All @@ -66,32 +62,20 @@ jobs:
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
ref: ${{ github.sha }}

- name: Force correct release branch
run: |
git checkout -B ${{ github.ref_name }} ${{ github.sha }}
- name: Setup Python and Dependencies
run: |
pip install python-semantic-release==9.15.0
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"

- name: Generate Changelog
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
- name: Install Poetry
run: |
# Generate changelog regardless of release
semantic-release changelog
pip install poetry==1.8.5
poetry config virtualenvs.create false
# Commit changelog if changed
if [[ -n $(git status --porcelain CHANGELOG.md) ]]; then
git pull origin ${{ github.ref_name }} --rebase
git add CHANGELOG.md
git commit -m "docs: update CHANGELOG.md [skip ci]"
git push origin HEAD:${{ github.ref_name }}
fi
- name: Install dependencies
run: poetry install

- name: Python Semantic Release
id: release
Expand All @@ -103,10 +87,9 @@ jobs:
force: ${{ inputs.force != 'none' && inputs.force || '' }}
git_committer_name: "github-actions[bot]"
git_committer_email: "41898282+github-actions[bot]@users.noreply.github.com"

- name: Publish to GitHub Release Assets
uses: python-semantic-release/[email protected]
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.PAT_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
changelog: true
commit: true
push: true
build: true
tag: true
vcs_release: true
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache: "pip"

- name: Install dependencies
- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry==1.8.5
poetry install --no-root
poetry config virtualenvs.create false
- name: Install dependencies
run: poetry install

- name: Run tests with coverage
run: |
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ commit_message = "chore(release): {version} [skip ci]"

[tool.python_semantic_release.remote]
token = "env:GH_TOKEN"
# Add these if you want to sign releases
sign_tags = true
provider = "github"

# Simplified branch configuration - only main branch
[tool.python_semantic_release.branches]
Expand Down

0 comments on commit 77d897d

Please sign in to comment.