Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 52 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
name: Release

on:
push:
tags:
- "v*"
pull_request:
branches:
- main
pull_request:
push:
branches:
- main

permissions:
contents: write

jobs:
goreleaser:
# Test and build snapshot for PRs
test-build:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -26,21 +26,62 @@ jobs:
with:
go-version: "1.25"

- name: Set version
- name: Run tests
run: go test -v ./...

- name: Set version from VERSION file
id: version
run: |
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
VERSION=$(cat VERSION)
echo "version=v${VERSION}" >> $GITHUB_OUTPUT

- uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: v1.26.2
args: build --snapshot --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.version }}

# Create tag and release when PR is merged to main
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v4
with:
go-version: "1.25"

- name: Read version and create tag
id: version
run: |
VERSION=$(cat VERSION)
TAG="v${VERSION}"
echo "version=${TAG}" >> $GITHUB_OUTPUT

# Check if tag already exists
if git rev-parse "${TAG}" >/dev/null 2>&1; then
echo "Tag ${TAG} already exists, skipping release"
echo "skip=true" >> $GITHUB_OUTPUT
else
VERSION=$(cat VERSION)
echo "version=v${VERSION}" >> $GITHUB_OUTPUT
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${TAG}" -m "Release ${TAG}"
git push origin "${TAG}"
echo "skip=false" >> $GITHUB_OUTPUT
fi

- uses: goreleaser/goreleaser-action@v5
if: steps.version.outputs.skip != 'true'
with:
distribution: goreleaser
version: v1.26.2
args: ${{ startsWith(github.ref, 'refs/tags/') && 'release' || 'build --snapshot' }} --clean
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.version }}
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ These Go-template tags are indented:
- Control blocks: `range`, `with`, `define`, `block`
- Branching: `if`, `else`, `else if`, `end`
- Vars: `{{ $var := ... }}`
- Some functions: `include`, `fail`, `printf` etc.
- Some functions: `fail`, `printf` etc.
- Comments: `{{/* ... */}}`

These are not indented by default but can be [configured](https://github.com/digitalstudium/helmfmt?tab=readme-ov-file#configuration):

- `tpl`, `template` and `toYaml` because they can break YAML indentation
- `tpl`, `template`, `include` and `toYaml` because they can break YAML indentation

---

Expand Down Expand Up @@ -108,8 +108,7 @@ Download it from [releases](https://github.com/digitalstudium/helmfmt/releases)
helmfmt <chart-path>
helmfmt --files <file1> <file2> ...
helmfmt --files <file1> <file2> ... --stdout
helmfmt --disable-indent=template,include <chart-path>
helmfmt --enable-indent=toYaml --files <file1> <file2> ...
helmfmt --enable-indent=toYaml,include --files <file1> <file2> ...
```

Example run:
Expand Down Expand Up @@ -154,14 +153,14 @@ Processed: 2, Updated: 1, Errors: 0
"exclude": []
},
"template": {
"disabled": false,
"exclude": []
},
"printf": {
"disabled": false,
"disabled": true,
"exclude": []
},
"include": {
"disabled": true,
"exclude": []
},
"printf": {
"disabled": false,
"exclude": []
},
Expand Down Expand Up @@ -207,6 +206,7 @@ Each rule can be configured with:
"rules": {
"indent": {
"include": {
"disabled": false,
"exclude": ["tests/*", "**/test-*.yaml"]
}
}
Expand All @@ -227,9 +227,6 @@ Each rule can be configured with:
You can override configuration rules using command-line flags:

```bash
# Disable specific rules
helmfmt --disable-indent=template,include <chart-path>

# Enable specific rules (overrides config file)
helmfmt --enable-indent=tpl,toYaml <chart-path>
```
Expand All @@ -243,7 +240,7 @@ To use `helmfmt` as a pre-commit hook, add the following to your `.pre-commit-co
```yaml
repos:
- repo: https://github.com/digitalstudium/helmfmt
rev: v0.3.0
rev: v0.4.0
hooks:
- id: helmfmt
```
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.4.0
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func loadConfig() *Config {
Indent: map[string]RuleConfig{
"tpl": {Disabled: true, Exclude: []string{}},
"toYaml": {Disabled: true, Exclude: []string{}},
"template": {Disabled: false, Exclude: []string{}},
"template": {Disabled: true, Exclude: []string{}},
"include": {Disabled: true, Exclude: []string{}},
"printf": {Disabled: false, Exclude: []string{}},
"include": {Disabled: false, Exclude: []string{}},
"fail": {Disabled: false, Exclude: []string{}},
},
},
Expand Down