kachick / selfup

đŸ†™Versions should know how to update themselves

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

selfup

CI - Go Status CI - Nix Status

Replace strings if the line contains the definition of how to update itself.

Installation

In Nix, you can skip installation steps

> nix run github:kachick/selfup/v0.0.2 -- --version
selfup dev (rev)

Prebuilt binaries are available for download from releases

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

Usage

Assume some GitHub actions workflow have lines like follows

- uses: dprint/check@v2.2
  with:
    dprint-version: '0.40.2' # selfup { "regex": "\\d[^']+", "script": "dprint --version | cut -d ' ' -f 2" }

Then you can call selfup as this

selfup run --prefix='# selfup ' .github/workflows/*.yml

You can check the running plans with list subcommand

> selfup list --prefix='# selfup ' .github/workflows/*.yml
.github/workflows/lint.yml:17: 0.40.2 => 0.40.2 # KEEP
.github/workflows/lint.yml:24: 1.16.12 => 1.16.12 # KEEP
.github/workflows/release.yml:37: 1.20.0 => 999 # UPDATE
.github/workflows/ci-go.yml:48: 2023.1.6 => 2023.1.6 # KEEP

JSON schema

Field Description
regex RE2, remember to escape meta characters in JSON
script Bash script to get new string

Options

--skip-by option skips to parse JSON and runs if the line includes this string

> selfup list --prefix='# selfup ' --skip-by=dprint .github/workflows/*.yml
.github/workflows/lint.yml:24: 1.16.12 => 1.16.12 # KEEP
.github/workflows/release.yml:37: 1.20.0 => 999 # UPDATE
.github/workflows/ci-go.yml:48: 2023.1.6 => 2023.1.6 # KEEP

Motivation

I'm using this tool to update tool versions in several GitHub actions.
Especially I want to synchronize them with Nix shells.

Nix and the ecosystem provide useful CIs, but the runtime footprint is not small even for small changes.
So I'm currently using both Nix CI and some tools CIs.

You can check actual example at workflow file, and the result PR.

About

đŸ†™Versions should know how to update themselves

License:MIT License


Languages

Language:Go 68.9%Language:Nix 31.1%