Skip to content

Commit

Permalink
build: 📦 improve release CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
darvid committed Jan 25, 2024
1 parent 9c94b2d commit 95a3c8e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
47 changes: 39 additions & 8 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build wheels and source distribution
name: Build
on:
push:
branches:
Expand Down Expand Up @@ -214,40 +214,71 @@ jobs:
name: Publish package
runs-on: ubuntu-latest
concurrency: release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.repository == 'darvid/python-hyperscan'
needs: [build_wheels, build_sdist]
permissions:
id-token: write
pull-requests: write
contents: write
steps:
- name: Checkout python-hyperscan
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

- uses: chainguard-dev/actions/setup-gitsign@main

- name: Check if release needed
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
root_options: "-vv --noop"
# python-semantic-release displays what it would have
# committed if commit is true and noop is set
commit: "true"

- name: Download artifacts
uses: actions/download-artifact@v4
if: steps.release.outputs.released == 'true'

- name: Prepare dist
run: |
mkdir dist
mv ./wheel-*/*.whl dist/
mv ./sdist/*.tar.gz dist/
- name: Create release branch
if: steps.release.outputs.released == 'true'
run: |
# use the same default branch name that create-pull-request uses
git checkout -b create-pull-request/patch
git branch --set-origin-to=origin/create-pull-request/patch
- name: Semantic release
id: release
uses: python-semantic-release/[email protected]
uses: python-semantic-release/[email protected]
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
root_options: "-vv"

- name: Publish package distributions to PyPI
- name: Create PR
uses: peter-evans/[email protected]
if: steps.release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
title: "Release ${{ steps.release.outputs.version }}"

- name: Publish package distributions to GitHub Releases
# if: steps.release.outputs.released == 'true'
if: steps.release.outputs.released == 'true'
uses: python-semantic-release/upload-to-gh-release@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}

- name: Publish package distributions to PyPI
if: steps.release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ version_variables = [
"pdm_build.py:__version__",
]

[tool.semantic_release.branches.release]
match = 'release/v?[\\d\\.\\-]+'
prerelease = false

[tool.semantic_release.commit_parser_options]
major_tags = [":boom:"]
minor_tags = [
Expand Down

0 comments on commit 95a3c8e

Please sign in to comment.