Skip to content

setup better python package builds for iriscasttools #197

setup better python package builds for iriscasttools

setup better python package builds for iriscasttools #197

name: Cloud Energy Collection Tests
on:
push:
branches:
- master
paths:
- "iriscasttools/**"
- ".github/workflows/iriscast_package_build.yaml"
pull_request:
paths:
- "iriscasttools/**"
- ".github/workflows/iriscast_package_build.yaml"
jobs:
test_and_lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.x", "3.10"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Navigate to Folder
run: cd ./iriscasttools
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
strategy:
matrix:
python-version: ["3.x"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build
- name: Build package
run: |
cd ./iriscasttools
python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.python-version }}
path: ./iriscasttools/dist/
publish:
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Get version from pyproject.toml
id: get_version
run: |
version=$(grep -m1 '^version' iriscasttools/pyproject.toml | sed -E 's/version *= *"([^"]+)"/\1/')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create tag for current version
run: |
version="${{ steps.get_version.outputs.version }}"
tag_name="iriscasttools-v${version}"
git config user.name "github-actions"
git config user.email "github-actions@github.com"
# Only tag if it doesn't already exist
if git rev-parse "$tag_name" >/dev/null 2>&1; then
echo "Tag $tag_name already exists. Skipping."
else
git tag "$tag_name"
git push origin "$tag_name"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: iriscasttools-v${{ steps.get_version.outputs.version }}
files: |
dist/**/*.whl
dist/**/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}