Streamline CI/CD Workflows and Improve Version Management #1
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
# File: .github/workflows/nightly-release.yml | |
name: Nightly Release | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
create-nightly: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- 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 semver | |
# Determine the current release version and create the nightly version | |
- name: Determine nightly version | |
id: version | |
run: | | |
# Get the current version from __init__.py | |
current_version=$(grep -oP "__version__\s*=\s*['\"]?\K[^'\"']+" uniclip/__init__.py || echo "0.0.0") | |
echo "Current version: $current_version" | |
# Create the nightly version: current_version+nightly.GITHUB_RUN_NUMBER | |
nightly_version="${current_version}+nightly.${GITHUB_RUN_NUMBER}" | |
echo "nightly_version=$nightly_version" >> "$GITHUB_OUTPUT" | |
echo "Nightly version: $nightly_version" | |
- name: Create Nightly Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: nightly-v${{ steps.version.outputs.nightly_version }} | |
release_name: Nightly Release ${{ steps.version.outputs.nightly_version }} | |
draft: false | |
prerelease: true |