-
Notifications
You must be signed in to change notification settings - Fork 11
123 lines (117 loc) · 3.74 KB
/
publish.yml
File metadata and controls
123 lines (117 loc) · 3.74 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Publish
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
env:
PYTHON_VERSION: 3.11.0
POETRY_VERSION: 1.3.1
jobs:
wait_static_tests:
name: Wait for Static Tests
runs-on: ubuntu-latest
strategy:
matrix:
test: [ "Flake8", "mypy" ]
python: [ "3.11", "3.10", "3.9" ]
steps:
- uses: actions/checkout@v4
- name: Wait for Tests
id: wait
uses: fountainhead/action-wait-for-check@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: "${{ matrix.test }} (${{ matrix.python }})"
ref: ${{ github.event.push_request.head.sha || github.sha }}
- if: ${{ steps.wait.outputs.conclusion != 'success' }}
run: exit 1
wait_unit_tests:
name: Wait for Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Wait for Tests
id: wait
uses: fountainhead/action-wait-for-check@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: "pytest"
ref: ${{ github.event.push_request.head.sha || github.sha }}
- if: ${{ steps.wait.outputs.conclusion != 'success' }}
run: exit 1
publish:
name: Publish
runs-on: ubuntu-latest
needs: [ wait_static_tests, wait_unit_tests ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Build and publish
env:
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry config virtualenvs.in-project true
poetry install --no-root
poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD
- name: Save dist
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
release:
name: Release
runs-on: ubuntu-latest
needs: publish
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get dist
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Get Tag
id: tag
uses: olegtarasov/get-tag@v2.1.1
- name: Clean CHANGELOG.md
run: |
touch CHANGELOG.md.tmp
npm install -g prettier
prettier --parser markdown --tab-width 4 --prose-wrap never CHANGELOG.md > CHANGELOG.md.tmp
cat CHANGELOG.md.tmp > CHANGELOG.md
- name: Build Release
id: release
uses: MatteoCampinoti94/changelog-to-release@v1.0.6
with:
version-name: ${{ steps.tag.outputs.tag }}
- name: Build Release File
env:
TAG: ${{ steps.tag.outputs.tag }}
RELEASE: ${{ steps.release.outputs.body }}
run: |
touch RELEASE.md
PREVIOUS_TAG="$(git tag -l --sort=-version:refname | head -2 | tail -1)"
printf "%s\n" "$RELEASE" > RELEASE.md
printf "\n## 🔗 Links\n" >> RELEASE.md
printf "\n* %s" "PyPi release: https://pypi.org/project/${GITHUB_REPOSITORY#*/}/${TAG#v}" >> RELEASE.md
printf "\n* %s" "Full changelog: https://github.com/$GITHUB_REPOSITORY/compare/$PREVIOUS_TAG...$TAG" >> RELEASE.md
cat RELEASE.md
printf "\n\n## Dist Files\n"
ls -l dist || echo " no files"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ steps.tag.outputs.tag }}
name: ${{ steps.release.outputs.title }}
body_path: RELEASE.md
files: |
dist/*