Commit 8319787c authored by Bart Kamphorst's avatar Bart Kamphorst
Browse files

feat: configurable initial semantic release

parent 9546f089
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ find-next-release:
    NPM_PACKAGES: semantic-release @semantic-release/exec
  script:
    - !reference [".release:install", script]
    - !reference [".release:patch-initial-version", script]
    - wget -O .releaserc
      https://gitlab.com/just-ci/templates/-/raw/v6.24.10/project-automation/release/find-next-release.json
    - semantic-release --dry-run --no-ci
+16 −0
Original line number Diff line number Diff line
---
variables:
  INITIAL_SEMANTIC_RELEASE: "" # initial semantic release version, e.g. "0.1.0"

.fix:GL_TOKEN:
  stage: .pre
  image: docker.io/alpine:3
@@ -36,3 +39,16 @@
          npm install -g "${PACKAGE}"
        fi
      done

.release:patch-initial-version:
  script:
    - |
      if [ ! -z "$INITIAL_SEMANTIC_RELEASE" ]; then
        FIRST_RELEASE_SEARCH_STR="const FIRST_RELEASE"
        NEW_FIRST_RELEASE_STR="$FIRST_RELEASE_SEARCH_STR = \"$INITIAL_SEMANTIC_RELEASE\";"
        SEMANTIC_RELEASE_LIB_DIR="$(npm list -g | head -1)/node_modules/semantic-release/lib/"
        CONSTANTS_PATH=$(grep -rwl $SEMANTIC_RELEASE_LIB_DIR -e "$FIRST_RELEASE_SEARCH_STR")
        sed -i "s/$FIRST_RELEASE_SEARCH_STR.*$/$NEW_FIRST_RELEASE_STR/" $CONSTANTS_PATH
        grep -q "$NEW_FIRST_RELEASE_STR" $CONSTANTS_PATH || echo "[!] Failed to reconfigure the initial release version of semantic-release." 1>&2
        echo "[*] Configured semantic-release to release version \"$INITIAL_SEMANTIC_RELEASE\" if no prior release exists."
      fi
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ semantic-release:
      @semantic-release/changelog @semantic-release/exec
  script:
    - !reference [".release:install", script]
    - !reference [".release:patch-initial-version", script]

    - |
      if ! test -f .releaserc; then