-
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
1 changed file
with
64 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,64 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
if: contains(github.event.head_commit.message, 'make-a-release') | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install hatch twine | ||
- name: Extract Version from __init__.py | ||
id: extract_version | ||
run: | | ||
VERSION=$(python -c "import re; | ||
import pathlib; | ||
init_file = pathlib.Path('snipe/__init__.py'); | ||
content = init_file.read_text(); | ||
match = re.search(r'__version__\s*=\s*[\'\"]([^\'\"]+)[\'\"]', content); | ||
print(match.group(1) if match else '0.0.0')") | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Build package | ||
run: | | ||
hatch build | ||
- name: Upload to PyPI Test Server | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} | ||
run: | | ||
python -m pip install twine | ||
twine upload --repository-url https://test.pypi.org/legacy/ dist/* | ||
- name: Create Git Tag | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}" | ||
git push origin "v${{ env.VERSION }}" | ||
- name: Create GitHub Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: "v${{ env.VERSION }}" | ||
name: "v${{ env.VERSION }}" | ||
body: | | ||
Release version ${{ env.VERSION }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |