-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from henningWoehr/feature/create-action
feat: add action code
- Loading branch information
Showing
2 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1,40 @@ | ||
# action-poetry-check-version | ||
# action-poetry-check-version | ||
GitHub Action for Python projects using poetry | ||
|
||
## Description | ||
This action compares the current project version with the latest tag of the repository. Fails if the project version isn't newer than the newest tag. | ||
|
||
## Action Inputs | ||
| Input name | Description | Required | Default Value | | ||
| --- | --- | --- | --- | | ||
| token | Github token to make authed request to GH API | true | None | | ||
|
||
## Action Outputs | ||
| Output name | Description | | ||
| --- | --- | | ||
| - | - | | ||
|
||
## Example | ||
|
||
#### Notes | ||
- No code checkout is needed | ||
|
||
```yml | ||
name: Check Version | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
check_version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check Version | ||
uses: henningwoehr/actions/poetry/check-version@main | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
``` |
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,43 @@ | ||
name: "check-version" | ||
description: "Checks, if the current project-version in the pyproject.toml is already existing as a tag. Fails, if that tag already exists" | ||
|
||
inputs: | ||
token: | ||
description: "Github token to make authed request to GH API" | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get Latest Release | ||
id: current | ||
uses: ctrlaltdev/[email protected] | ||
with: | ||
repo: ${{ github.repository }} | ||
token: ${{ inputs.token }} | ||
limit: 1 | ||
|
||
- name: Setup poetry | ||
id: setup-poetry | ||
uses: henningwoehr/action-poetry-setup@v1 | ||
|
||
- name: Set env | ||
run: | | ||
echo "RELEASE_OLD=$(echo $json_var | jq '.[].tag_name' | tr -d '"')" >> $GITHUB_ENV | ||
echo "POETRY_NEW=$(poetry version --short)" >> $GITHUB_ENV | ||
env: | ||
json_var: ${{ steps.current.outputs.releases }} | ||
shell: bash | ||
|
||
- name: validate version | ||
run: | | ||
python -c """ | ||
import sys | ||
from packaging import version | ||
if version.parse(sys.argv[1]) >= version.parse(sys.argv[2]): | ||
raise ValueError('Poetry Version is not larger than the last release') | ||
""" $RELEASE_OLD $POETRY_NEW | ||
shell: bash |