Skip to content

Commit

Permalink
ci: updates workflow for v9 of semantic release (#46)
Browse files Browse the repository at this point in the history
* fix: pins semantic release to version v7 and adds an optional minor flag

The latest version of semantic-release does not support setup.cfg.
Pinning to the same version as compliance-trestle so the upgrades
can be made in sync. This project is still in beta so adding an option
to force minor releases for breaking changes.

Signed-off-by: Jennifer Power <[email protected]>

* chore: fixes formatting on Makefile

Signed-off-by: Jennifer Power <[email protected]>

* chore: set MINOR variable on python-push.yml

* refactor: updates semantic release to 9.8.0

Align semantic release update logic with trestle

Signed-off-by: Jennifer Power <[email protected]>

* chore: moves MINOR env logic from Makefile

This is handled through pyproject.toml

Signed-off-by: Jennifer Power <[email protected]>

* ci(deps): updates actions/checkout to v4 in python-push workflow

Signed-off-by: Jennifer Power <[email protected]>

---------

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 authored Aug 29, 2024
1 parent b16607d commit 7a5ec63
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 31 deletions.
59 changes: 38 additions & 21 deletions .github/workflows/python-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Don't mess with line endings
run: |
git config --global core.autocrlf false
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -78,28 +78,45 @@ jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: release
url: https://pypi.org/p/compliance-trestle-fedramp
needs: build
if: github.ref == 'refs/heads/main' && github.repository == 'oscal-compass/compliance-trestle-fedramp'
steps:
- uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
token: ${{ secrets.ADMIN_PAT }}
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install build tools
run: |
make develop
- name: Create release
shell: bash
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
GH_TOKEN: ${{ secrets.ADMIN_PAT }}
run: |
make release
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
token: ${{ secrets.ADMIN_PAT }}
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install build tools
run: |
make develop
# This action uses Python Semantic Release v8
- name: Python Semantic Release
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.ADMIN_PAT }}

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# 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'

- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/[email protected]
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.ADMIN_PAT }}

merge-main-to-develop:
name: Merge main -> develop
Expand All @@ -110,7 +127,7 @@ jobs:
cancel-in-progress: true
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
ref: main
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ code-lint:
pre-commit run flake8 --all-files

code-typing:
mypy --pretty trestle
mypy --pretty trestle-fedramp

test::
python -m pytest -vvvv --exitfirst -n auto
Expand All @@ -66,7 +66,6 @@ release::
git config --global user.email "semantic-release@github-actions"
semantic-release publish


mdformat:
pre-commit run mdformat --all-files

Expand Down
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,30 @@ minversion = "6.2"
testpaths = [
"tests"
]

[tool.semantic_release]
build_command = "python setup.py sdist bdist_wheel"
version_variables = ["trestle_fedramp/__init__.py:__version__"]
commit_author = "semantic-release <semantic-release>"
major_on_zero = false

[tool.semantic_release.commit_parser_options]
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]
default_bump_level = 0


[tool.semantic_release.branches.main]
match = "(main)"
prerelease_token = "rc"
prerelease = false

[tool.semantic_release.remote]
name = "origin"
type = "github"
ignore_token_for_push = false
insecure = false

[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*"]
9 changes: 1 addition & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dev =
setuptools
wheel
yapf
python-semantic-release
python-semantic-release>=9.8.0
pep8-naming
pytest-random-order
python-dateutil
Expand All @@ -62,13 +62,6 @@ dev =
## Constrain system
pylint



[semantic_release]
version_variable=trestle_fedramp/__init__.py:__version__
branch = main
upload_to_pypi = true
version_source = commit

[flake8]
# WARNING: This should be kept compatible with .pre-commit-config.yaml
Expand Down

0 comments on commit 7a5ec63

Please sign in to comment.