Skip to content

Commit 461f31c

Browse files
authored
feat: Add publish.yml for release to pypi (#5)
1 parent a700f11 commit 461f31c

File tree

2 files changed

+55
-11
lines changed

2 files changed

+55
-11
lines changed

.github/workflows/publish.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
branches: [main]
14+
types: [published]
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
deploy:
22+
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Set up Python
28+
uses: actions/setup-python@v3
29+
with:
30+
python-version: '3.x'
31+
- name: Install dependencies
32+
run: python -m pip install --upgrade pip twine
33+
- name: Build wheel
34+
run: python -m pip wheel -w dist .
35+
- name: Check distribution
36+
run: twine check dist/*
37+
- name: Publish package (to TestPyPI)
38+
if: github.event_name == 'workflow_dispatch' && github.repository == 'cpp-linter/cpp-linter-hooks'
39+
env:
40+
TWINE_USERNAME: __token__
41+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
42+
run: twine upload --repository testpypi dist/*
43+
- name: Publish package (to PyPI)
44+
if: github.event_name != 'workflow_dispatch' && github.repository == 'cpp-linter/cpp-linter-hooks'
45+
env:
46+
TWINE_USERNAME: __token__
47+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
48+
run: twine upload dist/*

.github/workflows/test.yml

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
name: "Test"
1+
name: Test
22

33
on:
44
push:
55
branches: main
6-
paths: '**.py'
6+
paths:
7+
- '**.py'
8+
- '.github/workflows/test.yml'
79
pull_request:
810
branches: main
9-
paths: '**.py'
11+
paths:
12+
- '**.py'
13+
- '.github/workflows/test.yml'
1014
workflow_dispatch:
1115

1216
jobs:
@@ -25,14 +29,6 @@ jobs:
2529
pip install .
2630
pip install -r requirements-dev.txt
2731
28-
# - name: Add tag to latest commit for testing
29-
# run: |
30-
# git config user.name 'github-actions'
31-
# git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
32-
# git push --delete origin latest || true
33-
# git tag -a latest -m 'Retag latest commit'
34-
# git push origin latest
35-
3632
- name: Run tests and collect coverage
3733
run: |
3834
coverage run --source=tests,cpp_linter_hooks -m pytest

0 commit comments

Comments
 (0)