Skip to content

Commit 496b532

Browse files
committed
goreleaser
1 parent 6fe69a4 commit 496b532

File tree

5 files changed

+71
-60
lines changed

5 files changed

+71
-60
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,35 @@ name: release
22

33
on:
44
push:
5-
branches:
6-
- '!*'
75
tags:
8-
- v*.*.*
6+
- 'v*'
97

108
permissions:
119
contents: write
12-
id-token: write
13-
attestations: write
1410

1511
jobs:
1612
goreleaser:
1713
runs-on: ubuntu-latest
1814
steps:
19-
- name: Checkout
20-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21-
- name: Set up Go
22-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
23-
with:
24-
go-version-file: 'go.mod'
25-
- name: Import GPG key
26-
id: import_gpg
27-
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
28-
with:
29-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
30-
passphrase: ${{ secrets.PASSPHRASE }}
31-
- name: Run GoReleaser
32-
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
33-
with:
34-
version: latest
35-
args: release
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
39-
- uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
40-
with:
41-
subject-path: 'dist/checksums.txt'
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
# we need full clone for goreleaser to generate proper changelog
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v6
23+
with:
24+
go-version-file: go.mod
25+
26+
- name: Install GoReleaser
27+
uses: goreleaser/goreleaser-action@v6
28+
with:
29+
version: "~> v2"
30+
install-only: true
31+
32+
- name: Make release
33+
run: |
34+
make release
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# don't track built binary
2-
/no-multiline-comments
1+
# don't track built binaries
2+
/tflint-ruleset-misc
3+
/dist/
4+
5+
TODO.md

.goreleaser.yml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
1-
# This is an example goreleaser.yaml file with some sane defaults.
2-
# Make sure to check the documentation at http://goreleaser.com
31
version: 2
4-
env:
5-
- CGO_ENABLED=0
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
67
builds:
7-
- targets:
8-
- darwin_amd64
9-
- darwin_arm64
10-
- linux_386
11-
- linux_amd64
12-
- linux_arm
13-
- linux_arm64
14-
- windows_386
15-
- windows_amd64
16-
hooks:
17-
post:
18-
- mkdir -p ./dist/raw
19-
- cp "{{ .Path }}" "./dist/raw/{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
8+
- goarch:
9+
- amd64
10+
- arm64
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
ldflags:
16+
- -s -w -X main.version=v{{ .Version }}
17+
2018
archives:
21-
- id: zip
19+
- formats: [zip]
2220
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
23-
formats:
24-
- zip
25-
files:
26-
- none*
21+
2722
checksum:
28-
name_template: 'checksums.txt'
29-
extra_files:
30-
- glob: ./dist/raw/*
31-
signs:
32-
- artifacts: checksum
33-
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
23+
name_template: "checksums.txt"

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
default: build
22

3+
.PHONY: test
34
test:
45
go test ./...
56

7+
.PHONY: build
68
build:
79
go build
810

11+
.PHONY: install
912
install: build
1013
mkdir -p ~/.tflint.d/plugins
1114
mv ./tflint-ruleset-misc ~/.tflint.d/plugins
15+
16+
.PHONY: release
17+
release:
18+
@goreleaser release --clean
19+
20+
.PHONY: snapshot
21+
snapshot:
22+
@goreleaser release --clean --snapshot
23+
24+
.PHONY: pre-commit
25+
pre-commit:
26+
@pre-commit run --all-files
27+
28+
.PHONY: clean ## Clean build artifacts
29+
clean:
30+
rm -f tflint-ruleset-misc
31+
rm -rf dist

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package main
22

33
import (
4-
"github.com/AleksaC/tflint-ruleset-misc/rules"
54
"github.com/terraform-linters/tflint-plugin-sdk/plugin"
65
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
6+
7+
"github.com/AleksaC/tflint-ruleset-misc/rules"
78
)
89

10+
var version = "dev" // This will be set by the linker during build
11+
912
func main() {
1013
plugin.Serve(&plugin.ServeOpts{
1114
RuleSet: &tflint.BuiltinRuleSet{
1215
Name: "misc",
13-
Version: "0.1.0",
16+
Version: version,
1417
Rules: []tflint.Rule{
1518
rules.NewNoMultilineCommentsRule(),
1619
},

0 commit comments

Comments
 (0)