Official Release #6
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/release.yml | |
name: Official Release | |
on: | |
workflow_dispatch: # This allows manual triggering without inputs | |
jobs: | |
official-release: | |
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 | |
- name: Get latest nightly release | |
id: latest_nightly | |
run: | | |
latest_nightly=$(git describe --tags --match "nightly-v*" --abbrev=0) | |
echo "latest_nightly=$latest_nightly" >> "$GITHUB_OUTPUT" | |
- name: Determine official version | |
id: version | |
run: | | |
nightly_version="${{ steps.latest_nightly.outputs.latest_nightly }}" | |
official_version=$(echo $nightly_version | sed 's/nightly-v//' | sed 's/-nightly\..*//') | |
echo "official_version=$official_version" >> "$GITHUB_OUTPUT" | |
- name: Update version | |
run: | | |
sed -i "s/__version__\s*=\s*['\"].*['\"]/__version__ = '${{ steps.version.outputs.official_version }}'/" uniclip/__init__.py | |
- name: Commit version update | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add uniclip/__init__.py | |
git commit -m "Bump version to ${{ steps.version.outputs.official_version }}" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: Create Official Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.version.outputs.official_version }} | |
release_name: Release ${{ steps.version.outputs.official_version }} | |
draft: false | |
prerelease: false | |
- name: Update README | |
run: | | |
sed -i "s/Current version: .*/Current version: ${{ steps.version.outputs.official_version }}/" README.md | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add README.md | |
git commit -m "Update version in README to ${{ steps.version.outputs.official_version }}" | |
git push |