-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (173 loc) · 6.18 KB
/
Copy pathrelease.yml
File metadata and controls
207 lines (173 loc) · 6.18 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Build and Release
on:
# Trigger from rgb-lib repository
repository_dispatch:
types: [rgb-lib-release]
# Manual trigger
workflow_dispatch:
inputs:
rgb_lib_version:
description: 'rgb-lib version to use (e.g., v0.3.0-beta.8)'
required: true
type: string
jobs:
build:
name: Build (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Linux x64 (Ubuntu 22.04 for GLIBC 2.35 compatibility)
- runner: ubuntu-22.04
platform: linux-x86_64
target: x86_64-unknown-linux-gnu
# Linux ARM64 (Ubuntu 22.04 for GLIBC 2.35 compatibility)
- runner: ubuntu-22.04-arm
platform: linux-aarch64
target: aarch64-unknown-linux-gnu
# macOS ARM64 (Apple Silicon)
- runner: macos-latest
platform: macosx-arm64
target: aarch64-apple-darwin
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get rgb-lib version
id: rgb_lib_version
run: |
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ inputs.rgb_lib_version }}" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Update rgb-lib submodule to target version
run: |
cd rgb-lib
git fetch --all --tags
git checkout ${{ steps.rgb_lib_version.outputs.version }}
echo "Checked out rgb-lib version:"
git log --oneline -1
cd ..
shell: bash
- name: Get version for Python package
id: pyversion
run: |
VERSION="${{ steps.rgb_lib_version.outputs.version }}"
# Remove 'v' prefix and convert to PEP 440 format
# v0.3.0-beta.8 -> 0.3.0b8
PY_VERSION=$(echo "$VERSION" | sed 's/^v//' | sed 's/-beta\./b/' | sed 's/-alpha\./a/' | sed 's/-rc\./rc/')
echo "version=$PY_VERSION" >> $GITHUB_OUTPUT
echo "Python version: $PY_VERSION"
- name: Update version in pyproject.toml
run: |
VERSION="${{ steps.pyversion.outputs.version }}"
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
cat pyproject.toml | grep "^version"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Build wheel
run: |
export PLATFORM="${{ matrix.platform }}"
echo "Building for platform: $PLATFORM"
poetry build -vvv
env:
PLATFORM: ${{ matrix.platform }}
- name: List built wheels
run: ls -la dist/ || echo "dist/ not found, checking current directory..." && ls -la
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.platform }}
path: dist/*.whl
retention-days: 5
publish:
name: Publish to PyPI
needs: build
if: always() && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
path: wheels
pattern: wheel-*
merge-multiple: true
- name: List wheels
run: ls -la wheels/
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install twine
run: pip install twine
- name: Publish to PyPI
run: |
twine upload wheels/*.whl --skip-existing || echo "Some packages may already exist, continuing..."
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
release:
name: Create GitHub Release
needs: [build, publish]
if: always() && !cancelled()
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get version info
id: version
run: |
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
VERSION="${{ github.event.client_payload.version }}"
else
VERSION="${{ inputs.rgb_lib_version }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
path: wheels
pattern: wheel-*
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
body: |
## Python bindings for rgb-lib
Based on rgb-lib ${{ steps.version.outputs.version }}
### Installation via pip (recommended)
```bash
pip install rgb-lib
```
### Platforms
| Platform | Wheel |
|----------|-------|
| Linux x64 | `manylinux_2_34_x86_64` |
| Linux ARM64 | `manylinux_2_34_aarch64` |
| macOS ARM64 (Apple Silicon) | `macosx_12_0_arm64` |
### Changes
See [rgb-lib release notes](https://github.com/UTEXO-Protocol/rgb-lib/releases/tag/${{ steps.version.outputs.version }})
draft: false
prerelease: ${{ contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'rc') }}
files: wheels/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}