Add release publish action #1
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
name: Publish release | ||
on: | ||
release: | ||
types: [created] | ||
env: | ||
IS_TEST: true | ||
jobs: | ||
generate_info: | ||
name: Generate info | ||
environment: release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Parse version tag | ||
id: parse_version_tag | ||
env: | ||
TAG_NAME: ${{ github.event.release.tag_name }} | ||
run: | | ||
tag_name="${{ env.TAG_NAME }}" | ||
if [[ ! "${tag_name}" =~ ^v.+$ ]]; then | ||
echo "::error::Tag name must start with 'v'" | ||
exit 1 | ||
fi | ||
pypi_output="pypi-version=${tag_name#v}" | ||
echo "${pypi_output}" >> $GITHUB_OUTPUT | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: pip install build twine | ||
- name: Update package version | ||
run: | | ||
echo "VERSION = \"${{ needs.generate_info.outputs.pypi-version }}\"" > ergate/__version__.py | ||
- name: Build a binary wheel and a source tarball | ||
run: python -m build --sdist --wheel --outdir dist/ . | ||
- name: Publish package distribution | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: ${{ env.IS_TEST == 'true' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }} |