diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 131bf152d147..227a4a2c0636 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -3,7 +3,9 @@ name: Build and push multi-platform docker images on: push: tags: - - '^v[0-9]{2}\.[0-9]{2}(\.[0-9]{1,2})?([a-zA-Z0-9]*)?$' + - 'v[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+[0-9a-z]+' workflow_dispatch: inputs: version: @@ -48,9 +50,11 @@ jobs: - name: Set up values id: set-values run: | - if [ "${{ github.event.inputs.version }}" != "" ]; then + if [[ "${{ github.event.inputs.version }}" != "" ]]; then + echo "Input version provided" VERSION=${{ github.event.inputs.version }} - elif [ "${{ github.ref_type }}" == "tag" ]; then + elif [[ ${{ github.ref_type }} == "tag" ]]; then + echo "This is a tag event" VERSION=${{ github.ref_name }} else echo "No version provided and no tag found." @@ -58,36 +62,33 @@ jobs: fi echo "VERSION=$VERSION" >> $GITHUB_ENV - if [ "${{ github.event.inputs.repository-name }}" != "" ]; then + if [[ "${{ github.event.inputs.repository-name }}" != "" ]]; then REPONAME=${{ github.event.inputs.repository-name }} else REPONAME="elementsproject" fi echo "REPONAME=$REPONAME" >> $GITHUB_ENV - if [ "${{ github.event.inputs.platforms-to-build }}" != "" ]; then + if [[ "${{ github.event.inputs.platforms-to-build }}" != "" ]]; then PLATFORMS=${{ github.event.inputs.platforms-to-build }} else PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7" fi echo "PLATFORMS=$PLATFORMS" >> $GITHUB_ENV - if [ - "${{ github.event.inputs.push-latest }}" == "true" || - ( "${{ github.ref_type }}" == "tag" && [[ ! "${{ env.VERSION }}" =~ rc ]] ) - ]; then + if [[ "${{ github.event.inputs.push-latest }}" == "true" ]] || + ([[ "${{ github.ref_type }}" == "tag" ]] && [[ ! "$VERSION" =~ rc ]]); then + echo "Latest true" PUSHLATEST="true" else + echo "Latest false" PUSHLATEST="false" fi echo "PUSHLATEST=$PUSHLATEST" >> $GITHUB_ENV - - name: Set Tags - id: set-tags - run: | - TAGS="${{ env.REPONAME }}/lightningd:${{ env.VERSION }}" - if [ "${{ env.PUSHLATEST }}" == "true" ]; then - TAGS="$TAGS,${{ env.REPONAME }}/lightningd:latest" + TAGS="$REPONAME/lightningd:$VERSION" + if [[ "$PUSHLATEST" == "true" ]]; then + TAGS="$TAGS,$REPONAME/lightningd:latest" fi echo "TAGS=$TAGS" >> $GITHUB_ENV @@ -99,11 +100,11 @@ jobs: echo "EVENT INPUT REPO: ${{ github.event.inputs.repository-name }}" echo "EVENT INPUT PLATFORMS: ${{ github.event.inputs.platforms-to-build }}" echo "EVENT INPUT PUSH LATEST: ${{ github.event.inputs.push-latest }}" - echo "VERSION ENV: ${{ env.VERSION }}" - echo "REPO NAME: ${{ env.REPONAME }}" - echo "PLATFORMS: ${{ env.PLATFORMS }}" - echo "PUSH LATEST: ${{ env.PUSHLATEST }}" - echo "TAGS: ${{ env.TAGS }}" + echo "ENV VERSION: ${{ env.VERSION }}" + echo "ENV REPO NAME: ${{ env.REPONAME }}" + echo "ENV PLATFORMS: ${{ env.PLATFORMS }}" + echo "ENV PUSH LATEST: ${{ env.PUSHLATEST }}" + echo "ENV TAGS: ${{ env.TAGS }}" - name: Build and push Docker image uses: docker/build-push-action@v5 diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 038d49fb1170..b650c4f7b95f 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -3,8 +3,15 @@ name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI on: push: tags: - '^v[0-9]{2}\.[0-9]{2}(\.[0-9]{1,2})?$' + - '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: @@ -21,8 +28,6 @@ jobs: WORKDIR: contrib/pyln-testing - PACKAGE: pyln-proto WORKDIR: contrib/pyln-proto - - PACKAGE: pyln-grpc-proto - WORKDIR: contrib/pyln-grpc-proto steps: - name: Checkout repository uses: actions/checkout@v4 @@ -40,6 +45,20 @@ jobs: run: | echo "VERSION=$(git describe --abbrev=0).post$(git describe --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 }} @@ -49,13 +68,13 @@ jobs: echo "PATH=$HOME/.local/bin:$PATH" - name: Publish distribution 📦 to Test PyPI - if: github.event_name == 'workflow_dispatch' && github.repository == 'ElementsProject/lightning' + 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" + echo "Pyln VERSION: $VERSION" cd ${{ env.WORKDIR }} python3 -m pip config set global.timeout 150 poetry config repositories.testpypi https://test.pypi.org/legacy/ @@ -64,15 +83,15 @@ jobs: poetry publish --repository testpypi --no-interaction --skip-existing - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'ElementsProject/lightning' + 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)" - echo "Pyln* VERSION: $VERSION" cd ${{ env.WORKDIR }} export VERSION=$(git describe --abbrev=0) + echo "Pyln VERSION: $VERSION" make upgrade-version NEW_VERSION=$VERSION python3 -m pip config set global.timeout 150 poetry build --no-interaction