Skip to content

Build release binaries #95

Build release binaries

Build release binaries #95

name: "Build release binaries"
on:
workflow_dispatch:
inputs:
version:
default: 'latest'
description: 'Package version'
type: string
required: true
schedule:
- cron: '0 17 * * *'
env:
PACKAGE_NAME: ruff
MODULE_NAME: ruff
PYTHON_VERSION: "3.13"
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTUP_MAX_RETRIES: 10
jobs:
check-version:
name: Check
runs-on: ubuntu-slim
outputs:
version: ${{ steps.get-version.outputs.version }}
build: ${{ steps.check-release.outputs.build }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get Version
id: get-version
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
version="latest"
else
version=${{ github.event.inputs.version }}
fi
if [ "${version}" = "latest" ]; then
version=$(curl -s "https://api.github.com/repos/astral-sh/ruff/releases/latest" | jq -r .tag_name)
fi
if [ -z "${version}" ] || [ "$version" = "null" ]; then
echo "Error: version is empty"
exit 1
fi
echo "version=${version}" >> $GITHUB_ENV
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Check Release
id: check-release
run: |
gh release view ${version} -R ${{ github.repository }} >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT
gh release view ${version} -R ${{ github.repository }} | grep ruff-loongarch64-unknown-linux-gnu.tar.gz >/dev/null 2>&1 || echo "build=1" >> $GITHUB_OUTPUT
gh release view ${version} -R ${{ github.repository }} | grep ruff-loongarch64-unknown-linux-musl.tar.gz >/dev/null 2>&1 || echo "build=1" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
if : steps.check-release.outputs.create == '1'
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "Release ${version}" || true
git tag ${version}
git push origin ${version} || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
if : steps.check-release.outputs.create == '1'
run: |
gh release create ${version} -R ${{ github.repository }} --title ${version} --notes "**Full Changelog**: [${version}](https://github.com/astral-sh/ruff/releases/tag/${version})"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-cross:
runs-on: ubuntu-latest
needs: check-version
if: needs.check-version.outputs.build == '1'
env:
version: ${{ needs.check-version.outputs.version }}
strategy:
fail-fast: false
matrix:
platform:
- target: loongarch64-unknown-linux-gnu
arch: loongarch64
manylinux: 'manylinux_2_36'
maturin_docker_options: >-
-e JEMALLOC_SYS_WITH_LG_PAGE=14
- target: "loongarch64-unknown-linux-musl"
arch: loongarch64
manylinux: "musllinux_1_2"
maturin_docker_options: >-
-e JEMALLOC_SYS_WITH_LG_PAGE=14
steps:
- uses: actions/checkout@v6
with:
repository: astral-sh/ruff
ref: ${{ env.version }}
submodules: recursive
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Prep README.md"
run: |
python scripts/transform_readme.py --target pypi
- name: "Build wheels"
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
manylinux: ${{ matrix.platform.manylinux }}
docker-options: ${{ matrix.platform.maturin_docker_options }}
args: --release --locked --out dist
- name: "Upload wheels"
run: |
pip install twine==6.0.1
for file in dist/*.whl; do
twine upload --repository-url https://gitlab.com/api/v4/projects/65746188/packages/pypi $file || true
done
env:
TWINE_USERNAME: ${{ github.repository_owner }}
TWINE_PASSWORD: ${{ secrets.GL_TOKEN }}
- name: "Archive binary"
shell: bash
run: |
set -euo pipefail
TARGET=${{ matrix.platform.target }}
ARCHIVE_NAME=ruff-$TARGET
ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz
mkdir -p $ARCHIVE_NAME
cp target/$TARGET/release/ruff $ARCHIVE_NAME/ruff
tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
- name: "Upload binary"
uses: softprops/action-gh-release@v2
with:
repository: ${{ github.repository }}
tag_name: ${{ env.version }}
files: |
*.tar.gz
*.sha256