Skip to content

Commit 676f058

Browse files
committed
wip
1 parent 6eb2805 commit 676f058

File tree

1 file changed

+62
-18
lines changed

1 file changed

+62
-18
lines changed

.github/workflows/publish.yml

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,77 @@
1-
name: Publish Python Package
1+
name: Create and Publish Release
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags
7+
branches-ignore:
8+
- '**' # Ignore branch pushes, only trigger on tags
69

710
jobs:
8-
deploy:
11+
publish-pypi:
12+
environment:
13+
name: pypi
914
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
packages: write
18+
id-token: write
19+
1020
steps:
1121
- uses: actions/checkout@v3
12-
13-
- name: Set up Python
14-
uses: actions/setup-python@v4
1522
with:
16-
python-version: '3.x'
23+
fetch-depth: 0
24+
- uses: ./.github/actions/build-elroy
1725

18-
- name: Install uv
19-
run: |
20-
curl -LsSf https://astral.sh/uv/install.sh | sh
21-
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
22-
23-
- name: Build package
26+
- name: Publish to PyPI
27+
env:
28+
TWINE_USERNAME: __token__
29+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
2430
run: |
31+
pip install --user uv
32+
uv venv
33+
source .venv/bin/activate
2534
uv pip install build
2635
python -m build
36+
uv pip install twine
37+
twine upload dist/*
2738
28-
- name: Publish to PyPI
39+
create-github-release:
40+
environment:
41+
name: pypi
42+
needs: [publish-pypi]
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
with:
47+
fetch-depth: 0
48+
49+
- name: Create GitHub Release
50+
uses: actions/create-release@v1
51+
with:
52+
tag_name: ${{ github.ref }}
53+
release_name: Release ${{ github.ref }}
54+
draft: false
55+
prerelease: false
56+
body_path: CHANGELOG.md
2957
env:
30-
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
update-stable-and-deploy-branch:
60+
environment:
61+
name: pypi
62+
needs: [create-github-release]
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v3
66+
with:
67+
fetch-depth: 0
68+
- name: Update stable branch
3169
run: |
32-
uv pip install twine
33-
python -m twine upload --repository pypi dist/* -u __token__ -p $PYPI_API_TOKEN
70+
git config --global user.name 'GitHub Actions'
71+
git config --global user.email 'actions@github.com'
72+
git checkout stable || git checkout -b stable
73+
git reset --hard ${GITHUB_REF}
74+
git push -f origin stable
75+
git checkout deploy || git checkout -b deploy
76+
git reset --hard ${GITHUB_REF}
77+
git push -f origin deploy

0 commit comments

Comments
 (0)