bump version to 2.0.2 #16
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* |