Skip to content

Commit

Permalink
Update workflow files (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
teutoburg authored Sep 26, 2024
2 parents 6280756 + 5968ead commit 026632e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 81 deletions.
76 changes: 6 additions & 70 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,75 +20,11 @@ on:
- prerelease
- "prerelease --next-phase"

workflow_call:
inputs:
dry-run:
type: boolean
description: Only output new version number, no actual change.
required: false
rule:
type: string
description: Version bump level
required: true
branch:
type: string
description: Branch (ref) to checkout and push changes to
required: false
default: ${{ github.ref_name }}
outputs:
bumpmsg:
description: Message created by the version bump.
value: ${{ jobs.bump.outputs.bumpmsg }}

jobs:
bump:
Bump:
name: Bump version number
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
bumpmsg: ${{ steps.bumping.outputs.BUMP_MSG }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Set up Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.7.1"

- name: Bump package Version using Poetry
id: bumping
env:
RULE: ${{ inputs.rule }}
DRY: ${{ inputs.dry-run && '--dry-run' || '' }}
run: echo "BUMP_MSG=$(poetry version $DRY $RULE)" >> $GITHUB_OUTPUT

- name: Output debug msg
if: inputs.dry-run
env:
BUMP_MSG: ${{ steps.bumping.outputs.BUMP_MSG }}
run: |
echo "## $BUMP_MSG" >> $GITHUB_STEP_SUMMARY
echo "Dry run only, no actual modification made." >> $GITHUB_STEP_SUMMARY
- name: Commit changes
# could also use https://github.com/stefanzweifel/git-auto-commit-action instead
if: ${{ ! inputs.dry-run }}
env:
BUMP_MSG: ${{ steps.bumping.outputs.BUMP_MSG }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "$BUMP_MSG"
git push
echo "## $BUMP_MSG" >> $GITHUB_STEP_SUMMARY
echo "Successfully committed and pushed version bump." >> $GITHUB_STEP_SUMMARY
uses: AstarVienna/DevOps/.github/workflows/bump.yml@main
secrets: inherit
with:
dry-run: ${{ inputs.dry-run }}
rule: ${{ inputs.rule }}
30 changes: 19 additions & 11 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ on:
- published

jobs:
build:
Build:
name: Build package using Poetry
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Set up Poetry
uses: abatilo/actions-poetry@v2
uses: abatilo/actions-poetry@v3
with:
poetry-version: "1.7.1"
poetry-version: "1.8.3"

- name: Create step summary
run: echo "## Building $(poetry version)" >> $GITHUB_STEP_SUMMARY
Expand All @@ -29,7 +29,7 @@ jobs:
run: poetry build >> $GITHUB_STEP_SUMMARY

- name: Store distribution files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: distribution
path: dist/
Expand All @@ -44,7 +44,7 @@ jobs:
if: ${{ success() }}
run: echo "### Successfully built package" >> $GITHUB_STEP_SUMMARY

publish:
Publish:
name: Publish package to PyPI
runs-on: ubuntu-latest
needs: build
Expand All @@ -54,14 +54,14 @@ jobs:
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Set up Poetry
uses: abatilo/actions-poetry@v2
uses: abatilo/actions-poetry@v3
with:
poetry-version: "1.7.1"
poetry-version: "1.8.3"

- name: Create step summary
run: echo "## Publishing $(poetry version) to PyPI" >> $GITHUB_STEP_SUMMARY
Expand All @@ -77,11 +77,19 @@ jobs:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish >> $GITHUB_STEP_SUMMARY

bump:
- name: Add to step summary
if: ${{ success() }}
run: |
echo "### Successfully published package on PyPI" >> $GITHUB_STEP_SUMMARY
PKGVER=$(poetry version)
SUBURL="${PKGVER// //}"
echo "https://pypi.org/project/$SUBURL/" >> $GITHUB_STEP_SUMMARY
Bump:
name: Bump to (next) dev version
needs: publish
if: ${{ needs.publish.result == 'success' }}
uses: ./.github/workflows/bump.yml
uses: AstarVienna/DevOps/.github/workflows/bump.yml@main
secrets: inherit
with:
rule: prerelease
Expand Down

0 comments on commit 026632e

Please sign in to comment.