Skip to content

Commit

Permalink
Add python-version as an extra argument
Browse files Browse the repository at this point in the history
Fix `env` and `inputs` when using `with`
Set `--verbose` flag based on `RUNNER_DEBUG`
  • Loading branch information
dormant-user committed May 27, 2024
1 parent 8349c5e commit a75f361
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ jobs:
- `skip-existing` - Avoids failing if distribution exists in package index.
- `verbose` - Runs in verbose mode. Defaults to `false`
- `print-hash` - Show hash values of distribution files. Defaults to `true`
- `setup-python` - Uses the GH action `setup-python`. Defaults to `false`,
- `setup-python` - Uses the GH action `setup-python`. Defaults to `false`
but gets overridden dynamically based on `python` command's availability.
- `python-version` - Python version for `setup-python`. Defaults to `3.9`

## License & copyright

Expand Down
14 changes: 11 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ inputs:
description: Use setup python to load python env.
required: false
default: 'false'
python-version:
description: Python version to use.
required: false
default: '3.9'
branding:
color: gray-dark
icon: package
Expand Down Expand Up @@ -111,7 +115,7 @@ runs:
TWINE_EXTRA_ARGS="${TWINE_EXTRA_ARGS} --skip-existing"
fi
if [[ ${{ inputs.verbose }} != "false" ]]; then
if [[ ${{ inputs.verbose }} != "false" ]] || [ "${{ env.RUNNER_DEBUG }}" == "1" ]; then
TWINE_EXTRA_ARGS="--verbose $TWINE_EXTRA_ARGS"
fi
echo "TWINE_EXTRA_ARGS=$TWINE_EXTRA_ARGS" >> $GITHUB_ENV
Expand All @@ -122,6 +126,10 @@ runs:
echo "repository_url=https://upload.pypi.org/legacy/" >> $GITHUB_ENV
fi
if ! [[ ${{ env.token }} ]]; then
echo "token=${{ inputs.token }}" >> $GITHUB_ENV
fi
if [[ ${{ inputs.setup-python }} == "true" ]]; then
if [[ ${{ env.os_name }} == "darwin" ]]; then
# Discussion: https://github.com/orgs/community/discussions/26239
Expand All @@ -146,7 +154,7 @@ runs:
if: env.setup_python == true
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: ${{ inputs.python-version }}

- name: Install dependencies
run: |
Expand Down Expand Up @@ -211,7 +219,7 @@ runs:
if: inputs.dry-run != false
env:
TWINE_USERNAME: ${{ inputs.user }}
TWINE_PASSWORD: ${{ inputs.token }}
TWINE_PASSWORD: ${{ env.token }}
TWINE_REPOSITORY_URL: ${{ env.repository_url }}
run: twine upload ${{ env.TWINE_EXTRA_ARGS }} ${{ inputs.packages-dir }}/*.whl
shell: bash
Expand Down

0 comments on commit a75f361

Please sign in to comment.