Skip to content

Commit

Permalink
Merge branch 'master' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt authored Dec 18, 2023
2 parents 9614f9c + ad607d5 commit fa2ff4c
Show file tree
Hide file tree
Showing 44 changed files with 1,327 additions and 743 deletions.
4 changes: 2 additions & 2 deletions .changelog-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ commit_classifiers:
- action: SummaryRegexMatch
category: Updates
kwargs:
pattern: (?i)^(?:update|change|rename|remove|delete|improve|refactor|chg|modif)[^\n]*$
pattern: (?i)^(?:update|change|rename|remove|delete|improve|chg|modif)[^\n]*$
- action: SummaryRegexMatch
category: Fixes
kwargs:
pattern: (?i)^(?:fix)[^\n]*$
pattern: (?i)^(?:refactor|fix)[^\n]*$
- action:
category: Other

Expand Down
49 changes: 49 additions & 0 deletions .github/actions/package-and-upload-artifacts/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Package and upload artifacts
description: Package a Python project and upload the artifacts and release notes
inputs:
tag-name:
description: 'The name of the tag for the GitHub release'
required: true
runs:
using: 'composite'
steps:
- name: Parse changelog for release notes
shell: bash
run: |
function extract_version_content() {
changelog=$1
target_version=$2
awk -v target="$target_version" '
/^## / {
if (found) exit;
version=$2;
if (version == target) found=1;
next;
}
found { print; }
' <<< "$changelog"
}
changelog=$(cat "CHANGELOG.md")
target_version=${{ inputs.tag-name }}
echo "TAG_NAME=$target_version" >> $GITHUB_ENV
content=$(extract_version_content "$changelog" "$target_version")
if [ -n "$content" ]; then
echo "::notice::Found release notes for ${target_version}"
echo "$content" >> release-notes.md
else
echo "::warning::Did not find release notes for ${target_version}"
touch release-notes.md
fi
- name: Upload release notes
uses: actions/upload-artifact@v4
with:
name: release-notes
path: release-notes.md

- name: Package and upload artifacts
if: ${{ env.PACKAGE == 'true' }}
uses: hynek/build-and-inspect-python-package@v2
40 changes: 40 additions & 0 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release
description: Create a GitHub release and upload the package to PyPI
inputs:
pypi-api-token:
description: 'PyPI API token'
required: true
tag-name:
description: 'The name of the tag for the GitHub release'
required: true

runs:
using: "composite"
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Download release notes
uses: actions/download-artifact@v4
with:
name: release-notes

- name: Create a GitHub release
uses: softprops/action-gh-release@v1
with:
files: dist/*
tag_name: "${{ env.TAG_NAME }}"
body_path: release-notes.md

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ inputs.pypi-api-token }}
23 changes: 23 additions & 0 deletions .github/actions/setup-python-and-git/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: checkout-and-setup-python
description: 'Checkout the repository and setup Python'
inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.11'
runs:
using: 'composite'
steps:
- uses: actions/setup-python@v4
name: Setup Python
with:
python-version: ${{ inputs.python-version }}
cache: 'pip' # caching pip dependencies

- name: Git check
run: |
git config --global user.email "[email protected]"
git config --global user.name "Testing Git"
git --version
git config --list
shell: bash
83 changes: 0 additions & 83 deletions .github/workflows/release.yaml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [master]

jobs:
bumpversion:
preview-version-hint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -22,7 +22,7 @@ jobs:

- name: Install requirements
run: |
python -m pip install . bump-my-version
python -m pip install generate-changelog bump-my-version
- name: Get the release hint
id: generate-changelog
Expand All @@ -32,14 +32,20 @@ jobs:
echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
- name: Get Pull Request Number
id: pr
run: |
PR_NUMBER=$(gh pr view --json number -q .number || echo "${{ github.event.number }}")
echo "pull_request_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "::notice::PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Bump version dry run
if: ${{ env.RELEASE_KIND != 'no-release' }}
shell: bash
run: |
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
export PR_NUMBER REVISION
# This will display a full log of what would happen if we were to bump the version.
bump-my-version bump --dry-run --verbose "$RELEASE_KIND"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches: [master]

jobs:
version-hint:
version:
permissions:
id-token: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -21,7 +24,7 @@ jobs:

- name: Install requirements
run: |
python -m pip install . bump-my-version
python -m pip install generate-changelog bump-my-version
- name: Generate the changelog and get the release hint
id: generate-changelog
Expand All @@ -32,25 +35,43 @@ jobs:
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
echo "PACKAGE=false" >> $GITHUB_ENV
- name: Get Pull Request Number
id: pr
run: |
PR_NUMBER=$(gh pr view --json number -q .number || echo "${{ github.event.number }}")
echo "pull_request_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "::notice::PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Bump version
if: ${{ env.RELEASE_KIND != 'no-release' }}
shell: bash
run: |
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
export PR_NUMBER REVISION
case "$RELEASE_KIND" in
major|minor|patch)
bump-my-version bump --allow-dirty --verbose "$RELEASE_KIND"
git push
git push --tags
echo "TAG_NAME=$(bump-my-version show current_version)" >> $GITHUB_ENV
# git push
# git push --tags
echo "PACKAGE=true" >> $GITHUB_ENV
;;
dev)
echo "Intentionally not bumping version for dev release"
echo "Temporary dev release for testing"
bump-my-version bump --allow-dirty --verbose --no-commit "$RELEASE_KIND"
echo "TAG_NAME=$(bump-my-version show current_version)" >> $GITHUB_ENV
echo "PACKAGE=true" >> $GITHUB_ENV
# echo "Intentionally not bumping version for dev release"
;;
esac
- name: Package
if: ${{ env.PACKAGE == 'true' }}
uses: hynek/build-and-inspect-python-package@v1
# - name: Package and upload artifacts
# if: ${{ env.PACKAGE == 'true' }}
# uses: ./.github/actions/package-and-upload-artifacts
# with:
# tag-name: ${{ env.TAG_NAME }}

# - name: Create a GitHub release
# if: ${{ env.PACKAGE == 'true' }}
# uses: ./.github/actions/release
Loading

0 comments on commit fa2ff4c

Please sign in to comment.