-
Notifications
You must be signed in to change notification settings - Fork 79
222 lines (221 loc) · 7.85 KB
/
create-release-and-upload-assets.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Create release, build and upload release assets
on:
push:
tags:
- 'v*'
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- name: git fetch --all
run: |
git fetch --all
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Create upload_url artifact
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > upload_url.txt
- name: Upload upload_url artifact
uses: actions/upload-artifact@v1
with:
name: upload_url.txt
path: upload_url.txt
update-version-and-changelog:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- name: git fetch --all
run: |
git fetch --all
- name: git config
run: |
git config user.email [email protected]
git config user.name 'Marcus Furlong'
- name: Install dependencies
run: |
sudo apt update
sudo apt -y install python3-setuptools debhelper dh-exec dh-python git-buildpackage
- name: Update repo version if required
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MSG: |
auto-commit to update version
skip-checks: true
run: |
echo "${{ github.ref }}" | cut -dv -f2 > VERSION.txt
git add VERSION.txt
git diff --quiet && git diff --staged --quiet || git commit -m "${COMMIT_MSG}"
git push origin master
- name: Update debian changelog
env:
EMAIL: [email protected]
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MSG: |
auto-commit to update debian changelog
skip-checks: true
run: |
gbp dch --new-version=$(cat VERSION.txt)-1 --release --distribution=stable --spawn-editor=never --commit --commit-msg="${COMMIT_MSG}"
git push origin master
build-and-upload-deb-assets:
needs: update-version-and-changelog
runs-on: ubuntu-latest
container:
image: debian:bookworm
steps:
- name: Install build dependencies
run: |
apt update
export DEBIAN_FRONTEND=noninteractive
apt -y install python3-setuptools debhelper dh-exec dh-python git-buildpackage
- name: Fix sh so env vars propogate
run: |
rm /bin/sh
ln -sf /bin/bash /bin/sh
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- name: git fetch --all
run: |
git config --global --add safe.directory /__w/patchman/patchman
git fetch --all
- name: Get version
run: |
export version=$(echo "${{ github.ref }}" | cut -dv -f2)
echo "version=${version}" >> $GITHUB_ENV
- name: Download upload_url artifact
uses: actions/[email protected]
with:
name: upload_url.txt
path: /home/runner/work/patchman/patchman
- name: Get upload_url
run: |
export upload_url=$(<upload_url.txt)
rm upload_url.txt
echo "upload_url=${upload_url}" >> $GITHUB_ENV
- name: Build deb packages
env:
EMAIL: [email protected]
COMMIT_MSG: |
auto-commit
skip-checks: true
run: |
export version=$(echo "${{ github.ref }}" | cut -dv -f2)
echo "${version}" > VERSION.txt
git add VERSION.txt
git diff --quiet && git diff --staged --quiet || git commit -m "${COMMIT_MSG}"
gbp dch --new-version=${version}-1 --release --distribution=stable --spawn-editor=never --commit --commit-msg="${COMMIT_MSG}"
git tag --delete v${version}
git tag v${version}
gbp buildpackage --git-upstream-tree=${{ github.ref }} -uc -us
- name: Upload python3-patchman deb
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
asset_name: ${{ format('python3-patchman_{0}-1_all.deb', env.version) }}
asset_path: ../${{ format('python3-patchman_{0}-1_all.deb', env.version) }}
asset_content_type: application/vnd.debian.binary-package
- name: Upload patchman-client deb
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
asset_name: ${{ format('patchman-client_{0}-1_all.deb', env.version) }}
asset_path: ../${{ format('patchman-client_{0}-1_all.deb', env.version) }}
asset_content_type: application/vnd.debian.binary-package
build-and-upload-rpm-assets:
needs: update-version-and-changelog
runs-on: ubuntu-latest
container:
image: quay.io/centos/centos:stream9
steps:
- name: Install build dependencies
run: |
dnf -y install epel-release
dnf -y install rpm-build python3 python3-setuptools git
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- name: git fetch --all
run: |
git config --global --add safe.directory /__w/patchman/patchman
git fetch --all
- name: Get version
run: |
export version=$(echo "${{ github.ref }}" | cut -dv -f2)
echo "version=${version}" >> $GITHUB_ENV
- name: Download upload_url artifact
uses: actions/[email protected]
with:
name: upload_url.txt
path: /home/runner/work/patchman/patchman
- name: Get upload_url
run: |
export upload_url=$(<upload_url.txt)
rm upload_url.txt
echo "upload_url=${upload_url}" >> $GITHUB_ENV
- name: Build rpm packages
run: |
python3 setup.py bdist_rpm --python=/usr/bin/python3
rpmbuild -bb patchman-client.spec
- name: Upload patchman rpm
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
asset_name: ${{ format('patchman-{0}-1.noarch.rpm', env.version) }}
asset_path: ${{ format('dist/patchman-{0}-1.noarch.rpm', env.version) }}
asset_content_type: application/x-rpm
- name: Upload patchman-client rpm
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
asset_name: ${{ format('patchman-client-{0}-1.noarch.rpm', env.version) }}
asset_path: ${{ format('dist/noarch/patchman-client-{0}-1.noarch.rpm', env.version) }}
asset_content_type: application/x-rpm
upload-package-to-pypi:
needs: update-version-and-changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Set version
run: |
echo "${{ github.ref }}" | cut -dv -f2 > VERSION.txt
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 setup.py sdist bdist_wheel
twine upload dist/*