updater

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 9 Imported by: 0

README

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, be careful to escape for JSON stringify
script Bash script
Options

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

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

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Update

func Update(path string, prefix string, isListMode bool, skipBy string) (string, bool, error)

Returns new body and true if it is changed

Types

type Definition

type Definition struct {
	Regex  string
	Script string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL