Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: 📦 improve release CI/CD #104

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading