Skip to content

kachick/selfup

Repository files navigation

selfup

CI - Go Status CI - Nix Status Release

Replace strings in files using update rules defined in comments.

Installation

Nix

In Nix Flake, you can skip installation steps

> nix run github:kachick/selfup/v1.3.1 -- --version
selfup v1.3.1

You can also use the binary cache defined in the flake.
This is available for recent tagged versions, but only if the user is a trusted-user in your nix.conf file.

> grep trusted-users /etc/nix/nix.conf
trusted-users = root your_user

> nix run --accept-flake-config github:kachick/selfup/v1.3.1 -- --version
selfup v1.3.1

Prebuilt-binary

Prebuilt binaries are available for download from releases

> install_path="$(mktemp -d)"
> curl -L https://github.com/kachick/selfup/releases/download/v1.3.1/selfup_Linux_x86_64.tar.gz | tar xvz -C "$install_path" selfup
> "${install_path}/selfup" --version
selfup VERSION

You can also use gh command.

gh release download 'v1.3.1' --pattern 'selfup_Linux_x86_64.tar.gz' --repo kachick/selfup
tar -xvzf 'selfup_Linux_x86_64.tar.gz'

Usage

selfup [SUB] [OPTIONS] [PATH]...

Assume a GitHub Actions workflow has lines like this:

- uses: dprint/check@v2.2
  with:
    dprint-version: '0.40.2' # selfup { "extract": "\\b[0-9.]+", "replacer": ["dprint", "--version"], "nth": 2 }

You can run selfup like this:

selfup run .github/workflows/*.yml

You can check the plans with the list subcommand:

> selfup list .github/workflows/*.yml
  .github/workflows/lint.yml:17: 0.40.2
✓ .github/workflows/release.yml:37: 1.20.0 => 1.42.9
  .github/workflows/release.yml:50: 3.3.1

1/3 items will be replaced

JSON schema

Field Type Description
extract string Golang regex like RE2. Remember to escape meta-characters in JSON.
replacer []string Command and arguments. Use ["bash", "-c", "your_script | as_using_pipe"] for script style.
nth number Field number. The first field is 1. By default, it uses the whole line (0).
delimiter string Separator to split STDOUT into fields. It uses strings.Fields by default.

Options

  • --prefix: Set a custom prefix pattern (RE2) before the JSON.
  • --skip-by: Skip lines that contain this string.
  • --check: Exit with a non-zero code if changes or plans are found.
  • --no-color: Disable colored output.
  • --version: Print the version.

Examples

FAQ

  • selfup run .github does not work. Is there a walker option?

    • It only takes target paths. One way to use it is: git ls-files -z .github | xargs --null selfup run --
  • What are the advantages over other version updaters?

Motivation

I use this tool to update tool versions in several GitHub Actions. I especially want to synchronize them with Nix shells.

Nix and its ecosystem provide useful CI, but the runtime footprint is not small even for small changes.
So I currently use both Nix CI and some tool-specific CIs.

Notice

This tool modifies your codebase based on external command results.
Please use it only with commands and tools you trust.

About

đŸ†™Versions should know how to update themselves

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors