From 57d1dd3bb09fdc5848ca35eadb74811a67fd3656 Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 4 Sep 2023 21:56:28 +0200 Subject: [PATCH] simplify ci/ reduce gh actions --- .../build-debian-image-beta-node20.yml | 97 --------- .github/workflows/build-debian-image-beta.yml | 97 --------- .github/workflows/build-debian12-beta.yml | 186 ++++++++++++++++++ .../workflows/build-debian12-dev-node20.yml | 92 --------- .github/workflows/build-debian12-dev.yml | 8 +- CHANGELOG.md | 1 + 6 files changed, 191 insertions(+), 290 deletions(-) delete mode 100644 .github/workflows/build-debian-image-beta-node20.yml delete mode 100644 .github/workflows/build-debian-image-beta.yml create mode 100644 .github/workflows/build-debian12-beta.yml delete mode 100644 .github/workflows/build-debian12-dev-node20.yml diff --git a/.github/workflows/build-debian-image-beta-node20.yml b/.github/workflows/build-debian-image-beta-node20.yml deleted file mode 100644 index ede0388..0000000 --- a/.github/workflows/build-debian-image-beta-node20.yml +++ /dev/null @@ -1,97 +0,0 @@ -# Github action to build Docker image from beta branch (tag: beta) -name: Build debian beta-node20 - -on: - release: - types: [prereleased] - workflow_dispatch: - -jobs: - build-beta-node20-image: - runs-on: ubuntu-latest - steps: - - name: Fetching latest prerelease tag - run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Checkout repo - uses: actions/checkout@v3.5.3 - with: - repository: 'buanet/ioBroker.docker' - ref: ${{ env.RELEASE_TAG }} - - - name: Fetching version tag and date - id: version - run: | - VERSION="$(cat .VERSION)" - MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')" - DATI="$(date --rfc-3339=seconds | sed 's/ /T/')" - echo "This is the Version: $VERSION" - echo "version=$VERSION" >> $GITHUB_ENV - echo "This is the Major Version: $MAJORVERSION" - echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV - echo "This is the Buildnumber/Timestamp: $DATI" - echo "dati=$DATI" >> $GITHUB_ENV - # startup script - sed -e "s/\${VERSION}/$VERSION/" -e "s/\${BUILD}/$DATI/" ./debian/scripts/iobroker_startup.sh > ./debian/scripts/iobroker_startup.tmp - mv -f ./debian/scripts/iobroker_startup.tmp ./debian/scripts/iobroker_startup.sh - # amd64 - sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./debian/node20/Dockerfile > ./debian/node20/Dockerfile.tmp - mv -f ./debian/node20/Dockerfile.tmp ./debian/node20/Dockerfile - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2.2.0 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2.9.1 - - - name: Login to DockerHub - uses: docker/login-action@v2.2.0 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASS }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2.2.0 - with: - registry: ghcr.io - username: ${{ secrets.PACKAGES_USER }} - password: ${{ secrets.PACKAGES_PASS }} - - - name: Build Docker image (node20) - uses: docker/build-push-action@v4.1.1 - with: - context: ./debian - file: ./debian/node20/Dockerfile - push: true - platforms: | - linux/amd64 - linux/arm/v7 - linux/arm64/v8 - tags: | - buanet/iobroker:beta-node20, - buanet/iobroker:${{ env.version }}-node20, - ghcr.io/buanet/iobroker:beta-node20, - ghcr.io/buanet/iobroker:${{ env.version }}-node20 - provenance: false - outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) - - - name: Delete untagged images from GitHub packages - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.PACKAGES_PASS }} - script: | - const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions", - { per_page: ${{ env.PER_PAGE }} - }); - for(version of response.data) { - if (version.metadata.container.tags.length == 0) { - console.log("delete " + version.id) - const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); - console.log("status " + deleteResponse.status) - } - } - env: - OWNER: buanet - PACKAGE_NAME: iobroker - PER_PAGE: 100 diff --git a/.github/workflows/build-debian-image-beta.yml b/.github/workflows/build-debian-image-beta.yml deleted file mode 100644 index 5db6121..0000000 --- a/.github/workflows/build-debian-image-beta.yml +++ /dev/null @@ -1,97 +0,0 @@ -# Github action to build Docker image from beta branch (tag: beta) -name: Build debian beta - -on: - release: - types: [prereleased] - workflow_dispatch: - -jobs: - build-beta-image: - runs-on: ubuntu-latest - steps: - - name: Fetching latest prerelease tag - run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Checkout repo - uses: actions/checkout@v3.5.3 - with: - repository: 'buanet/ioBroker.docker' - ref: ${{ env.RELEASE_TAG }} - - - name: Fetching version tag and date - id: version - run: | - VERSION="$(cat .VERSION)" - MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')" - DATI="$(date --rfc-3339=seconds | sed 's/ /T/')" - echo "This is the Version: $VERSION" - echo "version=$VERSION" >> $GITHUB_ENV - echo "This is the Major Version: $MAJORVERSION" - echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV - echo "This is the Buildnumber/Timestamp: $DATI" - echo "dati=$DATI" >> $GITHUB_ENV - # startup script - sed -e "s/\${VERSION}/$VERSION/" -e "s/\${BUILD}/$DATI/" ./debian/scripts/iobroker_startup.sh > ./debian/scripts/iobroker_startup.tmp - mv -f ./debian/scripts/iobroker_startup.tmp ./debian/scripts/iobroker_startup.sh - # amd64 - sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./debian/node18/Dockerfile > ./debian/node18/Dockerfile.tmp - mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2.2.0 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2.9.1 - - - name: Login to DockerHub - uses: docker/login-action@v2.2.0 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASS }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2.2.0 - with: - registry: ghcr.io - username: ${{ secrets.PACKAGES_USER }} - password: ${{ secrets.PACKAGES_PASS }} - - - name: Build Docker image - uses: docker/build-push-action@v4.1.1 - with: - context: ./debian - file: ./debian/node18/Dockerfile - push: true - platforms: | - linux/amd64 - linux/arm/v7 - linux/arm64/v8 - tags: | - buanet/iobroker:beta, - buanet/iobroker:${{ env.version }}, - ghcr.io/buanet/iobroker:beta, - ghcr.io/buanet/iobroker:${{ env.version }} - provenance: false - outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) - - - name: Delete untagged images from GitHub packages - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.PACKAGES_PASS }} - script: | - const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions", - { per_page: ${{ env.PER_PAGE }} - }); - for(version of response.data) { - if (version.metadata.container.tags.length == 0) { - console.log("delete " + version.id) - const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); - console.log("status " + deleteResponse.status) - } - } - env: - OWNER: buanet - PACKAGE_NAME: iobroker - PER_PAGE: 100 diff --git a/.github/workflows/build-debian12-beta.yml b/.github/workflows/build-debian12-beta.yml new file mode 100644 index 0000000..299c5ef --- /dev/null +++ b/.github/workflows/build-debian12-beta.yml @@ -0,0 +1,186 @@ +# Github action to build Debian12 image (Tag: beta) +name: Build Debian 12 Image (beta) + +on: + release: + types: [prereleased] + workflow_dispatch: + inputs: + chose_node_version: + type: choice + description: 'Which Node version should be used?' + options: + - 'Recommended Node version (default)' + - 'Experimental Node version' + - 'Both Node versions' + +jobs: + build-with-recommended-node: + if: inputs.chose_node_version == 'Recommended Node version (default)' || inputs.chose_node_version == 'Both Node versions' || github.event_name == 'release' + name: Build with recommended Node version + runs-on: ubuntu-latest + steps: + - name: Fetch latest prerelease tag + run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Checkout repo + uses: actions/checkout@v3.6.0 + with: + repository: 'buanet/ioBroker.docker' + ref: ${{ env.RELEASE_TAG }} + + - name: Set job variables + run: | + VERSION="$(cat .VERSION)" + MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')" + DATI="$(date --rfc-3339=seconds | sed 's/ /T/')" + # Log output and export as Github environment variable + echo "[LOG] Nodejs Version: ${{ vars.RECOMMENDED_NODE_VERSION }}" + echo "[LOG] Image Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_ENV + echo "[LOG] Major Image Version: $MAJORVERSION" + echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV + echo "[LOG] Buildnumber/Timestamp: $DATI" + echo "dati=$DATI" >> $GITHUB_ENV + # Set values in iobroker_startup.sh + sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./debian12/scripts/iobroker_startup.sh > ./debian12/scripts/iobroker_startup.tmp + mv -f ./debian12/scripts/iobroker_startup.tmp ./debian12/scripts/iobroker_startup.sh + # Set values in Dockerfile + sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" -e "s/\${NODE}/${{ vars.RECOMMENDED_NODE_VERSION }}/" ./debian12/Dockerfile > ./debian12/Dockerfile.tmp + mv -f ./debian12/Dockerfile.tmp ./debian12/Dockerfile + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2.2.0 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2.10.0 + + - name: Login to DockerHub + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.2.0 + with: + registry: ghcr.io + username: ${{ secrets.PACKAGES_USER }} + password: ${{ secrets.PACKAGES_PASS }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: ./debian12 + file: ./debian12/Dockerfile + push: true + platforms: | + linux/amd64 + linux/arm/v7 + linux/arm64/v8 + tags: | + buanet/iobroker:beta, + buanet/iobroker:${{ env.version }}, + ghcr.io/buanet/iobroker:beta, + ghcr.io/buanet/iobroker:${{ env.version }} + provenance: false + outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) + + build-with-experimental-node: + if: inputs.chose_node_version == 'Experimental Node version' || inputs.chose_node_version == 'Both Node versions' || github.event_name == 'release' + name: Build with experimental Node version + runs-on: ubuntu-latest + steps: + - name: Fetch latest prerelease tag + run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Checkout repo + uses: actions/checkout@v3.6.0 + with: + repository: 'buanet/ioBroker.docker' + ref: ${{ env.RELEASE_TAG }} + + - name: Set job variables + run: | + VERSION="$(cat .VERSION)" + MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')" + DATI="$(date --rfc-3339=seconds | sed 's/ /T/')" + # Log output and export as Github environment variable + echo "[LOG] Nodejs Version: ${{ vars.EXPERIMENTAL_NODE_VERSION }}" + echo "[LOG] Image Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_ENV + echo "[LOG] Major Image Version: $MAJORVERSION" + echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV + echo "[LOG] Buildnumber/Timestamp: $DATI" + echo "dati=$DATI" >> $GITHUB_ENV + # Set values in iobroker_startup.sh + sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./debian12/scripts/iobroker_startup.sh > ./debian12/scripts/iobroker_startup.tmp + mv -f ./debian12/scripts/iobroker_startup.tmp ./debian12/scripts/iobroker_startup.sh + # Set values in Dockerfile + sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" -e "s/\${NODE}/${{ vars.EXPERIMENTAL_NODE_VERSION }}/" ./debian12/Dockerfile > ./debian12/Dockerfile.tmp + mv -f ./debian12/Dockerfile.tmp ./debian12/Dockerfile + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2.2.0 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2.10.0 + + - name: Login to DockerHub + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.2.0 + with: + registry: ghcr.io + username: ${{ secrets.PACKAGES_USER }} + password: ${{ secrets.PACKAGES_PASS }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: ./debian12 + file: ./debian12/Dockerfile + push: true + platforms: | + linux/amd64 + linux/arm/v7 + linux/arm64/v8 + tags: | + buanet/iobroker:beta-node${{ vars.EXPERIMENTAL_NODE_VERSION }}, + buanet/iobroker:${{ env.version }}-node${{ vars.EXPERIMENTAL_NODE_VERSION }}, + ghcr.io/buanet/iobroker:beta-node${{ vars.EXPERIMENTAL_NODE_VERSION }}, + ghcr.io/buanet/iobroker:${{ env.version }}-node${{ vars.EXPERIMENTAL_NODE_VERSION }} + provenance: false + outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) + + delete-untagged-images: + if: ${{ always() }} + needs: [build-with-recommended-node, build-with-experimental-node] + name: Delete untagged images from GitHub Container Registry + runs-on: ubuntu-latest + steps: + - name: Delete images + uses: actions/github-script@v6.4.1 + with: + github-token: ${{ secrets.PACKAGES_PASS }} + script: | + const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions", + { per_page: ${{ env.PER_PAGE }} + }); + for(version of response.data) { + if (version.metadata.container.tags.length == 0) { + console.log("delete " + version.id) + const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); + console.log("status " + deleteResponse.status) + } + } + env: + OWNER: buanet + PACKAGE_NAME: iobroker + PER_PAGE: 100 diff --git a/.github/workflows/build-debian12-dev-node20.yml b/.github/workflows/build-debian12-dev-node20.yml deleted file mode 100644 index c07a814..0000000 --- a/.github/workflows/build-debian12-dev-node20.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Github action to build Debian12 image (Tag: dev-node20) -name: Build Debian 12 Image (dev-node20) - -on: - workflow_dispatch: - -jobs: - build-dev-node20-image: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v3.6.0 - with: - repository: 'buanet/ioBroker.docker' - - - name: Set job variables - run: | - NODE="20" - VERSION="$(cat .VERSION)" - MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')" - DATI="$(date --rfc-3339=seconds | sed 's/ /T/')" - # Log output and export as Github environment variable - echo "[LOG] Nodejs Version: $NODE" - echo "node=$NODE" >> $GITHUB_ENV - echo "[LOG] Image Version: $VERSION" - echo "version=$VERSION" >> $GITHUB_ENV - echo "[LOG] Major Image Version: $MAJORVERSION" - echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV - echo "[LOG] Buildnumber/Timestamp: $DATI" - echo "dati=$DATI" >> $GITHUB_ENV - # Set values in iobroker_startup.sh - sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./debian12/scripts/iobroker_startup.sh > ./debian12/scripts/iobroker_startup.tmp - mv -f ./debian12/scripts/iobroker_startup.tmp ./debian12/scripts/iobroker_startup.sh - # Set values in Dockerfile - sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" -e "s/\${NODE}/$NODE/" ./debian12/Dockerfile > ./debian12/Dockerfile.tmp - mv -f ./debian12/Dockerfile.tmp ./debian12/Dockerfile - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2.2.0 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2.10.0 - - - name: Login to DockerHub - uses: docker/login-action@v2.2.0 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASS }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2.2.0 - with: - registry: ghcr.io - username: ${{ secrets.PACKAGES_USER }} - password: ${{ secrets.PACKAGES_PASS }} - - - name: Build and push Docker image - uses: docker/build-push-action@v4.1.1 - with: - context: ./debian12 - file: ./debian12/Dockerfile - push: true - platforms: | - linux/amd64 - linux/arm/v7 - linux/arm64/v8 - tags: | - buanet/iobroker:dev-node20, - ghcr.io/buanet/iobroker:dev-node20 - provenance: false - outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) - - - name: Delete untagged images from GitHub Container Registry - uses: actions/github-script@v6.4.1 - with: - github-token: ${{ secrets.PACKAGES_PASS }} - script: | - const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions", - { per_page: ${{ env.PER_PAGE }} - }); - for(version of response.data) { - if (version.metadata.container.tags.length == 0) { - console.log("delete " + version.id) - const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); - console.log("status " + deleteResponse.status) - } - } - env: - OWNER: buanet - PACKAGE_NAME: iobroker - PER_PAGE: 100 diff --git a/.github/workflows/build-debian12-dev.yml b/.github/workflows/build-debian12-dev.yml index 82acd44..d7b1980 100644 --- a/.github/workflows/build-debian12-dev.yml +++ b/.github/workflows/build-debian12-dev.yml @@ -14,8 +14,8 @@ on: jobs: build-with-recommended-node: - if: inputs.chose_node_version == 'Recommended Node version (default)' || inputs.chose_node_version == 'Both Node versions' - name: Build image with recommended Node version + if: inputs.chose_node_version == 'Recommended Node version (default)' || inputs.chose_node_version == 'Both Node versions' + name: Build with recommended Node version runs-on: ubuntu-latest steps: - name: Checkout repo @@ -82,8 +82,8 @@ jobs: outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) build-with-experimental-node: - if: inputs.chose_node_version == 'Experimental Node version' || inputs.chose_node_version == 'Both Node versions' - name: Build image with experimental Node version + if: inputs.chose_node_version == 'Experimental Node version' || inputs.chose_node_version == 'Both Node versions' + name: Build with experimental Node version runs-on: ubuntu-latest steps: - name: Checkout repo diff --git a/CHANGELOG.md b/CHANGELOG.md index 56b9c38..767b69b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Changelog ### v9.0.0-beta.1 (coming soon) +* simplify ci/ reduce gh actions * ignore errors in "silent cleanup" on first start ([#369](https://github.com/buanet/ioBroker.docker/issues/369)) * cleanup/ restructure repo * update nodejs setup process