-
Notifications
You must be signed in to change notification settings - Fork 301
152 lines (151 loc) · 5.21 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
name: Create release, build and upload release assets
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: check-version
run: |
version=$(echo "${{ github.ref }}" | cut -d/ -f3)
grep ${version} VERSION.txt || exit 1
create-release:
needs: check-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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@v4
with:
name: upload_url.txt
path: upload_url.txt
build-and-upload-deb-asset:
needs: create-release
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@v4
with:
fetch-depth: 0
ref: master
- name: git fetch --all
run: |
git config --global --add safe.directory /__w/openvpn-monitor/openvpn-monitor
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/download-artifact@v4
with:
name: upload_url.txt
path: /home/runner/work/openvpn-monitor/openvpn-monitor
- 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: Get version
run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Upload deb
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
asset_name: ${{ format('python3-openvpn-monitor_{0}-1_all.deb', env.version) }}
asset_path: ${{ format('deb_dist/python3-openvpn-monitor_{0}-1_all.deb', env.version) }}
asset_content_type: application/vnd.debian.binary-package
build-and-upload-rpm-asset:
needs: create-release
runs-on: ubuntu-latest
container:
image: rockylinux:9
steps:
- name: Install build dependencies
run: |
dnf -y install rpm-build python3 python3-setuptools git
- uses: actions/checkout@v4
- name: Download upload_url artifact
uses: actions/download-artifact@v4
with:
name: upload_url.txt
- name: Get upload_url
run: |
export upload_url=$(cat upload_url.txt)
rm upload_url.txt
echo "upload_url=${upload_url}" >> $GITHUB_ENV
- name: Build rpm packages
run: |
sed -i -e "s/name='.*/name='python3-openvpn-monitor',/" setup.py
python3 setup.py bdist_rpm
- name: Get version
run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Upload rpm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
asset_name: ${{ format('python3-openvpn-monitor-{0}-1.noarch.rpm', env.version) }}
asset_path: ${{ format('dist/python3-openvpn-monitor-{0}-1.noarch.rpm', env.version) }}
asset_content_type: application/x-rpm
upload-package-to-pypi:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
run: |
python setup.py sdist bdist_wheel
twine upload dist/*