-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
07722d8
commit ad38d4e
Showing
2 changed files
with
106 additions
and
255 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,58 @@ | ||
name: Publish Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Trigger on push to main branch | ||
|
||
jobs: | ||
release: | ||
name: Create GitHub Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout the code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Set up Python | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
# Step 3: Install dependencies | ||
- name: Install dependencies | ||
run: pip install toml | ||
|
||
# Step 4: Extract version from pyproject.toml | ||
- name: Extract version | ||
id: get_version | ||
run: | | ||
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
# Step 5: Check if tag already exists | ||
- name: Check if tag exists | ||
id: check_tag | ||
run: | | ||
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then | ||
echo "Tag v${{ env.VERSION }} already exists." | ||
exit 0 | ||
fi | ||
# Step 6: Create and push a new tag (if it doesn't exist) | ||
- name: Create Git tag | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}" | ||
git push origin "v${{ env.VERSION }}" | ||
# Step 7: Create GitHub release (if tag didn't exist) | ||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: "v${{ env.VERSION }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Oops, something went wrong.