Skip to content

Commit

Permalink
17476: Adjust PR workflow (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
apbassett authored Sep 14, 2023
1 parent b5748ee commit 311478e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/build-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Reusable WF - Build

on:
workflow_call:
inputs:
version:
required: false
default: ''
type: string
outputs:
version:
value: ${{ jobs.build.outputs.version }}
Expand All @@ -12,7 +17,13 @@ defaults:

jobs:

pepify:
uses: "./.github/workflows/pepify.yml"
with:
version: ${{ inputs.version }}

build:
needs: ["pepify"]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
Expand All @@ -25,6 +36,11 @@ jobs:
with:
python-version: "3.11"

- name: Set prerelease version
if: inputs.version != ''
run: |
echo "__version__ = '${{ needs.pepify.outputs.pepified-version }}'" >| ./howso/resources/no-telemetry/version.txt
- name: Install pypa/build
run: >-
python3 -m
Expand All @@ -44,8 +60,13 @@ jobs:
- name: Get version
id: get-version
run: |
echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
echo "VERSION=$(python setup.py --version)" >> $GITHUB_ENV
if [ "${{ inputs.version }}" != "" ]; then
echo "version=${{ needs.pepify.outputs.pepified-version }}" >> $GITHUB_OUTPUT
echo "VERSION=${{ needs.pepify.outputs.pepified-version }}" >> $GITHUB_ENV
else
echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
echo "VERSION=$(python setup.py --version)" >> $GITHUB_ENV
fi
- name: Upload Tarball Artifact
uses: actions/upload-artifact@v3
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/pepify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Reusable WF - PEPify Version

on:
workflow_call:
inputs:
version:
required: true
type: string
outputs:
pepified-version:
value: ${{ jobs.pepify.outputs.pepified-version }}

jobs:

pepify:
runs-on: ubuntu-latest
outputs:
pepified-version: ${{ steps.pepify.outputs.pepified-version }}
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Make Version PEP-Compliant
id: pepify
shell: bash
run: |
semver=${{ inputs.version }}
# Per PEP 440, the full scope of traditional semantic versioning is not valid in Python.
int_only_br=$(echo ".dev" | echo "${{ github.ref_name }}" | sed 's/[^0-9]*//g')
metadata=".dev$int_only_br"
pepified_version=$(echo "$semver" | sed -r -e 's/-alpha/a0/g' -e 's/-beta/b0/g' -e 's/\+PR./\.dev/g' -e "s|\+BR.${{ github.ref_name }}.|$metadata|g" -e 's/([0-9]+\.[0-9]+\.[0-9]+)([a-b0-9]+)?([\.dev]+)?(([0-9]+)\.([0-9]+)(\.([0-9]+))?)?/\1\2\3\5\6\8/g')
echo "Tagged version converted to PEP 440 standard: $pepified_version"
echo "pepified-version=$pepified_version" >> $GITHUB_OUTPUT

0 comments on commit 311478e

Please sign in to comment.