-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (77 loc) · 2.48 KB
/
publish-to-pypi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: cd-build-and-publish
on:
release:
types:
- released
jobs:
compliance:
if: github.event.release.target_commitish == 'main'
uses: ./.github/workflows/lint-and-pytest.yml
update-files:
if: github.event.release.target_commitish == 'main'
needs: compliance
outputs:
new_sha: ${{ steps.sha.outputs.SHA }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update version number in the files
run: |
sed -i "s/version = .*/version = '${{ github.event.release.tag_name }}'/" pyproject.toml
sed -i "s/__version__ = .*/__version__ = '${{ github.event.release.tag_name }}'/" ./src/mediacatch_s2t/__init__.py
- name: Commit changes
run: |
git config user.name "gha-release"
git config user.email "[email protected]"
git add pyproject.toml src/mediacatch_s2t/__init__.py
git commit -m "bump version to ${{ github.event.release.tag_name }}"
- name: Overwrite tag
run: |
echo "gh tag name ${{ github.event.release.tag_name }} to $(git rev-parse HEAD)"
git tag --force ${{ github.event.release.tag_name }} $(git rev-parse HEAD)
- name: Push changes
uses: ad-m/github-push-action@master
with:
tags: true
force: true
- name: get sha
id: sha
run: |
sha_new=$(git rev-parse HEAD)
echo $sha_new
echo "SHA=$sha_new" >> $GITHUB_OUTPUT
- run:
echo ${{ steps.sha.outputs.SHA }}
build-and-publish:
name: Build and publish Python distribution package to PyPI
needs: update-files
runs-on: ubuntu-latest
steps:
- name: Checkout repository with new commit
uses: actions/checkout@v3
with:
ref: ${{ needs.update-files.outputs.new_sha }}
- name: Show latest sha commit
run: |
git rev-parse HEAD
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python3 -m
build
--sdist
--wheel
--outdir dist/
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}