From f3f1936d74f1651301a445c3e5bf1b8da520f9fc Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Thu, 29 Aug 2024 17:02:55 -0700 Subject: [PATCH 1/3] github: Actions trigger of tag push Changelog-Fixed: Regex expression for github actions tags push trigger. --- .github/workflows/docker-release.yml | 41 ++++++++++++++-------------- .github/workflows/pypi.yml | 33 +++++++++++++++++----- 2 files changed, 47 insertions(+), 27 deletions(-) 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 From d7a1a4c64d0bfecc355448160c5b0b60e2f62fdf Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Fri, 30 Aug 2024 20:51:37 -0700 Subject: [PATCH 2/3] docker: git reset to avoid modded suffix Changelog-Fixed: Core lightning's version will not be suffixed with -modded anymore. --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b9df81f6dcca..8c3acd8bcbf4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -199,7 +199,12 @@ RUN ( ! [ "${target_host}" = "arm-linux-gnueabihf" ] ) || \ # https://github.com/ElementsProject/lightning/pull/7376#issuecomment-2161102381 RUN poetry lock --no-update && poetry install -RUN ./configure --prefix=/tmp/lightning_install --enable-static && make && poetry run make install +# Ensure that git differences are removed before making bineries, to avoid `-modded` suffix +# poetry.lock changed due to pyln-client, pyln-proto and pyln-testing version updates +# pyproject.toml was updated to exclude clnrest and wss-proxy plugins in base-builder stage +RUN git reset --hard HEAD + +RUN ./configure --prefix=/tmp/lightning_install --enable-static && poetry run make install # Export the requirements for the plugins so we can install them in builder-python stage WORKDIR /opt/lightningd/plugins/clnrest From 7990e0ce0d10aac5009cffdc3054decebcc7c650 Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Sat, 31 Aug 2024 14:32:13 -0700 Subject: [PATCH 3/3] github: Read tag on HEAD in Github Actions 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. --- .github/workflows/pypi.yml | 6 +++--- Makefile | 2 +- tools/repro-build.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index b650c4f7b95f..5a45a7dfaa6c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -37,13 +37,13 @@ jobs: - name: Check version tag run: >- - git describe --always --dirty=-modded --abbrev=7 + git describe --tags --always --dirty=-modded --abbrev=7 - name: Setup Version env: WORKDIR: ${{ matrix.WORKDIR }} run: | - echo "VERSION=$(git describe --abbrev=0).post$(git describe --abbrev=1 | awk -F "-" '{print $2}')" >> $GITHUB_ENV + 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 @@ -90,7 +90,7 @@ jobs: run: | echo "POETRY VERSION PUBLISH: $(poetry --version)" cd ${{ env.WORKDIR }} - export VERSION=$(git describe --abbrev=0) + 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 diff --git a/Makefile b/Makefile index d4551cf79b70..9ff384bff6d6 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ #! /usr/bin/make # Extract version from git, or if we're from a zipfile, use dirname -VERSION=$(shell git describe --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's|.*/c\{0,1\}lightning-v\{0,1\}\([0-9a-f.rc\-]*\)$$|\1|gp') +VERSION=$(shell git describe --tags --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's|.*/c\{0,1\}lightning-v\{0,1\}\([0-9a-f.rc\-]*\)$$|\1|gp') # Next release. CLN_NEXT_VERSION := v24.08 diff --git a/tools/repro-build.sh b/tools/repro-build.sh index 3b63127c16d5..6c346616c623 100755 --- a/tools/repro-build.sh +++ b/tools/repro-build.sh @@ -54,7 +54,7 @@ else fi PLATFORM="$OS"-"$VER" -VERSION=${FORCE_VERSION:-$(git describe --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's,.*/clightning-\(v[0-9.rc\-]*\)$,\1,p')} +VERSION=${FORCE_VERSION:-$(git describe --tags --always --dirty=-modded --abbrev=7 2>/dev/null || pwd | sed -n 's,.*/clightning-\(v[0-9.rc\-]*\)$,\1,p')} # eg. ## [0.6.3] - 2019-01-09: "The Smallblock Conspiracy" # Skip 'v' here in $VERSION