0.0.1 -> Release->Build and Publish Pypi ( 2 ) #1
Workflow file for this run
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: Release->Build and Publish to PyPi | |
# yamllint disable rule:line-length | |
on: | |
release: | |
types: [published] | |
# set the run-name | |
run-name: ${{ github.ref_name }} -> Release->Build and Publish Pypi ( | |
${{ github.run_attempt }} | |
) | |
jobs: | |
output_debug_info: | |
name: Output debug info | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get current date and time | |
id: datetime | |
run: | | |
datetime=$(date +'%Y-%m-%dT%H-%M-%SZ') | |
echo "datetime=$datetime" >> $GITHUB_OUTPUT | |
- name: Display Run Name | |
run: echo ${{ steps.datetime.outputs.datetime }} | |
build_and_publish: | |
name: Build artifacts and publish to pyPi | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Python 3.11 | |
uses: actions/[email protected] | |
with: | |
python-version: 3.11 | |
- name: Update pip and install hatch | |
run: | | |
python -m pip install --upgrade pip | |
pip install hatch | |
- name: Get version | |
id: get_version | |
run: | | |
export version=$(hatch version) | |
echo "version=$version" >> $GITHUB_OUTPUT | |
#validates that the version is a valid semver | |
- name: Validate version | |
id: validate_version | |
run: | | |
if [[ ! ${{ steps.get_version.outputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "Invalid version: ${{ steps.get_version.outputs.version }}" | |
exit 1 | |
fi | |
- name: Hatch build | |
run: hatch build | |
- name: Display structure of build files | |
id: display_build_files | |
run: | | |
ls -R dist/ | |
- name: Archive all artifacts in dist/ | |
uses: actions/[email protected] | |
with: | |
name: dist-v${{ steps.get_version.outputs.version }} | |
path: dist/ | |
if-no-files-found: error | |
- name: Publish to PyPi | |
uses: pypa/[email protected] | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ |