5 Commits

Author SHA1 Message Date
Antoine Aflalo
419edbce7b fix: ci config for goreleaser 2025-08-26 22:50:14 -04:00
Antoine Aflalo
4524e94b17 ci: fix goreleaser 2025-08-26 22:47:36 -04:00
Antoine Aflalo
c6823168af fix: add attestations 2025-08-26 22:45:35 -04:00
Antoine Aflalo
9bca0ceaf4 fix: add autocomplete defintion for log level 2025-08-26 22:39:23 -04:00
Antoine Aflalo
c2a6220fde fix(logging): fix logging parameter not taken into account 2025-08-26 22:36:23 -04:00
7 changed files with 56 additions and 31 deletions

View File

@@ -8,12 +8,13 @@ name: release
on:
push:
tags:
- 'v*'
- "v*"
permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access
attestations: write # needed for attestations
jobs:
release:
@@ -26,18 +27,26 @@ jobs:
with:
go-version: 1.25
cache: true
- uses: sigstore/cosign-installer@v3.9.2 # installs cosign
- uses: sigstore/cosign-installer@v3.9.2 # installs cosign
- uses: anchore/sbom-action/download-syft@v0.20.5 # installs syft
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- uses: docker/login-action@v3 # login to ghcr
- uses: docker/login-action@v3 # login to ghcr
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: goreleaser/goreleaser-action@v6 # run goreleaser
- uses: goreleaser/goreleaser-action@v6 # run goreleaser
with:
version: latest
version: nightly
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# After GoReleaser runs, attest all the files in ./dist/checksums.txt:
- uses: actions/attest-build-provenance@v2
with:
subject-checksums: ./dist/checksums.txt
# After GoReleaser runs, attest all the images in ./dist/digests.txt:
- uses: actions/attest-build-provenance@v2
with:
subject-checksums: ./dist/digests.txt

3
.gitignore vendored
View File

@@ -102,4 +102,5 @@ fabric.properties
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea/caches/build_file_checksums.ser
*__debug_bin*

View File

@@ -48,6 +48,9 @@ builds:
# https://goreleaser.com/customization/checksum
checksum:
name_template: "checksums.txt"
# Change the digests filename:
docker_digest:
name_template: "digests.txt"
# create a source tarball
# https://goreleaser.com/customization/source/
source:

31
.vscode/launch.json vendored
View File

@@ -1,16 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Optimize Testdata",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/cbzoptimizer",
"args": ["optimize", "${workspaceFolder}/testdata", "-l", "debug"],
"cwd": "${workspaceFolder}"
}
]
}

View File

@@ -54,14 +54,30 @@ func init() {
viper.AutomaticEnv()
// Add log level flag (accepts zerolog levels: panic, fatal, error, warn, info, debug, trace)
ef := enumflag.New(&logLevel, "log", LogLevelIds, enumflag.EnumCaseInsensitive)
rootCmd.PersistentFlags().VarP(
enumflag.New(&logLevel, "log", LogLevelIds, enumflag.EnumCaseInsensitive),
ef,
"log", "l",
"Set log level; can be 'panic', 'fatal', 'error', 'warn', 'info', 'debug', or 'trace'")
ef.RegisterCompletion(rootCmd, "log", enumflag.Help[zerolog.Level]{
zerolog.PanicLevel: "Only log panic messages",
zerolog.FatalLevel: "Log fatal and panic messages",
zerolog.ErrorLevel: "Log error, fatal, and panic messages",
zerolog.WarnLevel: "Log warn, error, fatal, and panic messages",
zerolog.InfoLevel: "Log info, warn, error, fatal, and panic messages",
zerolog.DebugLevel: "Log debug, info, warn, error, fatal, and panic messages",
zerolog.TraceLevel: "Log all messages including trace",
})
// Add log level environment variable support
viper.SetEnvPrefix("")
viper.BindEnv("LOG_LEVEL")
viper.BindEnv("log", "LOG_LEVEL")
viper.BindPFlag("log", rootCmd.PersistentFlags().Lookup("log"))
rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
ConfigureLogging()
}
// Ensure the configuration directory exists
err := os.MkdirAll(configFolder, os.ModePerm)
if err != nil {
@@ -95,7 +111,7 @@ func ConfigureLogging() {
level := zerolog.InfoLevel
// Check LOG_LEVEL environment variable first
envLogLevel := viper.GetString("LOG_LEVEL")
envLogLevel := viper.GetString("log")
if envLogLevel != "" {
if parsedLevel, err := zerolog.ParseLevel(envLogLevel); err == nil {
level = parsedLevel

View File

@@ -13,8 +13,5 @@ var (
func main() {
commands.SetVersionInfo(version, commit, date)
// Configure logging before executing commands
commands.ConfigureLogging()
commands.Execute()
}

2
go.mod
View File

@@ -2,8 +2,6 @@ module github.com/belphemur/CBZOptimizer/v2
go 1.25
toolchain go1.25.0
require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/belphemur/go-webpbin/v2 v2.0.0