Skip to content

Version fix and add another function relating to spaceship heat factor #78

Version fix and add another function relating to spaceship heat factor

Version fix and add another function relating to spaceship heat factor #78

Workflow file for this run

name: NMSpy
on:
# Run on all branches except for the gh-pages branch
push:
paths-ignore:
- '*.md'
branches-ignore:
- 'gh-pages'
tags:
- '*'
jobs:
build_test:
name: Build artefacts
runs-on: Windows-latest
strategy:
fail-fast: false
matrix:
py_ver: [{version: '3.9'}] # , {version: '3.10'}, {version: '3.11'}]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.py_ver.version}}
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.py_ver.version}}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip uv
uv sync --frozen --all-groups --all-extras
- name: Build Python ${{ matrix.py_ver.version}} wheel
run: uv build
- name: Lint and format code
run: |
uv run ruff check ./nmspy ./example_mods
uv run ruff format --check ./nmspy ./example_mods
uv run python -m twine check ./dist/*
- name: Upload Wheels
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
release_check:
name: Check whether to do a release
needs:
- build_test
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.set_version.outputs.package_version }}
should_release_pypi: ${{ steps.whether_to_release_pypi.outputs.should_release_pypi }}
should_release_test_pypi: ${{ steps.whether_to_release_test_pypi.outputs.should_release_test_pypi }}
permissions:
id-token: write # IMPORTANT: this permission is required to write to github envs
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check whether to release on pypi or test.pypi
id: version-check
uses: MathieuMoalic/[email protected]
with:
indexes: pypi.org test.pypi.org
- name: Globalise determined version
id: set_version
run: echo "package_version=${{ env.PACKAGE_VERSION }}" >> "$GITHUB_OUTPUT"
- name: Assign whether to release to pypi to output
id: whether_to_release_pypi
run: echo "should_release_pypi=${{ env.PUBLISHING_pypi_org }}" >> "$GITHUB_OUTPUT"
- name: Assign whether to release to test pypi to output
id: whether_to_release_test_pypi
run: echo "should_release_test_pypi=${{ env.PUBLISHING_test_pypi_org }}" >> "$GITHUB_OUTPUT"
release:
name: Release NMSpy wheels and source build to PyPI
# Only run this job if the following conditions are met:
# 1. We merge into master.
# 2. We need to do a release.
# 3. The commit message doesn't start with [skip pypi].
# 4. The version isn't a dev version.
if: ${{ github.ref == 'refs/heads/master' && needs.release_check.outputs.should_release_pypi == 'true' && !startsWith(github.event.head_commit.message, '[skip pypi]') && !contains(needs.release_check.outputs.package_version, 'dev') }}
needs:
- build_test
- release_check
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/NMSpy
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download files for release
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
test-release:
name: Release NMSpy wheels and source build to test-PyPI
# Only run this job if we merge into master and if we need to do a release.
if: ${{ github.ref == 'refs/heads/master' && needs.release_check.outputs.should_release_test_pypi == 'true' }}
needs:
- build_test
- release_check
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/NMSpy
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download files for release
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
attestations: true