-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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
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. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Create Release | ||
|
||
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 }} |