add linux build #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Python π distribution π¦ to PyPI and TestPyPI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
jobs: | ||
build-on-windows: | ||
name: Build distribution π¦ | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- name: Install pypa/build | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine build | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Rename the distribution files | ||
run: | | ||
# Get all .whl files in the dist folder | ||
$files = Get-ChildItem -Path .\dist\ -Filter *.whl | ||
# Loop through each file | ||
foreach ($file in $files) { | ||
# Split the file name by "-" | ||
$nameParts = $file.BaseName -split "-" | ||
# Replace the third and fourth items by "py3" | ||
$nameParts[2] = "py3" | ||
$nameParts[3] = "py3" | ||
# Assemble the new file name with new items | ||
$newName = [string]::Join("-", $nameParts) + ".whl" | ||
# Move the old file to new file name | ||
Move-Item -Path $file.FullName -Destination .\dist\$newName | ||
} | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
build-on-linux: | ||
name: Build distribution π¦ | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- name: Install pypa/build | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine build | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build --wheel | ||
- name: Rename the distribution files | ||
run: | | ||
# Navigate to the dist directory | ||
cd dist | ||
# Loop over every .whl file | ||
for oldname in *.whl | ||
do | ||
# Split the filename by "-" | ||
IFS='-' read -ra nameParts <<< "$oldname" | ||
# Replace the third and fourth items by "py3" | ||
nameParts[2]="py3" | ||
nameParts[3]="py3" | ||
nameParts[4]="manylinux1" | ||
# Assemble the new filename | ||
newName=$(IFS='-'; echo "${nameParts[*]}") | ||
# Move the old file to the new filename | ||
mv "$oldname" "$newName" | ||
done | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
github-release: | ||
name: >- | ||
Sign the Python π distribution π¦ with Sigstore | ||
and upload them to GitHub Release | ||
needs: | ||
- build | ||
Check failure on line 103 in .github/workflows/cd.yml GitHub Actions / Publish Python π distribution π¦ to PyPI and TestPyPIInvalid workflow file
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: >- | ||
gh release create | ||
'${{ github.ref_name }}' | ||
--repo '${{ github.repository }}' | ||
--notes "" | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' |