2023-02-28 17:14:59 +00:00
|
|
|
name: Publish
|
|
|
|
on:
|
2024-12-25 10:19:42 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
|
|
- cron: "0 9 * * 0"
|
2023-02-28 17:14:59 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-12-25 10:19:42 +00:00
|
|
|
test:
|
|
|
|
uses: luketainton/gha-workflows/.github/workflows/ci-python-poetry.yml@main
|
|
|
|
with:
|
|
|
|
python-version: 3.11
|
|
|
|
secrets:
|
|
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
|
|
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
|
|
|
|
|
|
create_release:
|
|
|
|
name: Create Release
|
2024-12-25 10:26:03 +00:00
|
|
|
needs: test
|
2024-12-25 10:19:42 +00:00
|
|
|
uses: luketainton/gha-workflows/.github/workflows/create-release.yml@main
|
|
|
|
|
2023-02-28 17:14:59 +00:00
|
|
|
build:
|
2024-12-25 10:19:42 +00:00
|
|
|
name: Build Wheel File
|
|
|
|
needs: create_release
|
|
|
|
if: ${{ needs.create_release.outputs.success == 'true' }}
|
2023-02-28 17:14:59 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out repository code
|
2024-12-25 10:19:42 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-02-28 17:14:59 +00:00
|
|
|
- name: Setup Python
|
2023-12-10 14:46:59 +00:00
|
|
|
uses: actions/setup-python@v5
|
2023-02-28 17:14:59 +00:00
|
|
|
with:
|
|
|
|
python-version: "3.11"
|
2024-12-25 10:19:42 +00:00
|
|
|
- name: Update pyproject.toml
|
|
|
|
run:
|
|
|
|
prefix="v"
|
2024-12-25 10:38:12 +00:00
|
|
|
echo "prefix=$prefix"
|
|
|
|
string="v1.3.1"
|
|
|
|
echo "string=$string"
|
2024-12-25 10:19:42 +00:00
|
|
|
versionname=${string#"$prefix"}
|
2024-12-25 10:38:12 +00:00
|
|
|
echo "versionname=$versionname"
|
|
|
|
oldpyprojectversion="version = \"0.0.0\""
|
|
|
|
echo "oldpyprojectversion=$oldpyprojectversion"
|
|
|
|
pyprojectversion="version = \"$versionname\""
|
|
|
|
echo "pyprojectversion=$pyprojectversion"
|
|
|
|
sed -i "s@$oldpyprojectversion@$pyprojectversion@g" pyproject.toml
|
2024-04-27 18:28:14 +01:00
|
|
|
- name: Setup Poetry
|
2024-04-29 06:21:17 +00:00
|
|
|
uses: abatilo/actions-poetry@v3
|
2023-02-28 17:14:59 +00:00
|
|
|
- name: Install dependencies
|
2024-04-27 18:28:14 +01:00
|
|
|
run: poetry install
|
2023-02-28 17:14:59 +00:00
|
|
|
- name: Build wheel file
|
2024-04-27 18:28:14 +01:00
|
|
|
run: poetry build
|
2024-12-25 10:19:42 +00:00
|
|
|
- name: Upload Artifact
|
2023-12-14 21:01:52 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-02-28 17:14:59 +00:00
|
|
|
with:
|
|
|
|
name: whl
|
|
|
|
path: dist/
|
2024-12-25 10:19:42 +00:00
|
|
|
- name: Upload Release Asset
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: gh release upload ${{ needs.create_release.outputs.release_name }} dist/*.whl
|
2023-02-28 17:14:59 +00:00
|
|
|
|
|
|
|
publish:
|
2024-12-25 10:19:42 +00:00
|
|
|
name: Publish to PyPI
|
|
|
|
needs: [create_release, build]
|
|
|
|
if: ${{ needs.create_release.outputs.success == 'true' }}
|
2023-02-28 17:14:59 +00:00
|
|
|
runs-on: ubuntu-latest
|
2024-04-27 18:28:14 +01:00
|
|
|
# Specifying a GitHub environment is optional, but strongly encouraged
|
2024-04-27 18:34:44 +01:00
|
|
|
environment:
|
|
|
|
name: release
|
|
|
|
url: https://pypi.org/p/ipilot
|
2024-04-27 18:28:14 +01:00
|
|
|
permissions:
|
|
|
|
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
|
|
id-token: write
|
2023-02-28 17:14:59 +00:00
|
|
|
steps:
|
|
|
|
- name: Create dist folder
|
2024-04-27 18:28:14 +01:00
|
|
|
run: mkdir -p dist
|
2023-12-14 19:53:45 +00:00
|
|
|
- uses: actions/download-artifact@v4
|
2023-02-28 17:14:59 +00:00
|
|
|
with:
|
|
|
|
name: whl
|
|
|
|
path: dist
|
|
|
|
- name: Publish to PyPI
|
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|