name: Build and Release run-name: ${{ gitea.actor }} preparing release on: push: tags: - 'v*' workflow_dispatch: inputs: version: description: 'Release version (e.g., v0.6.1)' required: true default: 'v0.6.1' jobs: build: runs-on: ubuntu-latest needs: [] steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.12' - name: Install Poetry uses: snok/install-poetry@v1 with: version: latest virtualenvs-create: true virtualenvs-in-project: true - name: Load cached venv id: cached-poetry-dependencies uses: actions/cache@v3 with: path: .venv key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - name: Install dependencies if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: poetry install --with dev - name: Build package run: | poetry build echo "Package built successfully!" ls -la dist/ - name: Generate changelog id: changelog run: | echo "## What's new in this version" > CHANGELOG.md echo "" >> CHANGELOG.md echo "### New Features" >> CHANGELOG.md echo "- Add description of new features" >> CHANGELOG.md echo "" >> CHANGELOG.md echo "### Bug Fixes" >> CHANGELOG.md echo "- Add description of bug fixes" >> CHANGELOG.md echo "" >> CHANGELOG.md echo "### Technical Changes" >> CHANGELOG.md echo "- Add description of technical improvements" >> CHANGELOG.md echo "" >> CHANGELOG.md echo "### Dependencies" >> CHANGELOG.md echo "- Updated dependencies to latest versions" >> CHANGELOG.md echo "" >> CHANGELOG.md echo "---" >> CHANGELOG.md echo "**Full Changelog:** https://gitea.example.com/${{ gitea.repository }}/compare/v0.5.0...${{ github.ref_name }}" >> CHANGELOG.md - name: Upload build artifacts uses: actions/upload-artifact@v3 with: name: dist-${{ github.ref_name }} path: | dist/ CHANGELOG.md - name: Build completed run: echo "Build completed! Artifacts ready for release." release: runs-on: ubuntu-latest needs: build if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' steps: - name: Checkout repository uses: actions/checkout@v4 - name: Download build artifacts uses: actions/download-artifact@v3 with: name: dist-${{ github.ref_name || github.event.inputs.version }} - name: Read changelog id: changelog run: | if [ -f CHANGELOG.md ]; then echo "CHANGELOG<> $GITHUB_OUTPUT cat CHANGELOG.md >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT else echo "CHANGELOG=Automatically generated release" >> $GITHUB_OUTPUT fi - name: Create Release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref_name || github.event.inputs.version }} release_name: PyServeX ${{ github.ref_name || github.event.inputs.version }} body: | ${{ steps.changelog.outputs.CHANGELOG }} ## Installation ```bash pip install pyserve==${{ github.ref_name || github.event.inputs.version }} ``` ## Usage ```bash pyserve --help ``` draft: true prerelease: false - name: Upload Release Asset (wheel) uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./dist/pyserve-*.whl asset_name: pyserve-${{ github.ref_name || github.event.inputs.version }}.whl asset_content_type: application/octet-stream - name: Upload Release Asset (tarball) uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./dist/pyserve-*.tar.gz asset_name: pyserve-${{ github.ref_name || github.event.inputs.version }}.tar.gz asset_content_type: application/gzip - name: Release created run: echo "Draft release created! Check and publish in Gitea interface."