Skip to content

try to automate releases #22

try to automate releases

try to automate releases #22

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: [ "main" ]
tags: [ '*' ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
python-version:
- "3.8" # EOL: 2024-10
- "3.9" # EOL: 2025-10
- "3.10" # EOL: 2026-10
- "3.11" # EOL: 2027-10
- "3.12" # EOL: 2028-10
#- "3.13" # REL: 2024-10-01
- "system"
# see supported python release schedule at https://devguide.python.org/versions/
steps:
- uses: actions/checkout@v4
with:
repository: getargv/getargv
path: getargv
token: ${{ secrets.GH_PAT }}
- name: Build libgetargv
run: make install_dylib
working-directory: getargv
- uses: actions/checkout@v4
with:
path: getargv.py
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
if: ${{ matrix.python-version != 'system' }}
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Upgrade pip & Install deps
run: |
python3 -m pip install --upgrade pip
python3 -m pip install build pyright
- name: Build
run: |
python3 -m build
python3 -m pip install dist/getargv-*.tar.gz
working-directory: getargv.py
- name: Test
run: python3 tests/testgetargv.py
working-directory: getargv.py
- name: Types Test
run: pyright --verifytypes getargv
working-directory: getargv.py
release:
needs: [ build ]
runs-on: macos-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
repository: getargv/getargv
path: getargv
token: ${{ secrets.GH_PAT }}
- name: Build libgetargv
run: make install_dylib
working-directory: getargv
- uses: actions/checkout@v4
with:
path: getargv.py
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3.x
check-latest: true
- name: Upgrade pip & Install deps
run: |
python3 -m pip install --upgrade pip
python3 -m pip install build pyright
- name: Bump version
id: bump_version
run: |
make bump_version
echo "new_version=$(make version)" >> $GITHUB_OUTPUT
- name: Build & install
run: |
python3 -m build
python3 -m pip install dist/getargv-*.tar.gz
working-directory: getargv.py
- uses: actions/upload-artifact@v3
with:
name: dist.zip
path: getargv.py/dist
- name: create && push tag
run: |
git commit -am 'release ${{ steps.bump_version.outputs.new_version }}'
git tag '${{ steps.bump_version.outputs.new_version }}'
git push origin tag '${{ steps.bump_version.outputs.new_version }}'
git push origin HEAD:main
working-directory: getargv.py
- name: Release
uses: softprops/action-gh-release@v1
with:
files: getargv.py/dist/*
name: ${{ steps.bump_version.outputs.new_version }}
pypi-publish:
# hopefully this dep is enough to only run on release
needs: [ release ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/getargv/
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3
- run: mv dist.zip/dist ./
- uses: pypa/gh-action-pypi-publish@release/v1