Skip to content

Commit 995816f

Browse files
add pipeline
1 parent a32405c commit 995816f

File tree

1 file changed

+80
-18
lines changed

1 file changed

+80
-18
lines changed

.github/workflows/release.yaml

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,94 @@
1-
name: Trigger Jenkins Job
1+
name: Release Pipeline
22

33
on:
44
push:
55
branches:
6+
- master
67
- latest
7-
paths:
8-
- pyproject.toml
98

109
jobs:
11-
trigger-jenkins:
12-
runs-on: self-hosted
13-
10+
beta-release:
11+
name: Beta Release
12+
runs-on: ubuntu-latest
13+
if: github.ref == 'refs/heads/master'
14+
1415
steps:
1516
- name: Checkout code
16-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11'
23+
24+
- name: Install dependencies
25+
run: |
26+
pip install --quiet build twine
27+
28+
- name: Modify package name for beta
29+
run: |
30+
sed -i -E 's/^(name *= *")superstream-clients(")/\1superstream-clients-beta\2/' pyproject.toml
31+
32+
- name: Build package
33+
run: python -m build
34+
35+
- name: Publish to PyPI
36+
env:
37+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
38+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
39+
run: |
40+
twine upload dist/*
1741
18-
- name: Trigger Jenkins Job
42+
prod-release:
43+
name: Production Release
44+
runs-on: ubuntu-latest
45+
if: github.ref == 'refs/heads/latest'
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v5
53+
with:
54+
python-version: '3.11'
55+
56+
- name: Install dependencies
57+
run: |
58+
pip install --quiet build twine toml
59+
60+
- name: Build package
61+
run: python -m build
62+
63+
- name: Publish to PyPI
1964
env:
20-
JENKINS_TOKEN: ${{ secrets.JENKINS_TOKEN }}
65+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
66+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
67+
run: |
68+
twine upload dist/*
69+
70+
- name: Get version from pyproject.toml
71+
id: get_version
2172
run: |
22-
HTTP_STATUS=$(curl -w "%{http_code}" -o /tmp/jenkins_response.txt -f -X POST \
23-
"https://jenkins.superstream.ai/job/DevOps/job/Superstream/job/SDK/job/superstream-clients-python/buildWithParameters?DEPLOYMENT_TYPE=production" \
24-
--user "[email protected]:$JENKINS_TOKEN")
73+
VERSION=$(python3 -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
74+
echo "version=$VERSION" >> $GITHUB_OUTPUT
75+
echo "Version: $VERSION"
2576
26-
if [ $? -ne 0 ] || [ "$HTTP_STATUS" -ne 201 ] && [ "$HTTP_STATUS" -ne 200 ]; then
27-
echo "Jenkins trigger failed with HTTP status: $HTTP_STATUS"
28-
cat /tmp/jenkins_response.txt
29-
exit 1
30-
fi
77+
- name: Create Git tag
78+
run: |
79+
git config user.email "[email protected]"
80+
git config user.name "GitHub Actions"
81+
git tag -a ${{ steps.get_version.outputs.version }} -m "${{ steps.get_version.outputs.version }}"
82+
git push origin ${{ steps.get_version.outputs.version }}
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Create GitHub Release
87+
uses: softprops/action-gh-release@v1
88+
with:
89+
tag_name: ${{ steps.get_version.outputs.version }}
90+
files: dist/superstream_clients-${{ steps.get_version.outputs.version }}.tar.gz
91+
generate_release_notes: true
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3194

32-
echo "Successfully triggered Jenkins build (HTTP $HTTP_STATUS)"

0 commit comments

Comments
 (0)