From 476cc995d4bd226cdf4bf9dc4f2d8cabb9ed986b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Ko=CC=88ninger?= Date: Sun, 31 May 2020 14:04:47 +0200 Subject: [PATCH] chore(build.sh): add build script --- .github/workflows/main.yml | 50 -------------------------- build.sh | 73 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100755 build.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index e2c7edf..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,50 +0,0 @@ -on: - push: - tags: - - 'v*' - -env: - NODE_VERSION: '12.x' # set this to the node version to use - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - path: customproperties - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v1 - with: - node-version: ${{ env.NODE_VERSION }} - - name: npm install, build, and test - run: | - cd customproperties/src - npm ci - npm run build - - name: Build release artifact archive - run: | - tar -czvf customproperties.tar.gz \ - --exclude=customproperties/src/ \ - customproperties/ - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: false - prerelease: false - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./customproperties.tar.gz - asset_name: customproperties.tar.gz - asset_content_type: application/tar+gzip diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..0eb161a --- /dev/null +++ b/build.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +main() { + local version + version=$1 + + downloadAndExtract $version + buildJavaScript + signSource + buildArchive + createSignature + + rm v$version.tar.gz + rm -rf customproperties +} + +downloadAndExtract() { + local version + version=$1 + + wget https://github.com/SteKoe/nextcloud-customproperties/archive/v$version.tar.gz -O v$version.tar.gz + tar -zxf v$version.tar.gz + + mv nextcloud-customproperties-$version customproperties +} + +buildJavaScript() { + echo "Build JavaScript..." + (cd customproperties/src && npm ci && npm run build) +} + +signSource() { + local cid + + rm -rf customproperties/.git customproperties/src + + cid=$(docker run -d -v `pwd`/customproperties:/app -v ~/.nextcloud/certificates/:/nextcloud/certificates/ nextcloud) + echo "Sign sources using container '$cid'..." + + echo "Waiting for NextCloud to be initialized..." + until docker logs $cid 2>&1 | grep "Initializing finished" > /dev/null; + do + sleep 1 + echo "Waiting..." + done + echo "NextCloud initialized!" + + echo "Signing app..." + docker exec -i $cid /bin/bash -c "chmod -R +w /app" || true + docker exec -i $cid php occ integrity:sign-app --privateKey=/nextcloud/certificates/customproperties.key --certificate=/nextcloud/certificates/customproperties.crt --path=/app || true + echo "Tidy up..." + docker rm -f $cid > /dev/null +} + +buildArchive() { + echo "Build archive..." + (tar -czf customproperties.tar.gz \ + --exclude=./src/node_modules/ \ + --exclude=./.git/ \ + --exclude=./src/ \ + customproperties/) +} + +createSignature() { + echo "Create signature..." + openssl dgst -sha512 -sign ~/.nextcloud/certificates/customproperties.key customproperties.tar.gz | openssl base64 +} + +main $@