fix builds #10
Workflow file for this run
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
on: | |
push: | |
# Sequence of patterns matched against refs/tags | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
#release: | |
# types: ['published'] | |
name: Create Release | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
continue-on-error: ${{ matrix.experimental }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10'] | |
experimental: [false] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install coverage | |
pip install . | |
- name: Test with coverage | |
run: | | |
coverage run test_lorem.py | |
version_check: | |
name: Check Version | |
runs-on: ubuntu-latest | |
needs: [ test ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install and Setup | |
run: | | |
python -m pip install -U pip setuptools wheel | |
- name: Get Version | |
id: get_version | |
run: | | |
set -x | |
python -m pip install -e . | |
echo "LOREM_VERSION=$(python -c 'import lorem; print(lorem.__version__)')" >> $GITHUB_OUTPUT | |
echo "LOREM_PRERELEASE=$(python -c 'import lorem, pkg_resources; print(str(pkg_resources.parse_version(lorem.__version__).is_prerelease).lower())')" >> $GITHUB_OUTPUT | |
echo "LOREM_CONDA_LABEL=$(python -c 'import lorem, pkg_resources; print("dev" if pkg_resources.parse_version(lorem.__version__).is_prerelease else "main")')" >> $GITHUB_OUTPUT | |
- uses: mukunku/tag-exists-action@v1.2.0 | |
id: check_tag | |
with: | |
tag: "v${{ steps.get_version.outputs.LOREM_VERSION }}" | |
outputs: | |
LOREM_VERSION: ${{ steps.get_version.outputs.LOREM_VERSION }} | |
LOREM_PRERELEASE: ${{ steps.get_version.outputs.LOREM_PRERELEASE }} | |
LOREM_TAG_EXISTS: ${{ steps.check_tag.outputs.exists }} | |
LOREM_CONDA_LABEL: ${{ steps.get_version.outputs.LOREM_CONDA_LABEL }} | |
github: | |
name: GitHub Release | |
runs-on: ubuntu-latest | |
needs: [ version_check ] | |
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.LOREM_TAG_EXISTS == 'false' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# ref: v${{ needs.version_check.outputs.LOREM_VERSION }} | |
fetch-depth: 0 | |
- name: Changelog | |
uses: Bullrich/generate-release-changelog@master | |
id: changelog | |
env: | |
REPO: ${{ github.repository }} | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1.12.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
# allowUpdates: true | |
# artifacts: | | |
# dist/* | |
# body: ${{ env.LOREM_CHANGELOG }} | |
body: | | |
${{ steps.changelog.outputs.changelog }} | |
# generateReleaseNotes: true | |
# makeLatest: true | |
name: python-lorem v${{ needs.version_check.outputs.LOREM_VERSION }} | |
prerelease: ${{ needs.version_check.outputs.LOREM_PRERELEASE }} | |
tag: "v${{ needs.version_check.outputs.LOREM_VERSION }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
tag: | |
name: Conda Tag | |
runs-on: ubuntu-latest | |
needs: [ version_check ] | |
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.LOREM_TAG_EXISTS == 'false' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.LOREM }} | |
# ref: v${{ needs.version_check.outputs.LOREM_VERSION }} | |
fetch-depth: 0 | |
- name: Reset Build Number | |
run: | | |
set -x | |
printf 0 > conda/build | |
- name: Commit Changes | |
run: | | |
set -x | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add conda/build | |
git commit -m"Reset conda build number" || true | |
- name: Push Changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.LOREM }} | |
- name: Create Tag | |
run: | | |
set -x | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git tag -d v${{ needs.version_check.outputs.LOREM_VERSION }} || true | |
git tag "conda-${{ needs.version_check.outputs.LOREM_VERSION }}+0" -m"Conda Build" | |
- name: Push Tag | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.LOREM }} | |
atomic: false | |
tags: true | |
pypi: | |
name: PyPI distribution for Python ${{ matrix.python-version }} | |
runs-on: ubuntu-latest | |
needs: [ github, version_check ] | |
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.LOREM_TAG_EXISTS == 'false' }} | |
strategy: | |
matrix: | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
- "pypy3.8" | |
- "pypy3.9" | |
- "pypy3.10" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: v${{ needs.version_check.outputs.LOREM_VERSION }} | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install and Setup | |
run: | | |
set -x | |
python -m pip install -U pip setuptools wheel | |
python -m pip install -U build | |
- name: Build Package | |
env: | |
LOREM_VERSION: ${{ needs.version_check.outputs.LOREM_VERSION }} | |
run: | | |
python -m build | |
# rename wheel's python tag | |
python util/wheel_rename.py dist/*.whl | |
- name: No Source Distribution for Python ${{ matrix.python-version }} | |
if: ${{ matrix.python-version != '3.12' }} | |
run: | | |
rm dist/*.tar.gz | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
skip-existing: true | |
- name: Publish package to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true | |
- name: Upload package to GitHub Release | |
uses: ncipollo/release-action@v1.12.0 | |
with: | |
allowUpdates: true | |
artifacts: | | |
dist/* | |
tag: "v${{ needs.version_check.outputs.LOREM_VERSION }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
conda: | |
name: Conda deployment of package for platform ${{ matrix.os }} with Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
needs: [ github, version_check ] | |
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.LOREM_TAG_EXISTS == 'false' }} | |
strategy: | |
matrix: | |
os: | |
- macos-latest | |
- ubuntu-latest | |
# - windows-latest # skip for now | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: conda-${{ needs.version_check.outputs.LOREM_VERSION }}+0 | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install and Setup | |
if: ${{ matrix.os != 'windows-latest' }} | |
run: | | |
set -x | |
python -m pip install -U pip setuptools wheel | |
python -m pip install -e . | |
- name: Install and Setup (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: | | |
python -m pip install -U pip setuptools wheel | |
python -m pip install -e . | |
- name: Conda environment creation and activation | |
uses: conda-incubator/setup-miniconda@v2 | |
env: | |
LOREM_VERSION: ${{ needs.version_check.outputs.LOREM_VERSION }} | |
LOREM_BUILD: "0" | |
with: | |
python-version: ${{ matrix.python-version }} | |
environment-file: conda/conda-build.yaml # Path to the build conda environment | |
auto-update-conda: false | |
auto-activate-base: false | |
show-channel-urls: true | |
- name: Build and upload the conda packages (macOS) | |
uses: uibcdf/action-build-and-upload-conda-packages@v1.2.0 | |
if: ${{ matrix.os == 'macos-latest' }} | |
env: | |
LOREM_VERSION: ${{ needs.version_check.outputs.LOREM_VERSION }} | |
LOREM_BUILD: "0" | |
with: | |
meta_yaml_dir: conda/lorem | |
python-version: ${{ matrix.python-version }} # Values previously defined in `matrix` | |
platform_osx-64: true | |
user: jarryshaw | |
label: ${{ needs.version_check.outputs.LOREM_CONDA_LABEL }} | |
token: ${{ secrets.ANACONDA_TOKEN }} # Replace with the right name of your secret | |
- name: Build and upload the conda packages (Ubuntu) | |
uses: uibcdf/action-build-and-upload-conda-packages@v1.2.0 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
env: | |
LOREM_VERSION: ${{ needs.version_check.outputs.LOREM_VERSION }} | |
LOREM_BUILD: "0" | |
with: | |
meta_yaml_dir: conda/lorem | |
python-version: ${{ matrix.python-version }} # Values previously defined in `matrix` | |
platform_linux-64: true | |
user: jarryshaw | |
label: ${{ needs.version_check.outputs.LOREM_CONDA_LABEL }} | |
token: ${{ secrets.ANACONDA_TOKEN }} # Replace with the right name of your secret | |
- name: Build and upload the conda packages (Windows) | |
uses: uibcdf/action-build-and-upload-conda-packages@v1.2.0 | |
if: ${{ matrix.os == 'windows-latest' }} | |
env: | |
LOREM_VERSION: ${{ needs.version_check.outputs.LOREM_VERSION }} | |
LOREM_BUILD: "0" | |
with: | |
meta_yaml_dir: conda/lorem | |
python-version: ${{ matrix.python-version }} # Values previously defined in `matrix` | |
platform_win-64: true | |
user: jarryshaw | |
label: ${{ needs.version_check.outputs.LOREM_CONDA_LABEL }} | |
token: ${{ secrets.ANACONDA_TOKEN }} # Replace with the right name of your secret | |
- name: Upload package to GitHub Release | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
uses: ncipollo/release-action@v1.12.0 | |
with: | |
allowUpdates: true | |
artifacts: | | |
/tmp/compilation-*/**/*.tar.bz2 | |
tag: "v${{ needs.version_check.outputs.LOREM_VERSION }}" | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
cleanup: | |
name: Delete tag | |
runs-on: ubuntu-latest | |
if: ${{ failure() || cancelled() }} | |
needs: [ test ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: dev-drprasad/delete-tag-and-release@v1.0 | |
with: | |
tag_name: ${{ github.ref }} #(required) tag name to delete | |
github_token: ${{ secrets.GITHUB_TOKEN }} # (required) a GitHub token with write access to the repo that needs to be modified | |
delete_release: true #(optional) default: true | |
repo: JarryShaw/lorem #(optional) target repository. default: repo running this action |