Skip to content

Commit 8895cbc

Browse files
lsteinCopilotCopilot
authored
chore: update deploy actions (#190)
* chore: update deploy actions * Update .github/workflows/upload-artifacts.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/deploy.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/deploy.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/deploy.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/deploy.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/deploy.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix typo in deploy workflow version reference (#194) --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 2a3dc8e commit 8895cbc

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,61 @@ name: Deploy Release
22

33
on:
44
workflow_dispatch:
5-
release:
5+
release:
66
types: [published]
7+
78
jobs:
8-
tag-release:
9+
tag-release:
910
runs-on: ubuntu-latest
11+
outputs:
12+
version: ${{ steps.get_version.outputs.version }}
13+
tag: ${{ steps.get_version.outputs.tag }}
1014
steps:
1115
- name: Checkout code
1216
uses: actions/checkout@v4
1317

1418
- name: Set up Python
1519
uses: actions/setup-python@v5
16-
with:
20+
with:
1721
python-version: '3.12'
1822

1923
- name: Extract version from pyproject.toml
2024
id: get_version
2125
run: |
2226
VERSION=$(python -c "
23-
try:
27+
try:
2428
import tomllib
2529
with open('pyproject.toml', 'rb') as f:
2630
data = tomllib.load(f)
2731
print(data['project']['version'])
2832
except Exception as e:
33+
import sys
2934
print(f'Error reading version: {e}', file=sys.stderr)
3035
exit(1)
3136
")
3237
echo "version=$VERSION" >> $GITHUB_OUTPUT
38+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
39+
40+
- name: Check if tag exists
41+
id: check_tag
42+
run: |
43+
if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.get_version.outputs.version }}"; then
44+
echo "Tag already exists"
45+
echo "exists=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "Tag does not exist"
48+
echo "exists=false" >> $GITHUB_OUTPUT
49+
fi
3350
3451
- name: Tag the release
52+
if: steps.check_tag.outputs.exists == 'false'
3553
run: |
3654
git config user.name "github-actions"
3755
git config user.email "github-actions@github.com"
3856
git tag v${{ steps.get_version.outputs.version }}
3957
git push origin v${{ steps.get_version.outputs.version }}
4058
41-
deploy-pypi:
59+
deploy-pypi:
4260
needs: tag-release
4361
uses: ./.github/workflows/deploy-pypi.yml
4462
secrets:
@@ -56,5 +74,7 @@ jobs:
5674
uses: ./.github/workflows/deploy-pyinstaller.yml
5775

5876
upload-release:
59-
needs: [deploy-pypi, deploy-dockerhub, deploy-pyinstaller]
77+
needs: [tag-release, deploy-pypi, deploy-dockerhub, deploy-pyinstaller]
6078
uses: ./.github/workflows/upload-artifacts.yml
79+
with:
80+
tag_name: ${{ needs.tag-release.outputs.tag }}
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
name: Upload Release Artifacts
22

33
on:
4-
workflow_call:
4+
workflow_call:
5+
inputs:
6+
tag_name:
7+
required: true
8+
type: string
9+
510
jobs:
6-
upload-release:
11+
upload-release:
712
runs-on: ubuntu-latest
813
steps:
914
- name: Download CPU installer package artifacts
1015
uses: actions/download-artifact@v4
11-
with:
16+
with:
1217
pattern: "*-cpu-*"
1318
path: artifacts
1419

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

0 commit comments

Comments
 (0)