Skip to content

Commit

Permalink
Update workflows to prep for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
eseglem committed Feb 9, 2024
1 parent d3a76d9 commit 860160c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ indent_style = space
trim_trailing_whitespace = true
indent_size = 4

[*.json]
[*.json,*.yaml,*.yml]
indent_size = 2
51 changes: 51 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release

on:
workflow_dispatch:

jobs:
run-tests:
uses: ./.github/workflows/tests.yaml

release:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry

- name: Install dependencies
run: poetry install --no-dev

- name: Get release version
id: release-version
run: echo "RELEASE_VERSION=v$(poetry version --short)" >> "$GITHUB_OUTPUT"

- name: Build package
run: poetry build

- name: Upload the files to the release
uses: ncipollo/release-action@v1
with:
artifacts: ${{ github.workspace }}/dist/*
tag: ${{ steps.release-version.outputs.RELEASE_VERSION }}
commit: ${{ github.sha }}
omitBody: true

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
50 changes: 21 additions & 29 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,42 @@ name: Tests

on:
push:
branches: [main]
tags: ["v*"]
branches:
- main
- develop
pull_request:
branches: [main]
branches:
- main
- develop
workflow_call:

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v4
- name: Checkout the repository
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
cache: poetry

- name: Install dependencies
run: poetry install -E test
- name: Run tests with coverage
run: poetry run pytest --ignore=tests/test_pycql2_hypothesis.py --cov=pycql2 --cov-report=xml tests/

publish:
needs: [tests]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: "poetry"
- name: Install dependencies
run: poetry install --no-dev
- name: Build package
run: poetry build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Run tests with coverage
run: poetry run pytest --ignore=tests/test_pycql2_hypothesis.py --cov=pycql2 --cov-report=term-missing tests/
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"markdownlint.config": {
"default": true,
"MD007": {
"ul-indent": {
"indent": 4
}
}
Expand Down

0 comments on commit 860160c

Please sign in to comment.