-
Notifications
You must be signed in to change notification settings - Fork 16
180 lines (152 loc) · 5.04 KB
/
Copy pathrego_python.yml
File metadata and controls
180 lines (152 loc) · 5.04 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
name: rego-python
on:
push:
paths:
- ".github/workflows/rego-python.yml"
- "glitch/rego/rego_python/**"
workflow_dispatch:
permissions:
contents: write
jobs:
build-binaries:
name: Build Rego Python binaries
runs-on: ${{ matrix.os_runner }}
strategy:
matrix:
include:
# Linux
- os: linux
arch: amd64
os_runner: ubuntu-latest
- os: linux
arch: arm64
os_runner: ubuntu-24.04-arm
# macOS
- os: darwin
arch: amd64
os_runner: macos-15-intel
- os: darwin
arch: arm64
os_runner: macos-latest
# Windows
- os: windows
arch: amd64
os_runner: windows-latest
#- os: windows
# arch: arm64
# os_runner: windows-11-arm
# This fails the build because the runner is still limited
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 'stable'
cache-dependency-path: glitch/rego/rego_python/src/rego_python/go/go.sum
- name: Build binary
shell: bash
run: |
OS=${{ matrix.os }}
ARCH=${{ matrix.arch }}
# Determine file extension
if [ "$OS" = "windows" ]; then
EXT="dll"
elif [ "$OS" = "darwin" ]; then
EXT="dylib"
else
EXT="so"
fi
OUTPUT="../bin/librego-$OS-$ARCH.$EXT"
echo "Building $OUTPUT ..."
cd glitch/rego/rego_python/src/rego_python/go
GOOS=$OS GOARCH=$ARCH go build -o "$OUTPUT" -buildmode=c-shared regolib.go
rm -f ../bin/librego-*.h
- name: List bin folder
run: ls -l glitch/rego/rego_python/src/rego_python/bin/
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: librego-${{ matrix.os }}-${{ matrix.arch }}
path: glitch/rego/rego_python/src/rego_python/bin/librego-${{ matrix.os }}-${{ matrix.arch }}.*
retention-days: 1
build-package:
name: Build Python package
runs-on: ubuntu-latest
needs: build-binaries
steps:
- uses: actions/checkout@v4
# Download all binary artifacts into bin/
- uses: actions/download-artifact@v4
with:
path: glitch/rego/rego_python/src/rego_python/bin
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install build tools
run: |
python -m pip install --upgrade build twine
- name: Build wheel and sdist
working-directory: glitch/rego/rego_python
run: python -m build
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: python-package
path: glitch/rego/rego_python/dist/*
retention-days: 1
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build-package
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(grep '^version = ' glitch/rego/rego_python/pyproject.toml | sed -E 's/version = "(.*)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version extracted: $VERSION"
- name: Create tag for release
run: |
git config user.name "rego_python-release-bot"
git config user.email "rego_python@users.noreply.github.com"
TAG=rego_python-v${{ steps.get_version.outputs.version }}
git tag $TAG
git push origin $TAG
NON_PREFIXED_TAG=v${{ steps.get_version.outputs.version }}
if git rev-parse "$NON_PREFIXED_TAG" >/dev/null 2>&1; then
echo "WARNING: Non-prefixed tag $NON_PREFIXED_TAG exists. Consider deleting it to avoid confusion."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download built package and binaries
uses: actions/download-artifact@v4
with:
path: release_assets
merge-multiple: true
- name: List downloaded assets
run: |
echo "Listing contents of release_assets directory:"
ls -lR release_assets
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: "rego_python-v${{ steps.get_version.outputs.version }}"
name: "Rego Python v${{ steps.get_version.outputs.version }}"
files: |
release_assets/*.whl
release_assets/*.tar.gz
release_assets/*.so
release_assets/*.dylib
release_assets/*.dll
generate_release_notes: false
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}