Skip to content
Snippets Groups Projects
Select Git revision
  • f077f3dd6f184be15bf09928ae8336593c8d6abc
  • master default protected
  • 1.31
  • 4.34.1
  • 4.34.0
  • 4.33.1
  • 4.33.0
  • 4.32.2
  • 4.32.1
  • 4.32.0
  • 4.31.0
  • 4.30.1
  • 4.30.0
  • 4.29.1
  • 4.29.0
  • 4.28.0
  • 4.27.0
  • 4.26.0
  • 4.25.5
  • 4.25.4
  • 4.25.3
  • 4.25.2
  • 4.25.1
23 results

deadmansswitch.js

Blame
  • update-changelog.nix 2.70 KiB
    {pkgs', ...}: let
      bashFktScript = import ./bash-fkt.nix {
        inherit pkgs';
      };
    in
      pkgs'.writeShellScriptBin "update-changelog" ''
    
        source ${pkgs'.common}/bin/common
        ${bashFktScript}
    
        echo_section "Update Changelog"
        echo_hint "This script will update the changelog."
        echo_hint "The command is executed in the current working directory and not in a nix derivation."
        cd_working_dir
    
        echo_step "Updating changelog"
    
        CHANGELOG_PATH="./CHANGELOG.md"
        latestDocumentedVersion=$(${pkgs'.gnugrep}/bin/grep '## \['  $CHANGELOG_PATH |  sed -E 's/## \[([0-9]+\.[0-9]+\.[0-9]+).*/\1/' | head -1)
        if [ -z "$latestDocumentedVersion" ]; then
             echo_fail "Could not find latest documented version in changelog"
             echo_hint "Please add a version entry in the file $CHANGELOG_PATH"
             exit 1
        fi
    
        currentVersion=$(${pkgs'.version}/bin/version print -g)
        if [ "$latestDocumentedVersion" = "$currentVersion" ]; then
          echo_ok "changelog already up to date"
        else
    
            tags=$(${pkgs'.git}/bin/git tag --sort=creatordate)
            tags_array=($tags)
            position=$(${pkgs'.coreutils}/bin/printf "%s\n" "''${tags_array[@]}" | ${pkgs'.gnugrep}/bin/grep -n "^$latestDocumentedVersion$" | ${pkgs'.coreutils}/bin/cut -d: -f1)
            if [ -z "$position" ]; then
                echo_fail "Could not find latest documented version in git tags"
                echo_hint "Please check the git tags"
                exit 1
            fi
    
            next_position=$((position + 1))
    
            if [ $next_position -le ''${#tags_array[@]} ]; then
                next_tag=''${tags_array[''$next_position - 1]}
            else
                echo_fail "Could not find next tag"
                echo_hint "Please check the git tags"
                exit 1
            fi
    
            echo_step "Generating changelog"
            tmpChangelog=$(${pkgs'.mktemp}/bin/mktemp)
            if ! ${pkgs'.git-chglog}/bin/git-chglog --config ./.config/chglog/config.yml -o $tmpChangelog $next_tag..
            then
              echo_fail "git-chglog failed"
              ${pkgs'.coreutils}/bin/rm $tmpChangelog
              exit 1
            fi
    
            newChanges=$(${pkgs'.coreutils}/bin/cat $tmpChangelog)
            ${pkgs'.coreutils}/bin/rm $tmpChangelog
    
            if [ -n "$newChanges" ]; then
              ${pkgs'.gnused}/bin/sed -i '/^# Changelog/d' $CHANGELOG_PATH
              ${pkgs'.coreutils}/bin/mv $CHANGELOG_PATH ''${CHANGELOG_PATH}.old
    
              echo -e "# Changelog\n\n" > $CHANGELOG_PATH
              echo "$newChanges" >> $CHANGELOG_PATH
    
              ${pkgs'.coreutils}/bin/cat "''${CHANGELOG_PATH}.old" >> $CHANGELOG_PATH
              ${pkgs'.coreutils}/bin/rm ''${CHANGELOG_PATH}.old