Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/.release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Release & Publish to PyPI

on:
workflow_dispatch:
inputs:
release-type:
description: 'Specify release type: regular, alpha, beta, or rc'
required: true
default: 'regular'

jobs:
release:
runs-on: ubuntu-latest
env:
# Store the release type from workflow input to reuse it across steps
RELEASE_TYPE: ${{ github.event.inputs.release-type }}

permissions:
contents: write
actions: write

steps:
# Validate the branch
- name: Validate branch
run: |
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then
echo "Error: This workflow can only be run on the main branch."
exit 1
fi

# Validate the release type
- name: Validate release type
run: |
if [[ "$RELEASE_TYPE" != "regular" && "$RELEASE_TYPE" != "alpha" && "$RELEASE_TYPE" != "beta" && "$RELEASE_TYPE" != "rc" ]]; then
echo "Error: Invalid release type '$RELEASE_TYPE'. It must be one of: regular, alpha, beta, or rc."
exit 1
fi

- name: Checkout source code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2

# Install dependencies from requirements.txt
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install wheel twine setuptools build

# Clean dist directory
- name: Clean dist directory
run: rm -rf dist/*

# Install Node.js dependencies
- name: Install Node.js dependencies
run: npm ci

# Set Git user
- name: Set Git user
run: |
git config --global user.email ${{ secrets.GIT_USER_EMAIL }}
git config --global user.name ${{ secrets.GIT_USER_NAME }}

# Run release-it
- name: Run release-it
run: |
if [ "$RELEASE_TYPE" == "regular" ]; then
npx release-it
else
npx release-it --preRelease=$RELEASE_TYPE
fi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
TOKEN_GITHUB: ${{ secrets.TOKEN_GITHUB }}

# Print success message if release-it completes successfully
- name: Print success message
if: success()
run: echo "Release and publishing completed successfully!"

# If the release step fails, print and upload the NPM error log
- name: Print NPM error log
if: failure()
run: |
echo "Release process failed. Check the NPM error log for details."
cat /home/runner/.npm/_logs/*-debug-0.log

# Upload NPM error log if release fails
- name: Upload NPM error log
if: failure()
uses: actions/upload-artifact@v3
with:
name: npm-error-log
path: /home/runner/.npm/_logs/*-debug-0.log
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Ignore Python virtual environments
.venv/
.env/

# Ignore distribution files
dist/
build/
*.egg-info/

# Ignore node_modules
node_modules/

# Ignore log files and temporary files
*.log
*.tmp

# Ignore Python cache files
__pycache__/
*.pyc
37 changes: 37 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://unpkg.com/release-it/schema/release-it.json",
"github": {
"release": true,
"releaseName": "Release ${version}",
"preRelease": false,
"autoGenerate": true,
"tokenRef": "TOKEN_GITHUB",
"contributors": true
},
"hooks": {
"before:bump": [
"python ./script/update_version.py ${version}"
],
"before:release": [
"python setup.py sdist bdist_wheel"
],
"after:release": [
"twine upload dist/*"
]
},
"git": {
"commitMessage": "chore(release): ${version}",
"tagName": "V${version}",
"requireCleanWorkingDir": true,
"push": true
},
"npm": {
"publish": false
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "angular",
"infile": "CHANGELOG.md"
}
}
}
Loading