From bd3fd9a5e8e2afbfff8b075546b3408d2688e594 Mon Sep 17 00:00:00 2001 From: Case Wylie Date: Wed, 29 Jan 2025 08:31:36 -0500 Subject: [PATCH] chore: nightlies in sh Signed-off-by: Case Wylie --- .github/workflows/nightlies.yml | 34 +---------------------------- scripts/nightlies.sh | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 33 deletions(-) create mode 100755 scripts/nightlies.sh diff --git a/.github/workflows/nightlies.yml b/.github/workflows/nightlies.yml index a0da2378d..72a616d47 100644 --- a/.github/workflows/nightlies.yml +++ b/.github/workflows/nightlies.yml @@ -44,36 +44,4 @@ jobs: - name: Publish to GHCR and NPM env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - #!/bin/bash - - npm install -g npm - - LATEST_VERSION=$(npx pepr@latest version 2>/dev/null) - RAW_NIGHTLY_VERSION=$(npx pepr@nightly version 2>/dev/null || echo "none") - - if [[ "$RAW_NIGHTLY_VERSION" == "none" ]]; then - echo "No nightly version found. Setting NIGHTLY_VERSION=0." - NIGHTLY_VERSION=0 - else - NIGHTLY_VERSION_PART=$(echo "$RAW_NIGHTLY_VERSION" | grep -oE "nightly\.([0-9]+)" | cut -d. -f2) - - BASE_NIGHTLY_VERSION=${RAW_NIGHTLY_VERSION%-nightly*} - if [[ "$LATEST_VERSION" > "$BASE_NIGHTLY_VERSION" ]]; then - echo "Nightly version is less than the latest version. Resetting NIGHTLY_VERSION to 0." - NIGHTLY_VERSION=0 - else - NIGHTLY_VERSION=$((NIGHTLY_VERSION_PART + 1)) - echo "Incrementing NIGHTLY_VERSION to $NIGHTLY_VERSION." - fi - fi - - FULL_VERSION="${LATEST_VERSION}-nightly.${NIGHTLY_VERSION}" - - echo "FULL_VERSION=$FULL_VERSION" >> $GITHUB_ENV - - npm version --no-git-tag-version $FULL_VERSION - - docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/defenseunicorns/pepr/controller:$FULL_VERSION . - - npm publish --tag "nightly" + run: ./scripts/nightlies.sh diff --git a/scripts/nightlies.sh b/scripts/nightlies.sh new file mode 100755 index 000000000..4d44ea26b --- /dev/null +++ b/scripts/nightlies.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2023-Present The Pepr Authors + +# Script to build and publish nightly versions of Pepr Controller and Pepr CLI. + +set -e +npm install -g npm + +LATEST_VERSION=$(npx --yes pepr@latest --version 2>/dev/null) +RAW_NIGHTLY_VERSION=$(npx --yes pepr@nightly --version 2>/dev/null || echo "none") + +if [[ "$RAW_NIGHTLY_VERSION" == "none" ]]; then + echo "No nightly version found. Setting NIGHTLY_VERSION=0." + NIGHTLY_VERSION=0 +else + NIGHTLY_VERSION_PART=$(echo "$RAW_NIGHTLY_VERSION" | grep -oE "nightly\.([0-9]+)" | cut -d. -f2) + + BASE_NIGHTLY_VERSION=${RAW_NIGHTLY_VERSION%-nightly*} + if [[ "$LATEST_VERSION" > "$BASE_NIGHTLY_VERSION" ]]; then + echo "Nightly version is less than the latest version. Resetting NIGHTLY_VERSION to 0." + NIGHTLY_VERSION=0 + else + NIGHTLY_VERSION=$((NIGHTLY_VERSION_PART + 1)) + echo "Incrementing NIGHTLY_VERSION to $NIGHTLY_VERSION." + fi +fi + +FULL_VERSION="${LATEST_VERSION}-nightly.${NIGHTLY_VERSION}" + +echo "FULL_VERSION=$FULL_VERSION" >> "$GITHUB_ENV" + +npm version --no-git-tag-version "$FULL_VERSION" + +docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/defenseunicorns/pepr/controller:"$FULL_VERSION" . + +npm publish --tag "nightly"