Build and publish to PyPI #14
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: Build and publish to PyPI | |
on: | |
push: | |
tags: | |
- 'v*' # push tags to trigger the workflow | |
workflow_dispatch: | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: false | |
jobs: | |
build-wheel: | |
name: wheels | |
runs-on: ubuntu-latest | |
# trigger the workflow only on default branch, or manually | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: cp3{8,9,10,11}-manylinux_x86_64 | |
# force manylinux2014 to avoid compatibility issues on RHEL 7 | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
# install required dependencies: bz2 | |
CIBW_BEFORE_ALL: | | |
# Centos 7 is EOL and is no longer available from the usual mirrors, so switch | |
# to https://vault.centos.org | |
sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf && \ | |
sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/*.repo && \ | |
sed -i 's;^#baseurl=http://mirror;baseurl=https://vault;g' /etc/yum.repos.d/*.repo | |
yum install -y bzip2-devel | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels | |
path: wheelhouse/*.whl | |
build-sdist: | |
name: sdist | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Install bz2 | |
run: | | |
sudo apt-get update && sudo apt-get install libbz2-dev -y | |
- name: Build source distribution | |
run: pipx run build --sdist | |
- name: Upload source distribution | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: dist/*.tar.gz | |
publish: | |
name: publish | |
runs-on: ubuntu-latest | |
needs: [build-wheel, build-sdist] | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Download wheels | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
- name: Move wheels to dist | |
run: | | |
mv dist/wheels/*.whl dist | |
mv dist/sdist/*.tar.gz dist | |
rm -r dist/wheels | |
rm -r dist/sdist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
needs: [build-wheel, build-sdist] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download wheels | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
- name: Move wheels to dist | |
run: | | |
mv dist/wheels/*.whl dist | |
mv dist/sdist/*.tar.gz dist | |
rm -r dist/wheels | |
rm -r dist/sdist | |
- name: Setup Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Generate Changelog | |
run: | | |
npm install -g conventional-changelog-cli | |
conventional-changelog -p angular -i dist/CHANGELOG.md -s | |
- name: Create a new Release | |
uses: ncipollo/release-action@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
# https://github.com/ncipollo/release-action for the full list of arguments | |
artifacts: dist/*.whl,dist/*.tar.gz | |
draft: true # generate a draft release | |
generateReleaseNotes: false | |
bodyFile: dist/CHANGELOG.md | |
# generate a pre-release if 'pre', 'rc', or 'beta' is in the tag name, or triggered manually | |
prerelease: ${{ github.event_name == 'workflow_dispatch' || contains(github.ref, 'beta') || contains(github.ref, 'rc') || contains(github.ref, 'pre') }} | |
# use the tag name if it's a tag, otherwise use the commit hash | |
continue-on-error: true |