From e563a193f5c29ffb569c711ad45e7063cb7f82d0 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 16 May 2021 21:53:55 +0200 Subject: [PATCH 1/3] Setup PHP release workflow in drone with lftp --- .drone.yml | 197 ++++++++++++++++++ mods/release-list-exclude.txt | 2 + ...ease-list.txt => release-list-include.txt} | 1 + 3 files changed, 200 insertions(+) create mode 100644 mods/release-list-exclude.txt rename mods/{release-list.txt => release-list-include.txt} (95%) diff --git a/.drone.yml b/.drone.yml index b45409a84..18b84b76e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -325,3 +325,200 @@ volumes: - name: cache host: path: /tmp/drone-cache +--- +kind: pipeline +type: docker +name: continous-deployment + +trigger: + repo: + - friendica/friendica + branch: + - develop + - 20*-rc + event: + - push + +node: + node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca + +steps: + - name: Clone addon + image: alpine/git + commands: + - git clone https://github.com/friendica/friendica-addons ./addon + - cd ./addon + - git checkout $DRONE_REPO_BRANCH + - name: Restore cache + image: meltwater/drone-cache:dev + settings: + backend: "filesystem" + restore: true + cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}' + archive_format: "gzip" + mount: + - '.composer' + volumes: + - name: cache + path: + /tmp/cache + - name: Composer install + image: friendicaci/php7.4:php7.4.18 + commands: + - export COMPOSER_HOME=.composer + - composer validate + - composer install --no-dev --optimize-autoloader + - name: Create artifacts + image: debian + commands: + - apt-get update + - apt-get install bzip2 + - mkdir ./build + - export VERSION="$(cat VERSION)" + - # Create artifact + - export RELEASE="friendica-full-$VERSION" + - export ARTIFACT="$RELEASE.tar.gz" + - tar + --transform "s,^,$RELEASE/," + -X mods/release-list-exclude.txt + -T mods/release-list-include.txt + -cvjf ./build/$ARTIFACT + - # calculate SHA256 checksum + - cd ./build + - sha256sum "$ARTIFACT" > "$ARTIFACT.sha256" + - ls -lh + - # output the sha256 sum for checking + - cat "$ARTIFACT.sha256" + - sha256sum "$ARTIFACT" + - name: Upload artifacts + image: alpine + environment: + LFTP_HOST: + from_secret: sftp_host + LFTP_USER: + from_secret: sftp_user + LFTP_KEY: + from_secret: ssh_key + LFTP_PORT: "22" + LFTP_SOURCE: "build" + LFTP_TARGET: "/http" + commands: + - apk add lftp openssh openssl + - touch drone.key + - chmod 400 drone.key + - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key + - lftp -c " + set net:timeout 5; + set net:max-retries 2; + set net:reconnect-interval-base 5; + set sftp:auto-confirm true; + set sftp:connect-program 'ssh -q -a -x -i drone.key'; + connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT; + cd $LFTP_TARGET; + mput $LFTP_SOURCE/*; + " + - rm drone.key + +volumes: + - name: cache + host: + path: /tmp/drone-cache +--- +kind: pipeline +type: docker +name: release-deployment + +trigger: + repo: + - friendica/friendica + branch: + - stable + event: + - tag + +node: + node: releaser # This prevents executing this pipeline at other servers than drone.friendi.ca + +steps: + - name: Clone addon + image: alpine/git + commands: + - git clone https://github.com/friendica/friendica-addons ./addon + - cd ./addon + - git checkout $DRONE_REPO_BRANCH + - name: Restore cache + image: meltwater/drone-cache:dev + settings: + backend: "filesystem" + restore: true + cache_key: '{{ .Repo.Name }}_php74_{{ arch }}_{{ os }}' + archive_format: "gzip" + mount: + - '.composer' + volumes: + - name: cache + path: + /tmp/cache + - name: Composer install + image: friendicaci/php7.4:php7.4.18 + commands: + - export COMPOSER_HOME=.composer + - composer validate + - composer install --no-dev --optimize-autoloader + - name: Create artifacts + image: debian + commands: + - apt-get update + - apt-get install bzip2 + - mkdir ./build + - export VERSION="$(cat VERSION)" + - mkdir ./build + - export VERSION="$(cat VERSION)" + - # Create artifact + - export RELEASE="friendica-full-$VERSION" + - export ARTIFACT="$RELEASE.tar.gz" + - tar + --transform "s,^,$RELEASE/," + -X mods/release-list-exclude.txt + -T mods/release-list-include.txt + -cvjf ./build/$ARTIFACT + - # calculate SHA256 checksum + - cd ./build + - sha256sum "$ARTIFACT" > "$ARTIFACT.sha256" + - ls -lh + - # output the sha256 sum for checking + - cat "$ARTIFACT.sha256" + - sha256sum "$ARTIFACT" + - name: Upload artifacts + image: alpine + environment: + LFTP_HOST: + from_secret: sftp_host + LFTP_USER: + from_secret: sftp_user + LFTP_KEY: + from_secret: ssh_key + LFTP_PORT: "22" + LFTP_SOURCE: "build" + LFTP_TARGET: "/http" + commands: + - apk add lftp openssh openssl + - touch drone.key + - chmod 400 drone.key + - echo "$LFTP_KEY" | openssl base64 -A -d > drone.key + - lftp -c " + set net:timeout 5; + set net:max-retries 2; + set net:reconnect-interval-base 5; + set sftp:auto-confirm true; + set sftp:connect-program 'ssh -q -a -x -i drone.key'; + connect sftp://$LFTP_USER:@$LFTP_HOST:$LFTP_PORT; + cd $LFTP_TARGET; + mput $LFTP_SOURCE/*; + " + - rm drone.key + +volumes: + - name: cache + host: + path: /tmp/drone-cache diff --git a/mods/release-list-exclude.txt b/mods/release-list-exclude.txt new file mode 100644 index 000000000..e370e73af --- /dev/null +++ b/mods/release-list-exclude.txt @@ -0,0 +1,2 @@ +view/lang/*/messages.po +view/smarty3/compiled/* \ No newline at end of file diff --git a/mods/release-list.txt b/mods/release-list-include.txt similarity index 95% rename from mods/release-list.txt rename to mods/release-list-include.txt index dfebc0216..95faa36ed 100644 --- a/mods/release-list.txt +++ b/mods/release-list-include.txt @@ -1,3 +1,4 @@ +bin/.htaccess bin/auth_ejabberd.php bin/console bin/console.bat From 970b8b3b31ffc87872e5488014b8c023da20764a Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 16 May 2021 22:09:45 +0200 Subject: [PATCH 2/3] Remove github workflows --- .github/workflows/releases.yml | 67 ---------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 .github/workflows/releases.yml diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml deleted file mode 100644 index 9a7c544d9..000000000 --- a/.github/workflows/releases.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Generate release packages -on: - release: - types: [published] -jobs: - release: - name: Create release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 - with: - tools: pecl, composer:v1 - - - name: Retrieve version - id: release - run: echo "::set-output name=version::$(cat VERSION)" - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Get composer cache directory - id: composercache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composercache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --no-dev --optimize-autoloader - - - name: Create artifact - id: artifact - run: | - ARTIFACT="friendica-full-${{ steps.release.outputs.version }}.tar.gz" - echo "::set-output name=name::${ARTIFACT}" - mkdir build - tar -cvjf build/${ARTIFACT} -T mods/release-list.txt - - - name: SHA256 - id: sha256 - run: | - cd build - ARTIFACT=${{ steps.artifact.outputs.name }} - sha256sum "${ARTIFACT}" > "${ARTIFACT}.sha256" - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: friendica - path: build/ - - - name: Upload to release - uses: softprops/action-gh-release@v1 - with: - files: | - build/${{ steps.artifact.outputs.name }}.tar.gz - build/${{ steps.artifact.outputs.name }}.tar.gz.sha256 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 385875f1ca6a2aa1cdb8f33330e7b31164fe81b6 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 3 Sep 2021 16:14:38 +0200 Subject: [PATCH 3/3] Update .drone.yml Co-authored-by: Hypolite Petovan --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 18b84b76e..1b2da85b5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -328,7 +328,7 @@ volumes: --- kind: pipeline type: docker -name: continous-deployment +name: continuous-deployment trigger: repo: