Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 33 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Python package

on:
push:
branches: [master, main]
branches: [master, main, '*.x']
pull_request:
branches: [master, main]
branches: [master, main, '*.x']

jobs:
build-lint-unit-test:
Expand Down Expand Up @@ -49,7 +49,16 @@ jobs:
release:
runs-on: ubuntu-latest
needs: [build-lint-unit-test, integration-test]
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
if: >
github.event_name == 'push' &&
(
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main' ||
(
startsWith(github.ref, 'refs/heads/') &&
endsWith(github.ref, '.x')
)
)
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -64,15 +73,33 @@ jobs:
- run: poetry install
- name: Semantic release
run: |
pip install python-semantic-release==7.34.6
pip install python-semantic-release==10.6.1
git config --global user.name "github-actions"
git config --global user.email "action@github.com"
semantic-release version
Comment thread
AlexDanDuna marked this conversation as resolved.
env:
# To generate a new token use the following guide, providing access to the "repo" scope.
# https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
# Once you update the secret on the repo, ensure you update the master/main protected branch policy
# to allow your user permission to "bypass required pull requests".
GH_TOKEN: ${{secrets.GH_TOKEN}}
- name: Publish package distributions to PyPI using Twine
# Only publish if Semantic release built packages under "dist/"; hashFiles returns '' when no files match the given pattern.
if: hashFiles('dist/*') != ''
run: |
pip install twine==6.1.0
python -m twine upload dist/*
env:
TWINE_USERNAME: ${{secrets.REPOSITORY_USERNAME}}
TWINE_PASSWORD: ${{secrets.PYPI_PASSWORD}}
- name: Semantic release - Publish package distributions to GitHub Releases
# Only publish if Semantic release built packages under "dist/"; hashFiles returns '' when no files match the given pattern.
if: hashFiles('dist/*') != ''
run: |
semantic-release publish
env:
# To generate a new token use the following guide, providing access to the "repo" scope.
# https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
# Once you update the secret on the repo, ensure you update the master/main protected branch policy
# to allow your user permission to "bypass required pull requests".
GH_TOKEN: ${{secrets.GH_TOKEN}}
REPOSITORY_USERNAME: ${{secrets.REPOSITORY_USERNAME}}
REPOSITORY_PASSWORD: ${{secrets.PYPI_PASSWORD}}
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ To contribute to this project, it is recommended that you follow these steps:
6. Send a GitHub Pull Request to the main repository's master branch. GitHub
Pull Requests are the expected method of code collaboration on this project.

## Patching older versions
1. Contact the [repository owners](https://github.com/ni/nisystemlink-clients-python/blob/master/.github/CODEOWNERS) for approval and ask them to create a
branch based on the commit that was used to generate the release to be patched.
The naming for this branch should follow this guideline:
- "1.x", if we want to create a new minor version for version 1
- "1.3.x", if we want to create a new patch version for version 1.3

2. Fork the repository on GitHub.
3. Fetch and check out the maintenance branch created in step 1, then create and
switch to a working branch from it.
4. Run the unit tests on your system (see Testing section). At this point,
if any tests fail, do not begin development. Try to investigate these
failures. If you're unable to do so, report an issue through our
[GitHub issues page](https://github.com/ni/nisystemlink-clients-python/issues).
5. Write new tests that demonstrate your bug or feature. Ensure that these
new tests fail.
6. Make your change.
7. Run all the unit tests again (which include the tests you just added),
and confirm that they all pass.
8. Send a GitHub Pull Request to the main repository branch that was created as a result of step 1. GitHub
Pull Requests are the expected method of code collaboration on this project.

## Testing

Before running any tests, you must have a supported version of Python (3.10+) and [Poetry](https://python-poetry.org/docs/) installed locally.
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ markers = [
exclude = ".*\\.pyi"

[tool.semantic_release]
branch = "master"
version_toml = ["pyproject.toml:tool.poetry.version"]
build_command = "poetry build"
Comment thread
AlexDanDuna marked this conversation as resolved.

# Allow releasing from the `master` branch.
[tool.semantic_release.branches.master]
match = "^master$"

# Allow releasing from maintenance branches named "1.x", "1.2.x", etc.
[tool.semantic_release.branches.maintenance]
match = "^\\d+(?:\\.\\d+)*\\.x$"


[build-system]
Expand Down
Loading