Skip to content

Commit c33d082

Browse files
authored
Add ability to provide package version number in create_package action (#50)
* Add ability to provide package version number in create_package action * Fix * Fix * Vix version env variable
1 parent 182ad10 commit c33d082

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,13 @@ This action relies on git tags to be present in order to generate an artifact ta
174174
3) This action requires to [poetry](https://python-poetry.org/docs/master/) ~1.2 being installed in build environment (for example, by [install_poetry action](#install_poetry))
175175

176176
### Inputs
177-
| Name | Description | Optional | Default value |
178-
|---------------------|:----------------------------------------------------------------------------|----------|---------------|
179-
| pypi_repo_url | Package index URL | False | |
180-
| pypi_token_username | Package index authentication username | False | |
181-
| pypi_token | Package index authentication token or password. | False | |
182-
| package_name | Name of package to create. This should match name of root project directory | False | |
177+
| Name | Description | Optional | Default value |
178+
|---------------------|:-------------------------------------------------------------------------------------|----------|:---------------|
179+
| pypi_repo_url | Package index URL | False | |
180+
| pypi_token_username | Package index authentication username | False | |
181+
| pypi_token | Package index authentication token or password. | False | |
182+
| package_name | Name of package to create. This should match name of root project directory | False | |
183+
| version | Version of package. If not provided, a new **development** version will be generated | | Empty |
183184

184185
### Outputs
185186
No outputs defined

create_package/action.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ inputs:
2222
description: Name of package to create. This should match name of root project directory
2323
required: true
2424

25+
version:
26+
description: Version of package (if not provided, a new development version will be generated)
27+
required: false
28+
default: ''
29+
2530
outputs:
2631
version:
2732
description: "Version"
@@ -40,9 +45,11 @@ runs:
4045
POETRY_HTTP_BASIC_CUSTOM_REPO_USERNAME: ${{ inputs.pypi_token_username }}
4146
POETRY_HTTP_BASIC_CUSTOM_REPO_PASSWORD: ${{ inputs.pypi_token }}
4247
PACKAGE_NAME: ${{ inputs.package_name }}
48+
VERSION: ${{ inputs.version }}
4349
id: package-generator
4450
- name: Create comment
4551
uses: peter-evans/create-or-update-comment@v2
52+
if: github.event.issue.number
4653
with:
4754
issue-number: ${{ github.event.issue.number }}
4855
body: Created package with number `${{ steps.package-generator.outputs.version }}`

create_package/create_package.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616

1717
set -Eeuo pipefail
1818

19-
next_version=$(git describe --tags --abbrev=0 | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
20-
version=${next_version}a${PULL_REQUEST_NUMBER}.dev${COMMENTS_COUNT}
19+
if [[ -z "$VERSION" ]]; then
20+
next_version=$(git describe --tags --abbrev=0 | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
21+
version=${next_version}a${PULL_REQUEST_NUMBER}.dev${COMMENTS_COUNT}
22+
else
23+
version="$VERSION"
24+
fi;
2125
sed -i "s/version = \"0.0.0\"/version = \"$version\"/" pyproject.toml
2226
echo "__version__ = '$version'" > "./$PACKAGE_NAME/_version.py"
2327
echo "REPOSITORY TO PUBLISH IS $REPO_URL"

0 commit comments

Comments
 (0)