mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-18 13:15:46 +00:00
The macOS job could upload to the latest release before the Linux job recreated it, causing the macOS wheel to be lost. Now wait for the Linux wheel to appear in latest first. Made-with: Cursor
164 lines
5.7 KiB
YAML
164 lines
5.7 KiB
YAML
name: Release (pyosys wheels)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build-linux-wheel:
|
|
runs-on: ubuntu-latest
|
|
name: Build Linux amd64 wheel
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
|
|
- name: Build wheel in Alpine container
|
|
run: |
|
|
docker run --rm \
|
|
-v "${{ github.workspace }}:/src" \
|
|
-w /src \
|
|
--platform linux/amd64 \
|
|
alpine:3.20 sh -c '
|
|
set -ex
|
|
apk add --no-cache \
|
|
build-base bison flex flex-dev gperf \
|
|
tcl-dev readline-dev zlib-dev libffi-dev \
|
|
libdwarf-dev elfutils-dev \
|
|
python3 python3-dev py3-pip py3-setuptools py3-wheel \
|
|
git pkgconf ccache
|
|
|
|
git config --global --add safe.directory /src
|
|
git submodule foreach --recursive git config --global --add safe.directory \$toplevel/\$sm_path
|
|
|
|
# Alpine/musl compatibility shims for Verific tclmain link step
|
|
ln -sf /usr/lib/libtcl8.6.so /usr/lib/libtcl.so
|
|
echo "void dummy_nsl(void){}" | gcc -shared -o /usr/lib/libnsl.so -x c -
|
|
|
|
# Build Verific TCL main (needed before Yosys)
|
|
cd /src/verific/tclmain
|
|
make
|
|
cd /src
|
|
|
|
# Build the wheel via setup.py
|
|
pip install --break-system-packages pybind11 cxxheaderparser
|
|
_PYOSYS_OVERRIDE_VER=$(
|
|
grep "^YOSYS_VER " Makefile | head -1 | sed "s/.*:= *//" | tr "+" "."
|
|
) python3 setup.py bdist_wheel --dist-dir /src/dist
|
|
'
|
|
|
|
- name: Generate release notes
|
|
id: meta
|
|
run: |
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
FULL_SHA=$(git rev-parse HEAD)
|
|
DATE=$(date -u +%Y-%m-%d)
|
|
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
|
|
echo "date=$DATE" >> "$GITHUB_OUTPUT"
|
|
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
|
|
printf '%s\n' \
|
|
"Automated build from \`main\` @ [\`${SHORT_SHA}\`](${REPO_URL}/commit/${FULL_SHA})" \
|
|
"" \
|
|
"**Built:** ${DATE}" \
|
|
"" \
|
|
"### Assets" \
|
|
"| File | Platform |" \
|
|
"|------|----------|" \
|
|
"| \`pyosys-*-linux_x86_64.whl\` | Linux x86-64 |" \
|
|
"| \`pyosys-*-macosx_*_arm64.whl\` | macOS Apple Silicon |" \
|
|
"" \
|
|
"### Installation" \
|
|
"\`\`\`bash" \
|
|
"pip install pyosys-*.whl" \
|
|
"\`\`\`" \
|
|
> release_notes.md
|
|
|
|
- name: Create permanent release
|
|
run: |
|
|
TAG="build-${{ steps.meta.outputs.date }}-${{ steps.meta.outputs.short_sha }}"
|
|
gh release create "$TAG" \
|
|
dist/*.whl \
|
|
--target "${{ github.sha }}" \
|
|
--title "Build ${{ steps.meta.outputs.date }} (${{ steps.meta.outputs.short_sha }})" \
|
|
--notes-file release_notes.md
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Update latest release
|
|
run: |
|
|
git tag -f latest HEAD
|
|
git push -f origin latest
|
|
gh release delete latest --yes 2>/dev/null || true
|
|
gh release create latest \
|
|
dist/*.whl \
|
|
--target "${{ github.sha }}" \
|
|
--title "Latest Build (${{ steps.meta.outputs.date }})" \
|
|
--notes-file release_notes.md \
|
|
--prerelease
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
build-macos-wheel:
|
|
runs-on: macos-15
|
|
name: Build macOS arm64 wheel
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.13'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
brew install bison flex gperf tcl-tk@8 readline libffi dwarfutils libelf ccache
|
|
pip3 install pybind11 cxxheaderparser setuptools wheel
|
|
|
|
- name: Build Verific tclmain
|
|
run: |
|
|
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$PATH"
|
|
export MACOSX_DEPLOYMENT_TARGET=11.0
|
|
cd verific/tclmain
|
|
make
|
|
|
|
- name: Build wheel
|
|
run: |
|
|
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$PATH"
|
|
export MACOSX_DEPLOYMENT_TARGET=11.0
|
|
_PYOSYS_OVERRIDE_VER=$(
|
|
grep "^YOSYS_VER " Makefile | head -1 | sed "s/.*:= *//" | tr "+" "."
|
|
) python3 setup.py bdist_wheel --dist-dir dist
|
|
|
|
- name: Upload to permanent release
|
|
run: |
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
DATE=$(date -u +%Y-%m-%d)
|
|
TAG="build-${DATE}-${SHORT_SHA}"
|
|
until gh release view "$TAG" >/dev/null 2>&1; do sleep 5; done
|
|
for i in 1 2 3 4 5; do
|
|
gh release upload "$TAG" dist/*.whl --clobber && break
|
|
echo "Upload attempt $i failed, retrying in 15s..."
|
|
sleep 15
|
|
done
|
|
# Wait for the Linux job to finish creating the latest release with its wheel
|
|
echo "Waiting for Linux wheel to appear in latest release..."
|
|
until gh release view latest --json assets --jq '.assets[].name' 2>/dev/null | grep -q linux; do sleep 10; done
|
|
for i in 1 2 3 4 5; do
|
|
gh release upload latest dist/*.whl --clobber && break
|
|
echo "Upload attempt $i failed, retrying in 15s..."
|
|
sleep 15
|
|
done
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|