mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-13 02:58:21 +01:00
Running `git describe` in local setup correctly identifies the tag available on the tag. But `docker buildx` via actions does not identify it without `--tags` param. Reference Issue: https://github.com/ElementsProject/lightning/issues/7626 Changelog-Fixed: Docker image created via github actions correctly reads the tag available on the HEAD.
98 lines
3.4 KiB
YAML
98 lines
3.4 KiB
YAML
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v[0-9]+.[0-9]+'
|
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
|
- 'v[0-9]+.[0-9]+[0-9a-z]+'
|
|
workflow_dispatch:
|
|
inputs:
|
|
dist-location:
|
|
description: 'Distribution location (test/prod)'
|
|
default: 'test'
|
|
required: false
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Build and publish ${{ matrix.package }} 🐍
|
|
runs-on: ubuntu-20.04
|
|
timeout-minutes: 120
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
include:
|
|
- PACKAGE: pyln-client
|
|
WORKDIR: contrib/pyln-client
|
|
- PACKAGE: pyln-testing
|
|
WORKDIR: contrib/pyln-testing
|
|
- PACKAGE: pyln-proto
|
|
WORKDIR: contrib/pyln-proto
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
# Need to fetch entire history in order to locate the version tag
|
|
fetch-depth: 0
|
|
|
|
- name: Check version tag
|
|
run: >-
|
|
git describe --tags --always --dirty=-modded --abbrev=7
|
|
|
|
- name: Setup Version
|
|
env:
|
|
WORKDIR: ${{ matrix.WORKDIR }}
|
|
run: |
|
|
echo "VERSION=$(git describe --tags --abbrev=0).post$(git describe --tags --abbrev=1 | awk -F "-" '{print $2}')" >> $GITHUB_ENV
|
|
|
|
- name: Set up values
|
|
id: set-values
|
|
run: |
|
|
if [[ "${{ github.event.inputs.dist-location }}" != "" ]]; then
|
|
DISTLOCATION=${{ github.event.inputs.dist-location }}
|
|
elif [[ "${{ github.ref_type }}" == "tag" ]] && [[ ! "${{ github.ref_name }}" =~ rc ]]; then
|
|
DISTLOCATION="prod"
|
|
else
|
|
DISTLOCATION="test"
|
|
fi
|
|
echo "DISTLOCATION=$DISTLOCATION" >> $GITHUB_OUTPUT
|
|
echo "EVENT DISTLOCATION: ${{ github.event.inputs.dist-location }}"
|
|
echo "DISTRIBUTION LOCATION: $DISTLOCATION"
|
|
|
|
- name: Install Poetry
|
|
env:
|
|
WORKDIR: ${{ matrix.WORKDIR }}
|
|
run: |
|
|
curl -sSL https://install.python-poetry.org | python3 -
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
echo "PATH=$HOME/.local/bin:$PATH"
|
|
|
|
- name: Publish distribution 📦 to Test PyPI
|
|
if: github.repository == 'ElementsProject/lightning' && steps.set-values.outputs.DISTLOCATION == 'test'
|
|
env:
|
|
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
WORKDIR: ${{ matrix.WORKDIR }}
|
|
run: |
|
|
echo "POETRY VERSION TEST: $(poetry --version)"
|
|
echo "Pyln VERSION: $VERSION"
|
|
cd ${{ env.WORKDIR }}
|
|
python3 -m pip config set global.timeout 150
|
|
poetry config repositories.testpypi https://test.pypi.org/legacy/
|
|
make upgrade-version NEW_VERSION=$VERSION
|
|
poetry build --no-interaction
|
|
poetry publish --repository testpypi --no-interaction --skip-existing
|
|
|
|
- name: Publish distribution 📦 to PyPI
|
|
if: github.repository == 'ElementsProject/lightning' && steps.set-values.outputs.DISTLOCATION == 'prod'
|
|
env:
|
|
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
|
|
WORKDIR: ${{ matrix.WORKDIR }}
|
|
run: |
|
|
echo "POETRY VERSION PUBLISH: $(poetry --version)"
|
|
cd ${{ env.WORKDIR }}
|
|
export VERSION=$(git describe --tags --abbrev=0)
|
|
echo "Pyln VERSION: $VERSION"
|
|
make upgrade-version NEW_VERSION=$VERSION
|
|
python3 -m pip config set global.timeout 150
|
|
poetry build --no-interaction
|
|
poetry publish --no-interaction
|