Skip to content

Commit

Permalink
bugfix build action
Browse files Browse the repository at this point in the history
  • Loading branch information
trincaog committed Jan 2, 2024
1 parent 1eaee30 commit e579049
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 47 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Upload Python Package to PyPI

on:
release:
types: [published]

jobs:
build:
name: Build and deploy
environment: production
permissions:
id-token: write
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4

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

- name: Set environment variables
id: set_env_variables
run: |
echo "PYTHONPATH=." >> "$GITHUB_ENV"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest
pytest test/ --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml
- name: Extract tag name
id: tag
run: echo "PKG_VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> "$GITHUB_OUTPUT"

- name: Update version in pyproject.toml
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.PKG_VERSION }}/g" pyproject.toml
- name: Build package
run: python -m build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ vars.PYPI_URL }}
password: ${{ secrets.PYPI_API_TOKEN }}
42 changes: 42 additions & 0 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

on: [workflow_dispatch]

jobs:
build:
name: Build Package
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4

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

- name: Set environment variables
id: set_env_variables
run: |
echo "PYTHONPATH=." >> "$GITHUB_ENV"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest
pytest test/ --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.python-version }}
path: |
junit/test-results-${{ matrix.python-version }}.xml
if: ${{ always() }}
45 changes: 0 additions & 45 deletions .github/workflows/python-publish.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist/
*.egg-info/
.coverage
venv/
junit/
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["setuptools>=68.0"]
build-backend = "setuptools.build_meta"

[project]
name = "magiccube"
version = "{{VERSION_PLACEHOLDER}}"
Expand All @@ -21,5 +25,5 @@ dependencies = [
[project.urls]
"Homepage" = "https://github.com/trincaog/magiccube"

[tool.setuptools]
packages = ["magiccube"]
[tool.setuptools.packages.find]
include = ["magiccube", "magiccube.*"]

0 comments on commit e579049

Please sign in to comment.