Skip to content

Commit

Permalink
Issue #156: Adds workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SonOfLope committed Oct 17, 2024
1 parent 841c548 commit 7b3a0f0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/workflow-pyproject-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Reusable Workflow for Python Package Release

## Purpose

Automate the release process for Python packages, using the version from
`pyproject.toml` to create a GitHub release.

## Steps

1. Checkout the repository code
2. Parse the version from `pyproject.toml`
3. Create a new version tag
4. Push the tag to the repository
5. Automatically generate release notes and publish a new GitHub release

## Input

This workflow automatically uses the repository name and parses the version from
the `pyproject.toml` file. No additional input is required when calling the
workflow.
41 changes: 41 additions & 0 deletions .github/workflows/workflow-pyproject-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Create Release

Check warning on line 1 in .github/workflows/workflow-pyproject-release.yml

View workflow job for this annotation

GitHub Actions / yaml-lint-check

1:1 [document-start] missing document start "---"

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git for GitHub Actions
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
- name: Parse version from pyproject.toml
id: parse_version
run: |
version=$(grep -Po '(?<=^version = ")[^"]*' pyproject.toml)
echo "version=$version" >> $GITHUB_ENV
- name: Tag the version and push
run: |
git tag -a v${{ env.version }} -m "Release ${{ env.version }}"
git push origin v${{ env.version }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: "v${{ env.version }}"
name: "${{ github.repository }} v${{ env.version }}"
body: "Release version ${{ env.version }} for ${{ github.repository }}."
allowUpdates: true
generateReleaseNotes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 7b3a0f0

Please sign in to comment.