-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @fk3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Param( | ||
[Parameter(Mandatory)] | ||
[string]$targetBranch, | ||
[Parameter(Mandatory)] | ||
[string]$sourceBranch | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
git fetch origin $targetBranch | ||
$commitTarget = git rev-parse "origin/$targetBranch" | ||
git fetch origin $sourceBranch | ||
$commitSource = git rev-parse "origin/$sourceBranch" | ||
|
||
# verify that source branch originates from the latest commit of the target branch | ||
# (i.e. a fast-forward merge could be performed) | ||
git merge-base --is-ancestor $commitTarget $commitSource | ||
if ($LASTEXITCODE -ne "0") | ||
{ | ||
throw "Merge would create a non-semilinear history. Please rebase." | ||
} | ||
|
||
# the target branch should only contain simple commits and no merges | ||
$numberOfMergeCommits = git rev-list --min-parents=2 --count "${commitTarget}..${commitSource}" | ||
if ($numberOfMergeCommits -ne "0") | ||
{ | ||
Throw "Source Branch contains non-linear history. Please rebase." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Make sure that the version number has been increased and does not exist on PyPI yet.""" | ||
|
||
import importlib.metadata | ||
import subprocess | ||
|
||
lib = "interface-proxy" | ||
|
||
lib_version = importlib.metadata.version(lib) | ||
|
||
not_found = False | ||
|
||
try: | ||
subprocess.check_call( | ||
[ # noqa: S603, S607 | ||
"python", | ||
"-m", | ||
"pip", | ||
"install", | ||
"--no-deps", | ||
"--ignore-installed", | ||
"--dry-run", | ||
f"{lib}=={lib_version}", | ||
], | ||
) | ||
except subprocess.SubprocessError: | ||
not_found = True | ||
|
||
if not_found is False: | ||
exc_msg = ( | ||
f"Version {lib_version} seems to be published already. " | ||
f"Did you forget to increase the version number in interface_proxy/__init__.py?" | ||
) | ||
print(f"::error::{exc_msg}") # noqa: T201 | ||
raise ValueError(exc_msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Check Version | ||
|
||
on: | ||
pull_request: | ||
branches: main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check_version: | ||
name: Check Version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
- name: Install environment | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --no-deps . | ||
- name: Run version check | ||
run: | | ||
python .github/check_version_uniqueness.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
targetenv: | ||
description: 'Target Environment' | ||
required: true | ||
default: 'testpypi' | ||
type: choice | ||
options: | ||
- testpypi | ||
- pypi | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
overview: | ||
name: Overview | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Job Summary | ||
run: | | ||
if [[ "${{ github.ref_name }}" != "main" && "${{ inputs.targetenv || 'testpypi' }}" == "pypi" ]] | ||
then | ||
{ | ||
echo "::error::Publishing to PyPI is only allowed from the main branch"; | ||
exit 1; | ||
} | ||
fi; | ||
echo "### Job Summary" >> $GITHUB_STEP_SUMMARY | ||
echo "Publish to ${{ inputs.targetenv || 'testpypi' }} environment from ${{ github.ref_name }} branch." >> $GITHUB_STEP_SUMMARY | ||
publish: | ||
name: Publish | ||
runs-on: windows-2022 | ||
needs: overview | ||
environment: ${{ inputs.targetenv || 'testpypi' }} | ||
env: | ||
TWINE_USERNAME: '__token__' | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
- name: Install build tools | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build~=1.0.3 twine~=4.0.2 | ||
- name: Build | ||
run: | | ||
python -m build --wheel | ||
- name: Publish distribution | ||
run: | | ||
twine upload --repository-url ${{ vars.PYPI_API_ENDPOINT }} dist/* | ||
- name: Tag commit | ||
if: ${{ (github.ref_name == 'main') || ((inputs.targetenv || 'testpypi') == 'pypi') }} | ||
run: | | ||
pip install --no-index --no-deps --find-links=dist/ interface-proxy | ||
$LibVersion = python -c "import importlib.metadata; print(importlib.metadata.version('interface-proxy'))" | ||
if ( -not (Get-ChildItem -Path dist -Filter "*${$LibVersion}*.whl")) | ||
{ | ||
Throw "Inspected version $LibVersion could not be found in any wheels in the dist folder." | ||
} | ||
$TagName = "Release-${$LibVersion}_(${{ inputs.targetenv || 'testpypi' }})" | ||
git tag $TagName | ||
git push origin $TagName | ||
shell: pwsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Check Semilinear History | ||
|
||
on: | ||
pull_request: | ||
branches: main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
semilinear_history: | ||
name: Check Semilinear History | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Check Semilinear History | ||
shell: pwsh | ||
run: | | ||
.\.github\Check-SemilinearHistory.ps1 -targetBranch ${{ github.base_ref }} -sourceBranch ${{ github.head_ref }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Run Checks | ||
|
||
on: | ||
pull_request: | ||
branches: main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
checks: | ||
name: Run Checks | ||
runs-on: windows-2022 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
- name: Install tox | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox~=4.12.1 | ||
- name: Run tox | ||
run: | | ||
tox run-parallel |