Skip to content

Merge pull request #535 from auebergang/master #57

Merge pull request #535 from auebergang/master

Merge pull request #535 from auebergang/master #57

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 furlongm@gmail.com
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: furlongm@gmail.com
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:buster
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/download-artifact@v1
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:
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/upload-release-asset@v1.0.1
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/upload-release-asset@v1.0.1
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:stream8
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/download-artifact@v1
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/upload-release-asset@v1.0.1
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/upload-release-asset@v1.0.1
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/*