-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (69 loc) · 2.5 KB
/
backend-release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Automated Backend Release Process
on:
push:
branches:
- main
paths:
- "backend/**"
jobs:
create-release-and-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3.11 -
- name: Install dependencies with Poetry
run: |
poetry install
- name: Determine Version Change
id: version_check
run: |
VERSION="backend@v$(poetry version -s)"
echo "Current version: $VERSION"
LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases?per_page=5" | \
jq -r '.[] | select(.tag_name | startswith("backend@")).tag_name' | head -n 1)
echo "Latest release version: $LATEST_RELEASE"
if [ "$VERSION" != "$LATEST_RELEASE" ]; then
echo "Version has changed."
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "new_version=$VERSION" >> $GITHUB_OUTPUT
else
echo "No version change detected."
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
- name: Call Reusable Workflow to Build Backend for Linux
uses: ../.github/workflows/build-backend-executable.yaml
with:
platform: linux
- name: Call Reusable Workflow to Build Backend for macOS
uses: ../.github/workflows/build-backend-executable.yaml
with:
platform: macos
- name: Call Reusable Workflow to Build Backend for Windows
uses: ../.github/workflows/build-backend-executable.yaml
with:
platform: windows
- name: Create Release
if: steps.version_check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version_check.outputs.new_version }}
generate_release_notes: True
- name: Configure Poetry for PyPI
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
- name: Build and publish to PyPI
if: steps.version_check.outputs.version_changed == 'true'
run: |
poetry build
poetry publish