Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from python-semantic-release:master #116

Merged
merged 26 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d84efc7
docs: update docstrings to resolve sphinx failures (#1030)
wyardley Sep 25, 2024
1fa0e70
ci(pr): add file type filter to regulate testing jobs (#1031)
codejedi365 Sep 26, 2024
2307ed2
chore(gha): update action details for marketplace publishing (#1032)
codejedi365 Sep 27, 2024
156915c
fix(version-cmd): improve `version_variables` flexibility w/ quotes (…
codejedi365 Sep 27, 2024
cbe8eaa
9.8.9
Sep 27, 2024
2135c68
docs(github-actions): clarify & consolidate GitHub Actions usage docs…
wyardley Sep 27, 2024
d46596a
ci(pr-workflow): limit which workflow files trigger full testing (#1033)
codejedi365 Sep 27, 2024
c7ad311
ci(main-wkflow): remove beautify job & enforce style via linter
codejedi365 Sep 28, 2024
87765c2
ci(pr-wkflow): add formatting enforcement to lint job to match main
codejedi365 Sep 28, 2024
acce606
ci(main-wkflow): add file type filter to regulate testing jobs (#1037)
codejedi365 Sep 28, 2024
6a5d35d
feat(github-actions): add `is_prerelease` output to the version actio…
codejedi365 Sep 28, 2024
fd8c509
9.9.0
Sep 28, 2024
886324c
ci(main-wkflow): add steps to update partial version reference tags (…
codejedi365 Sep 28, 2024
74f146f
ci(main-wkflow): force release to act on the github.sha the workflow …
codejedi365 Sep 28, 2024
14f04df
docs(github-actions): update primary example with workflow sha contro…
codejedi365 Sep 28, 2024
adb1f7c
ci(main-wkflow): ensure file changes are only detected from last push…
codejedi365 Sep 28, 2024
59c0819
ci(main-wkflow): swap `upload-to-gh-release` action to `publish-actio…
codejedi365 Sep 29, 2024
e263f46
test(repos): adjust git config in example repos to prevent autosignin…
codejedi365 Oct 1, 2024
cfcb4eb
chore(config): fix setuptools package discovery error
codejedi365 Oct 1, 2024
b87172b
chore(conf-pytest): remove default xdist parameter from config
codejedi365 Oct 6, 2024
6a37159
chore(git-attributes): force line-endings in repo to always be posix …
codejedi365 Oct 6, 2024
26597e2
feat(github-actions): add an action `build` directive to toggle the `…
codejedi365 Oct 7, 2024
c18c245
feat(changelog): modify changelog template to support changelog updat…
codejedi365 Oct 7, 2024
76f1ffa
9.10.0
Oct 7, 2024
31b615a
ci(main-wkflow): fix unknown git user before tag creation (#1053)
codejedi365 Oct 8, 2024
18399a7
9.10.0
Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://help.github.com/articles/dealing-with-line-endings/
* text=auto eol=lf
164 changes: 113 additions & 51 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,68 @@ on:
- "pre/*"

jobs:

eval-changes:
name: Evaluate changes
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50 # Must at least retrieve a set of commits to compare changes
# primarily because of any 'Rebase and Merge' PR action in GitHub

- name: Evaluate | Check specific file types for changes
id: changed-files
uses: tj-actions/changed-files@v45.0.2
with:
base_sha: ${{ github.event.push.before }}
files_yaml: |
build:
- MANIFEST.in
- Dockerfile
- .dockerignore
- scripts/**
ci:
- .github/workflows/main.yml
docs:
- docs/**
- README.rst
- AUTHORS.rst
- CONTRIBUTING.rst
- CHANGELOG.rst
src:
- semantic_release/**
- pyproject.toml
tests:
- tests/**

- name: Evaluate | Detect if any of the combinations of file sets have changed
id: all-changes
run: |
printf '%s\n' "any_changed=false" >> $GITHUB_OUTPUT
if [ "${{ steps.changed-files.outputs.build_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.ci_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.docs_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.src_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.tests_any_changed }}" == "true" ]; then
printf '%s\n' "any_changed=true" >> $GITHUB_OUTPUT
fi

outputs:
any-file-changes: ${{ steps.all-changes.outputs.any_changed }}
build-changes: ${{ steps.changed-files.outputs.build_any_changed }}
ci-changes: ${{ steps.changed-files.outputs.ci_any_changed }}
doc-changes: ${{ steps.changed-files.outputs.docs_any_changed }}
src-changes: ${{ steps.changed-files.outputs.src_any_changed }}
test-changes: ${{ steps.changed-files.outputs.tests_any_changed }}


test:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} tests
runs-on: ${{ matrix.os }}
needs: eval-changes
if: ${{ needs.eval-changes.outputs.src-changes == 'true' || needs.eval-changes.outputs.test-changes == 'true' || needs.eval-changes.outputs.ci-changes == 'true' }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
Expand Down Expand Up @@ -83,81 +142,51 @@ jobs:
with:
report_paths: ./tests/reports/*.xml


lint:
needs: eval-changes
if: ${{ needs.eval-changes.outputs.any-file-changes == 'true' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.8
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Install mypy & dev packages
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install ".[dev, mypy]"
python -m pip install .[dev,mypy]

- name: ruff
- name: Lint | Ruff Evaluation
id: lint
run: |
python -m ruff check . \
python -m ruff check \
--config pyproject.toml \
--output-format=full \
--exit-non-zero-on-fix

- name: mypy
- name: Type-Check | MyPy Evaluation
id: type-check
if: ${{ always() && steps.lint.outcome != 'skipped' }}
run: |
python -m mypy --ignore-missing-imports semantic_release

beautify:
name: Beautify
runs-on: ubuntu-latest
concurrency: push
needs: [test, lint]
outputs:
new_sha: ${{ steps.sha.outputs.SHA }}
permissions:
id-token: write
contents: write

steps:
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Checkout repository
uses: actions/checkout@v4

- name: Install Ruff
- name: Format-Check | Ruff Evaluation
id: format-check
if: ${{ always() && steps.type-check.outcome != 'skipped' }}
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install ".[dev]"

- name: Format
run: |
python -m ruff format .
python -m ruff format --check --config pyproject.toml

- name: Commit and push changes
uses: github-actions-x/commit@v2.9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "style: beautify ${{ github.sha }}"
name: github-actions
email: action@github.com

- name: Get new SHA
id: sha
run: |
new_sha=$(git rev-parse HEAD)
echo "SHA=$new_sha" >> $GITHUB_OUTPUT

release:
name: Semantic Release
runs-on: ubuntu-latest
concurrency: push
needs: [test, lint, beautify]
needs: [test, lint]
if: github.repository == 'python-semantic-release/python-semantic-release'
environment:
name: pypi
Expand All @@ -167,11 +196,23 @@ jobs:
id-token: write
contents: write

env:
GITHUB_ACTIONS_AUTHOR_NAME: github-actions
GITHUB_ACTIONS_AUTHOR_EMAIL: actions@users.noreply.github.com

steps:
- uses: actions/checkout@v4
# Note: we need to checkout the repository at the workflow sha in case during the workflow
# the branch was updated. To keep PSR working with the configured release branches,
# we force a checkout of the desired release branch but at the workflow sha HEAD.
- name: Setup | Checkout Repository at workflow sha
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
ref: ${{ github.sha }}

- name: Setup | Force correct release branch on workflow sha
run: |
git checkout -B ${{ github.ref_name }}

- name: Python Semantic Release
id: release
Expand All @@ -180,6 +221,28 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
root_options: "-vv"

- name: Update Minor Release Tag Reference
if: steps.release.outputs.released == 'true' && steps.release.outputs.is_prerelease == 'false'
env:
FULL_VERSION_TAG: ${{ steps.release.outputs.tag }}
GIT_COMMITTER_NAME: ${{ env.GITHUB_ACTIONS_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ env.GITHUB_ACTIONS_AUTHOR_EMAIL }}
run: |
MINOR_VERSION_TAG="$(echo "$FULL_VERSION_TAG" | cut -d. -f1,2)"
git tag --force --annotate "$MINOR_VERSION_TAG" "${FULL_VERSION_TAG}^{}" -m "$MINOR_VERSION_TAG"
git push -u origin "$MINOR_VERSION_TAG" --force

- name: Update Major Release Tag Reference
if: steps.release.outputs.released == 'true' && steps.release.outputs.is_prerelease == 'false'
env:
FULL_VERSION_TAG: ${{ steps.release.outputs.tag }}
GIT_COMMITTER_NAME: ${{ env.GITHUB_ACTIONS_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ env.GITHUB_ACTIONS_AUTHOR_EMAIL }}
run: |
MAJOR_VERSION_TAG="$(echo "$FULL_VERSION_TAG" | cut -d. -f1)"
git tag --force --annotate "$MAJOR_VERSION_TAG" "${FULL_VERSION_TAG}^{}" -m "$MAJOR_VERSION_TAG"
git push -u origin "$MAJOR_VERSION_TAG" --force

# see https://docs.pypi.org/trusted-publishers/
- name: Publish package distributions to PyPI
id: pypi-publish
Expand All @@ -192,11 +255,10 @@ jobs:

- name: Publish package distributions to GitHub Releases
id: github-release

# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true.
# See https://github.com/actions/runner/issues/1173
if: steps.release.outputs.released == 'true'
uses: python-semantic-release/upload-to-gh-release@main
uses: python-semantic-release/publish-action@v9.9.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
89 changes: 82 additions & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,68 @@ name: Checks
on:
pull_request:

permissions:
contents: read

jobs:

eval-changes:
name: Evaluate changes
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Evaluate | Check specific file types for changes
id: changed-files
uses: tj-actions/changed-files@v45.0.2
with:
files_yaml: |
build:
- MANIFEST.in
- Dockerfile
- .dockerignore
- scripts/**
ci:
- .github/workflows/pr.yml
docs:
- docs/**
- README.rst
- AUTHORS.rst
- CONTRIBUTING.rst
- CHANGELOG.rst
src:
- semantic_release/**
- pyproject.toml
tests:
- tests/**

- name: Evaluate | Detect if any of the combinations of file sets have changed
id: all-changes
run: |
printf '%s\n' "any_changed=false" >> $GITHUB_OUTPUT
if [ "${{ steps.changed-files.outputs.build_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.ci_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.docs_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.src_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.tests_any_changed }}" == "true" ]; then
printf '%s\n' "any_changed=true" >> $GITHUB_OUTPUT
fi

outputs:
any-file-changes: ${{ steps.all-changes.outputs.any_changed }}
build-changes: ${{ steps.changed-files.outputs.build_any_changed }}
ci-changes: ${{ steps.changed-files.outputs.ci_any_changed }}
doc-changes: ${{ steps.changed-files.outputs.docs_any_changed }}
src-changes: ${{ steps.changed-files.outputs.src_any_changed }}
test-changes: ${{ steps.changed-files.outputs.tests_any_changed }}


test-linux:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} tests
runs-on: ${{ matrix.os }}
needs: eval-changes
if: ${{ needs.eval-changes.outputs.src-changes == 'true' || needs.eval-changes.outputs.test-changes == 'true' || needs.eval-changes.outputs.ci-changes == 'true' }}
strategy:
matrix:
python-version:
Expand Down Expand Up @@ -66,6 +124,8 @@ jobs:
test-windows:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} tests
runs-on: ${{ matrix.os }}
needs: eval-changes
if: ${{ needs.eval-changes.outputs.src-changes == 'true' || needs.eval-changes.outputs.test-changes == 'true' || needs.eval-changes.outputs.ci-changes == 'true' }}
strategy:
# Since the current test suite takes 10-15 minutes to complete on windows, we are
# only going to run it on the oldest version of python we support. The older version
Expand Down Expand Up @@ -122,30 +182,45 @@ jobs:
report_paths: ./tests/reports/*.xml
annotate_only: true


lint:
needs: eval-changes
if: ${{ needs.eval-changes.outputs.any-file-changes == 'true' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.8
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Install mypy & dev packages
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install ".[dev, mypy]"
python -m pip install .[dev,mypy]

- name: ruff
- name: Lint | Ruff Evaluation
id: lint
run: |
python -m ruff check . \
python -m ruff check \
--config pyproject.toml \
--output-format=full \
--exit-non-zero-on-fix

- name: mypy
run: python -m mypy --ignore-missing-imports semantic_release
- name: Type-Check | MyPy Evaluation
id: type-check
if: ${{ always() && steps.lint.outcome != 'skipped' }}
run: |
python -m mypy --ignore-missing-imports semantic_release

- name: Format-Check | Ruff Evaluation
id: format-check
if: ${{ always() && steps.type-check.outcome != 'skipped' }}
run: |
python -m ruff format --check --config pyproject.toml


commitlint:
runs-on: ubuntu-latest
Expand Down
Loading