release version #16
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: release version | |
on: | |
push: | |
tags: 'v*' | |
jobs: | |
verify_style: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Set up Python 3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
architecture: 'x64' | |
- | |
name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip invoke | |
invoke setup --devel --tests | |
- | |
name: Lint with flake8 | |
run: | | |
invoke lint | |
- | |
name: Check style with black | |
run: | | |
invoke black --check | |
verify_types: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Set up Python 3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
architecture: 'x64' | |
- | |
name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip invoke | |
invoke setup --devel --tests | |
- | |
name: validate types | |
run: | | |
python/bin/python -m mypy instruct | |
test_matrix: | |
needs: [verify_style, verify_types] | |
strategy: | |
fail-fast: false | |
matrix: | |
experimental: [false] | |
arch: | |
- 'x64' | |
python_version: | |
- '3.7' | |
- '3.8' | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
- 'pypy3.7' | |
- 'pypy3.8' | |
- 'pypy3.9' | |
os: | |
- 'ubuntu-latest' | |
include: | |
- | |
python_version: 'pypy3.10' | |
experimental: true | |
arch: 'x64' | |
os: ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
continue-on-error: ${{ matrix.experimental }} | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Set up Python ${{ matrix.python_version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python_version }} | |
architecture: ${{ matrix.arch }} | |
- | |
name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip invoke typing-extensions | |
invoke setup --tests | |
- | |
name: Test with pytest | |
run: | | |
python/bin/python -m pytest | |
pypi-publish: | |
needs: [test_matrix, verify_style] | |
runs-on: 'ubuntu-latest' | |
environment: | |
name: pypi | |
url: https://pypi.org/p/instruct | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- | |
name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
architecture: 'x64' | |
- | |
name: Setup | |
run: | | |
python -m pip install --upgrade pip invoke typing-extensions | |
invoke setup --devel --no-project | |
- | |
name: Set some variables... | |
id: version | |
run: | | |
echo "CURRENT_VERSION=$(grep -vE '^#' CURRENT_VERSION.txt | head -1)" >> "$GITHUB_OUTPUT" | |
echo "CHANGELOG_VERSION=$(invoke last-logged-changes | head -1 | cut -f2 -d' ' | tr -d '`')" >> "$GITHUB_OUTPUT" | |
echo "GIT_VERSION=$(echo '${{ github.ref_name }}' | sed 's/^.//')" >> "$GITHUB_OUTPUT" | |
- | |
name: Assert tag version matches the source version | |
run: | | |
if [ 'x${{ steps.version.outputs.GIT_VERSION }}' != 'x${{ steps.version.outputs.CURRENT_VERSION }}' ]; then | |
echo '::error file=CURRENT_VERSION.txt,line=2,title=Version mismatch::Expected ${{ steps.version.outputs.GIT_VERSION }} but got ${{ steps.version.outputs.CURRENT_VERSION }} instead. | |
Suggest you fix that and delete the tag.' | |
exit 254 | |
fi | |
if [ 'x${{ steps.version.outputs.CHANGELOG_VERSION }}' != 'x${{ github.ref_name }}' ]; then | |
echo '::error title=Release note version mismatch:: Expected release notes to be for ${{ github.ref_name }} however got ${{ steps.version.outputs.CHANGELOG_VERSION }} instead.' | |
exit 253 | |
fi | |
- | |
name: Create artifacts | |
id: artifacts | |
run: | | |
invoke build --validate | |
printf '%s\n=======================\n\n' '${{ steps.version.outputs.CURRENT_VERSION }}' | tee RELEASE_NOTES.rst | |
invoke last-logged-changes | tee -a RELEASE_NOTES.rst | |
invoke checksum | tee -a RELEASE_NOTES.rst | |
- | |
name: Convert RELEASE_NOTES.rst to markdown | |
uses: docker://pandoc/core:2.9 | |
with: | |
args: >- | |
-s | |
--wrap=none | |
-t gfm | |
-o RELEASE_NOTES.md | |
RELEASE_NOTES.rst | |
- | |
name: Create Release | |
id: upload-release-asset | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: RELEASE_NOTES.md | |
name: Release ${{ steps.version.outputs.CURRENT_VERSION }} | |
files: | |
dist/instruct* | |
- | |
name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
if: ${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') }} | |
with: | |
skip-existing: true |