-
Notifications
You must be signed in to change notification settings - Fork 23
196 lines (161 loc) · 5.2 KB
/
cicd.yml
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: 🚀 CI/CD
on:
push:
jobs:
test_and_build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Load Cached Poetry
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-dependencies-v2
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Load Cached Python Dependencies
uses: actions/cache@v2
with:
path: .venv
key: python-dependencies-${{ hashFiles('**/poetry.lock') }}
- name: Install Python Dependencies
run: poetry install
- name: Install APT Dependencies
uses: upciti/wakemeops-action@v1
with:
packages: |
debhelper
fakeroot
- name: Run ruff format
run: poetry run ruff format
- name: Run ruff check
run: poetry run ruff check
- name: Run pytest
run: poetry run pytest --cov=src --cov-report=term-missing tests
- name: Generate coverage report
shell: bash
run: poetry run coverage xml
- uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
- name: Build single binary application
run: |
poetry install --extras pyinstaller
poetry run poetry-dynamic-versioning
poetry run pyinstaller --onefile src/wheel2deb/__main__.py --name wheel2deb -s
dist/wheel2deb version
dist/wheel2deb
mv dist/wheel2deb wheel2deb_linux_amd64
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: wheel2deb_linux_amd64
path: wheel2deb_linux_amd64
retention-days: 2
publish_release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [test_and_build]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install clog-cli
uses: upciti/wakemeops-action@v1
with:
packages: clog-cli
- name: Build Release Changelog
run: |
clog --setversion $(git tag --sort=creatordate | tail -n1) \
--from $(git tag --sort=creatordate | tail -n2 | head -n1) \
-o changelog.md \
-r https://github.com/upciti/wheel2deb
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: wheel2deb_linux_amd64
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: changelog.md
files: wheel2deb_linux_amd64
publish_pypi:
runs-on: ubuntu-20.04
needs: [test_and_build]
if: startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Load Cached Poetry
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-dependencies-v2
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Get Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build Distribution
run: |
poetry version "$RELEASE_VERSION"
poetry build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
publish_image:
runs-on: ubuntu-latest
needs: [test_and_build]
if: github.event.repository.fork == false && startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: wheel2deb_linux_amd64
- name: Set execute permission
run: chmod +x wheel2deb_linux_amd64
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set docker image tags and labels
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/upciti/wheel2deb
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
build-args: |
WHEEL2DEB_PATH=wheel2deb_linux_amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Check Docker image
run: docker run --rm -i ghcr.io/${{ github.event.repository.full_name }}:latest --help
- name: Publish Docker image
run: |
docker push --all-tags ghcr.io/${{ github.event.repository.full_name }}