python_test_project/.gitea/workflows/release.yml

64 lines
1.8 KiB
YAML
Raw Permalink Normal View History

2024-11-11 06:11:21 -08:00
name: Upload Python Package
permissions:
contents: write
on:
push:
# Sequence of patterns matched against refs/tags
tags:
2024-11-13 07:54:42 -08:00
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
2024-11-11 06:11:21 -08:00
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
- name: Generate Changelog
run: .gitea/release_message.sh > release_message.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: release_message.md
2024-11-13 06:59:48 -08:00
deploy:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
2024-11-13 07:54:42 -08:00
- name: Check version match
run: |
REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')
2024-11-13 08:06:08 -08:00
if [ "$(cat $REPOSITORY_NAME/VERSION)" = "${GITHUB_REF_NAME:1}" ] ; then
2024-11-13 07:54:42 -08:00
echo "Version matches successfully!"
else
echo "Version must match!"
2024-11-13 08:19:59 -08:00
exit -1
2024-11-13 07:54:42 -08:00
fi
2024-11-13 06:59:48 -08:00
- name: Build and publish
env:
2024-11-13 08:19:59 -08:00
TWINE_USERNAME: gitearobot
TWINE_PASSWORD: ${{ secrets.PACKAGE_GITEA_PAT }}
2024-11-13 06:59:48 -08:00
run: |
REPOSITORY_OWNER=$(echo "$GITHUB_REPOSITORY" | awk -F '/' '{print $1}')
python setup.py sdist bdist_wheel
2024-11-13 08:19:59 -08:00
twine upload --repository-url https://git.disi.dev/api/packages/$REPOSITORY_OWNER/pypi dist/*
2024-11-13 06:59:48 -08:00