Skip to content

Commit

Permalink
feat: adds action to update dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Apr 1, 2024
1 parent f8119fa commit c9f2467
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/release.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.idea
.vscode
.vscode
mage_output_file.go
47 changes: 46 additions & 1 deletion magefile.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The OWASP Coraza contributors
// Copyright 2024 The OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0

//go:build mage
Expand All @@ -16,6 +16,9 @@ import (
"os"
"path/filepath"
"strings"
"text/template"

_ "embed"

"github.com/magefile/mage/sh"
)
Expand Down Expand Up @@ -242,3 +245,45 @@ func cleanupOldCRS(rulesDstDir, testsDir string) error {
func Test() error {
return sh.RunV("go", "test", "./...")
}

//go:embed version.go.tmpl
var versionTempl string

func SetDepsVersion() error {
type version struct {
CRSVersion string
CorazaVersion string
}

v := version{
CRSVersion: crsVersion,
CorazaVersion: corazaVersion,
}

if os.Getenv("CRS_VERSION") != "" {
v.CRSVersion = os.Getenv("CRS_VERSION")
}

if os.Getenv("CORAZA_VERSION") != "" {
v.CorazaVersion = os.Getenv("CORAZA_VERSION")
}

verFile, err := os.OpenFile("version.go", os.O_WRONLY, 0644)
if err != nil {
return err
}
defer verFile.Close()

tmpl, err := template.New("version").Parse(versionTempl)
if err != nil {
return err
}

return tmpl.Execute(verFile, v)
}

func DepsVersion() error {
fmt.Printf("CRS Version: %s\nCoraza Version: %s\n", crsVersion, corazaVersion)

return nil
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The OWASP Coraza contributors
// Copyright 2024 The OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0

//go:build mage
Expand Down
12 changes: 12 additions & 0 deletions version.go.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2024 The OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0

//go:build mage
// +build mage

package main

const (
crsVersion = "{{ .CRSVersion }}"
corazaVersion = "{{ .CorazaVersion }}"
)

0 comments on commit c9f2467

Please sign in to comment.