Skip to content

chore(cli): get version from vcs #36

chore(cli): get version from vcs

chore(cli): get version from vcs #36

Workflow file for this run

---
name: build cli
on:
push:
tags:
- pact-python-cli/*
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
STABLE_PYTHON_VERSION: '3.13'
HATCH_VERBOSE: '1'
FORCE_COLOR: '1'
CIBW_BUILD_FRONTEND: build
jobs:
complete:
name: Build CLI completion check
if: always()
permissions:
contents: none
runs-on: ubuntu-latest
needs:
- build-sdist
- build-wheels
steps:
- name: Failed
run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
build-sdist:
name: Build CLI source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
with:
enable-cache: true
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install hatch
run: uv tool install hatch
- name: Create source distribution
working-directory: pact-python-cli
run: hatch build --target sdist
- name: Upload sdist
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: wheels-sdist
path: pact-python-cli/dist/*.tar*
if-no-files-found: error
compression-level: 0
build-wheels:
name: Build CLI wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
- os: macos-latest
- os: ubuntu-24.04-arm
- os: ubuntu-latest
# - os: windows-11-arm # Not supported upstream
- os: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Filter targets
id: cibw-filter
shell: bash
# On PRs, only build the latest stable version of Python to speed up the
# workflow.
run: |
if [[ "${{ github.event_name}}" == "pull_request" ]] ; then
echo "build=cp${STABLE_PYTHON_VERSION/./}-*" >> "$GITHUB_OUTPUT"
else
echo "build=*" >> "$GITHUB_OUTPUT"
fi
- name: Set macOS deployment target
if: startsWith(matrix.os, 'macos-')
run: |
echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> "$GITHUB_ENV"
- name: Create wheels
uses: pypa/cibuildwheel@95d2f3a92fbf80abe066b09418bbf128a8923df2 # v3.0.1
with:
package-dir: pact-python-cli
env:
CIBW_BUILD: ${{ steps.cibw-filter.outputs.build }}
- name: Upload wheels
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
if-no-files-found: error
compression-level: 0
publish:
name: Publish CLI wheels and sdist
if: >-
github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags/pact-python-cli/')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pact-python-cli
needs:
- build-sdist
- build-wheels
permissions:
contents: read
# Required for trusted publishing
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Install git cliff and typos
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
with:
tool: git-cliff,typos
- name: Update changelog
run: git cliff --verbose
working-directory: pact-python-cli
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Generate release changelog
id: release-changelog
working-directory: pact-python-cli
run: |
git cliff \
--current \
--strip header \
--output ${{ runner.temp }}/release-changelog.md
echo -e "\n\n## Pull Requests\n\n" >> ${{ runner.temp }}/release-changelog.md
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Download wheels and sdist
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: wheelhouse
merge-multiple: true
- name: Generate release
id: release
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
with:
files: wheelhouse/*
body_path: ${{ runner.temp }}/release-changelog.md
draft: false
prerelease: false
generate_release_notes: true
- name: Push build artifacts to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
skip-existing: true
packages-dir: wheelhouse
- name: Create PR for changelog update
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: 'docs: update changelog for ${{ github.ref_name }}'
title: 'docs: update cli changelog'
body: |
This PR updates the changelog for ${{ github.ref_name }}.
branch: docs/update-changelog
base: main