mirror of
https://github.com/acaloiaro/ess
synced 2026-07-21 18:29:08 +00:00
Merge pull request #17 from acaloiaro/git-add-optional
Add skip-git-add flag
This commit is contained in:
commit
c1275418f4
3 changed files with 21 additions and 13 deletions
20
.github/workflows/goreleaser.yml
vendored
20
.github/workflows/goreleaser.yml
vendored
|
|
@ -27,18 +27,18 @@ jobs:
|
|||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "Github Actions"
|
||||
go install git.sr.ht/~jcmuller/semver-bumper@latest
|
||||
newTag=$(git tag --list 'v*' | semver-bumper --increment minor)
|
||||
buildDate=$(date --iso-8601=seconds)
|
||||
sed -i -e "s@BUILD_DATE = \".\+\"@BUILD_DATE = \"${buildDate/v}\"@" main.go
|
||||
sed -i -e "s@VERSION = \".\+\"@VERSION = \"${newTag/v}\"@" main.go
|
||||
sed -i -e "s@version = \".\+\"@version = \"${newTag/v}\"@" default.nix
|
||||
go install github.com/caarlos0/svu@latest
|
||||
OLD_TAG=$(svu current --strip-prefix)
|
||||
NEW_TAG=$(svu next --strip-prefix)
|
||||
[ "$OLD_TAG" == "$NEW_TAG" ] && echo "no version bump" && exit 0
|
||||
sed -i "s/$OLD_TAG/$NEW_TAG/g" default.nix
|
||||
sed -i "s/$OLD_TAG/$NEW_TAG/g" main.go
|
||||
git add default.nix
|
||||
git add main.go
|
||||
git commit -m "Bump release version"
|
||||
git tag $newTag
|
||||
git add main.go
|
||||
git commit -m "bump release version" --allow-empty
|
||||
git tag v$NEW_TAG
|
||||
git push
|
||||
git push --tags
|
||||
git push --tags
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v4
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[](https://app.gitter.im/#/room/#env-sample-sync-dev:gitter.im)
|
||||
|
||||
Automatically keep `.env` files in sync with `env.sample`
|
||||
Automatically keep `env.sample` files in sync with `.env`
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -202,8 +202,10 @@ It's even possible to provide default/example values for every environment varia
|
|||
| Name | Description | Example | Default |
|
||||
| --------------- | --------------------------------------------------- | --------------------------------------------------------- | ----------------------------- |
|
||||
| `--env-file` | The name of the environment file | `--env-file=.secrets` | `--env-file=.env` |
|
||||
| `--debug` | Enable debugging | `--debug` | `false` |
|
||||
| `--skip-git-add` | Skip performing `git add` after syncing | `--skip-git-add` | `false` |
|
||||
| `--sample-file` | The name of the sample environment file | `--sample-file=secrets.example` | `--sample-file=env.sample` |
|
||||
| `--example` | Provide examples for specific environment variables | `--example=FOO="Example FOO" --example=BAR="Example BAR"` | `--example=VAR=<VAR>` |
|
||||
| `--example` | Provide examples for specific environment variables | `--example=FOO="Example FOO" --example=BAR="Example BAR"` | `--example=VAR=<VAR>` |
|
||||
|
||||
## Pre-commit Configuration Examples
|
||||
|
||||
|
|
|
|||
8
main.go
8
main.go
|
|
@ -47,8 +47,8 @@ func (e exampleFlag) Set(value string) (err error) {
|
|||
var (
|
||||
examplesFlag = make(exampleFlag)
|
||||
debugFlag bool
|
||||
skipGitAddFlag bool
|
||||
envFileFlag string
|
||||
logLevel = slog.LevelInfo
|
||||
sampleFileFlag string
|
||||
versionFlag bool
|
||||
)
|
||||
|
|
@ -57,6 +57,7 @@ func init() {
|
|||
flag.StringVar(&envFileFlag, "env-file", ".env", "set the path to your env file: ess -env-file=.env_file [sync|install]")
|
||||
flag.StringVar(&sampleFileFlag, "sample-file", "env.sample", "set the path to your sample file: ess -sample-file=env_var.sample [sync|install]")
|
||||
flag.BoolVar(&debugFlag, "debug", false, "print debug logs: ess --debug [sync|install]")
|
||||
flag.BoolVar(&skipGitAddFlag, "skip-git-add", false, "skip doing 'git add' on generated sample file after sync")
|
||||
flag.Var(examplesFlag, "example", "set example values for samples: ess --example=BAR=\"my bar value\" [sync|install]")
|
||||
flag.BoolVar(&versionFlag, "version", false, "print the current ess version: ess --version")
|
||||
|
||||
|
|
@ -92,6 +93,11 @@ func main() {
|
|||
switch command {
|
||||
case "sync":
|
||||
sync(projectPath)
|
||||
|
||||
if skipGitAddFlag {
|
||||
return
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "add", filepath.Join(projectPath, sampleFileFlag))
|
||||
slog.Debug("running git command", "args", cmd.Args)
|
||||
err := cmd.Run()
|
||||
|
|
|
|||
Loading…
Reference in a new issue