-
Notifications
You must be signed in to change notification settings - Fork 1
111 lines (94 loc) · 3.3 KB
/
Copy pathrelease.yaml
File metadata and controls
111 lines (94 loc) · 3.3 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Release
on:
workflow_dispatch:
jobs:
github_release:
name: GitHub Release
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ref: main
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install semantic release and plugins
run: |
# conventional-changelog-conventionalcommits is loaded at runtime by
# @semantic-release/release-notes-generator@14 (which only ships it as
# a devDependency). It must be pinned: v10 broke the v9 preset API and
# silently produced empty release notes. Keep this in lockstep with the
# release-notes-generator major that semantic-release@24 resolves.
npm install -g semantic-release@v24.2.1 \
conventional-changelog-cli \
conventional-changelog-conventionalcommits@9.3.1 \
@semantic-release/changelog \
@semantic-release/exec \
@semantic-release/git \
@semantic-release/github
- name: Semantic Release Dry Run
id: semantic
run: |
dry_run_output=$(semantic-release --dry-run 2>&1 || true)
echo "$dry_run_output"
# Check if there are no changes
if [[ "$dry_run_output" == *"no new version is released"* ]]; then
echo "No new release needed"
echo "new_release_published=false" >> $GITHUB_OUTPUT
exit 0
fi
# Extract version from dry run output
version=$(echo "$dry_run_output" | grep -oiP "the next release version is \K[0-9]+\.[0-9]+\.[0-9]+")
if [ -z "$version" ]; then
echo "::error ::Could not determine version"
exit 1
fi
echo "new_release_version=$version" >> $GITHUB_OUTPUT
# Run actual release
if semantic-release; then
echo "Release successful"
echo "new_release_published=true" >> $GITHUB_OUTPUT
else
echo "Release failed"
exit 1
fi
env:
CI: true
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN_RAG_INTEGRATION }}
publish:
name: Publish to PyPI
needs: github_release
if: needs.github_release.outputs.new_release_published == 'true'
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Fetch changes on main
run: git pull origin main
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*