Skip to content
Merged
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
32 changes: 26 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,61 @@ name: Deploy Release

on:
workflow_dispatch:
release:
release:
types: [published]

jobs:
tag-release:
tag-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
tag: ${{ steps.get_version.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
with:
python-version: '3.12'

- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "
try:
try:
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
print(data['project']['version'])
except Exception as e:
import sys
print(f'Error reading version: {e}', file=sys.stderr)
exit(1)
")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT

- name: Check if tag exists
id: check_tag
run: |
if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.get_version.outputs.version }}"; then
echo "Tag already exists"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Tag does not exist"
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Tag the release
if: steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git tag v${{ steps.get_version.outputs.version }}
git push origin v${{ steps.get_version.outputs.version }}

deploy-pypi:
deploy-pypi:
needs: tag-release
uses: ./.github/workflows/deploy-pypi.yml
secrets:
Expand All @@ -56,5 +74,7 @@ jobs:
uses: ./.github/workflows/deploy-pyinstaller.yml

upload-release:
needs: [deploy-pypi, deploy-dockerhub, deploy-pyinstaller]
needs: [tag-release, deploy-pypi, deploy-dockerhub, deploy-pyinstaller]
uses: ./.github/workflows/upload-artifacts.yml
with:
tag_name: ${{ needs.tag-release.outputs.tag }}
12 changes: 9 additions & 3 deletions .github/workflows/upload-artifacts.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: Upload Release Artifacts

on:
workflow_call:
workflow_call:
inputs:
tag_name:
required: true
type: string

jobs:
upload-release:
upload-release:
runs-on: ubuntu-latest
steps:
- name: Download CPU installer package artifacts
uses: actions/download-artifact@v4
with:
with:
pattern: "*-cpu-*"
path: artifacts

Expand All @@ -18,6 +23,7 @@ jobs:
- name: Upload artifacts to GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag_name }}
files: artifacts/*-cpu-*/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}