From 1ca91842fd6d45490f27f771e911130e898ff701 Mon Sep 17 00:00:00 2001 From: unglaublicherdude Date: Thu, 20 Jun 2024 16:24:41 +0200 Subject: [PATCH] setup a matrix build --- .github/workflows/release-app.yml | 12 +++++++- get-matrix.sh | 46 +++++++++++++++++++++++++++++++ install.sh | 4 ++- 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100755 get-matrix.sh diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml index 88899f35..2cc8284c 100644 --- a/.github/workflows/release-app.yml +++ b/.github/workflows/release-app.yml @@ -8,8 +8,18 @@ on: branches: ["*"] jobs: + matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - id: set-matrix + run: ./get-matrix.sh >> $GITHUB_OUTPUT test: runs-on: ubuntu-latest + strategy: + matrix: ${{fromJson(needs.job1.outputs.matrix)}} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -34,7 +44,7 @@ jobs: env: CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }} CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }} - run: ./install.sh + run: ./install.sh ${{ matrix.nextcloud_version }} - name: run tests env: diff --git a/get-matrix.sh b/get-matrix.sh new file mode 100755 index 00000000..365420b9 --- /dev/null +++ b/get-matrix.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +MIN_VERSION=$([[ $(cat appinfo/info.xml) =~ $(echo 'min-version=[^[0-9]]*([0-9]+).*') ]] && echo ${BASH_REMATCH[1]}) +MAX_VERSION=$([[ $(cat appinfo/info.xml) =~ $(echo 'max-version=[^[0-9]]*([0-9]+).*') ]] && echo ${BASH_REMATCH[1]}) + +BASE_TEMPLATE='matrix={"include":[VERSIONS]}' +VERSION_TEMPLATE='{"nextcloud_version":"NEXTCLOUD_VERSION"}' + + +if [ -z "$MIN_VERSION" ] && [ -z "$MAX_VERSION" ]; then + echo 'matrix={"include":[{"nextcloud_version":"29"}]}' + exit 0 +fi + +if [ -z "$MIN_VERSION" ] && [ -n "$MAX_VERSION" ] ; then + VERSIONS=$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$MAX_VERSION/g") + echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g" + exit 0 +fi + +if [ -n "$MIN_VERSION" ] && [ -z "$MAX_VERSION" ] ; then + VERSIONS=$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$MIN_VERSION/g") + echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g" +fi + +if [ "$MIN_VERSION" -eq "$MAX_VERSION" ]; then + VERSIONS=$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$MIN_VERSION/g") + echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g" + exit 0 +fi + +if [ "$MIN_VERSION" -gt "$MAX_VERSION" ]; then + echo 'Min version should be less or equal to max version' + exit 1 +fi + +VERSION_TEMPLATE='{"nextcloud_version":"NEXTCLOUD_VERSION"}' +VERSIONS="" +for i in $(eval echo {$MIN_VERSION..$MAX_VERSION}) +do + VERSIONS="$VERSIONS,$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$i/g")" +done +echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g" + + + diff --git a/install.sh b/install.sh index 0933322b..38bc2161 100755 --- a/install.sh +++ b/install.sh @@ -1,12 +1,14 @@ #!/bin/bash +NEXTCLOUD_VERSION=${1:-29} + source .env-local || echo "No .env-local file found." setup_nextcloud () { echo "setup nextcloud" docker stop nextcloud-container || echo "No container to stop" sleep 1 - docker run -d --name nextcloud-container --rm --publish 80:80 nextcloud:29 + docker run -d --name nextcloud-container --rm --publish 80:80 nextcloud:$NEXTCLOUD_VERSION until docker exec --user www-data -i nextcloud-container php occ status | grep "installed: false" do