diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 011d56c5..d3dc9a35 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,8 +34,8 @@ jobs: # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://git.io/codeql-language-support language: [ 'go' ] - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/dockerfiles.yml b/.github/workflows/dockerfiles.yml index 70008dc3..03920a63 100644 --- a/.github/workflows/dockerfiles.yml +++ b/.github/workflows/dockerfiles.yml @@ -24,7 +24,7 @@ jobs: [ "./build/docker/go-tools/Dockerfile", ] - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-24.04" name: Lint ${{ matrix.dockerfile }} steps: - name: Checkout diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b448c135..c7156f51 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -40,8 +40,8 @@ jobs: fail-fast: false max-parallel: 3 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Build steps: @@ -97,8 +97,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Run Tests steps: @@ -144,8 +144,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Run linters steps: @@ -201,8 +201,8 @@ jobs: fail-fast: true max-parallel: 1 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Quality reports steps: diff --git a/.github/workflows/readme-stars.yml b/.github/workflows/readme-stars.yml index 90a9fd69..79a99c5a 100644 --- a/.github/workflows/readme-stars.yml +++ b/.github/workflows/readme-stars.yml @@ -11,7 +11,7 @@ on: jobs: update-readme: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 env: USER_ID: ${{ secrets.AOC_USER_ID }} BOARD_ID: ${{ secrets.AOC_BOARD_ID}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2aa22b6..f2498301 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,8 +13,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Build steps: @@ -59,8 +59,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Regression tests steps: @@ -108,8 +108,8 @@ jobs: fail-fast: false max-parallel: 1 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Lint steps: @@ -161,8 +161,8 @@ jobs: fail-fast: false max-parallel: 1 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.23] + os: [ 'ubuntu-24.04' ] + go-version: [1.24] runs-on: ${{ matrix.os }} name: Release steps: diff --git a/.goreleaser.yml b/.goreleaser.yml index d84a3b71..c751385b 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -30,11 +30,7 @@ builds: - 'windows' goarch: - 'amd64' - - 'arm' - 'arm64' - ignore: - - goos: darwin - goarch: 'arm' mod_timestamp: '{{ .CommitTimestamp }}' env: @@ -42,9 +38,7 @@ builds: main: ./cmd/aoc-cli flags: - -trimpath - ldflags: - - "{{ .Env.GO_BUILD_LDFLAGS }}" - - + universal_binaries: - # ID of the source build # @@ -68,11 +62,13 @@ archives: - id: cli builds: - cli - format: tar.gz + formats: + - tar.gz wrap_in_directory: true format_overrides: - goos: windows - format: zip + formats: + - zip name_template: "{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" files: - LICENSE @@ -111,4 +107,4 @@ changelog: order: 999 milestones: - - close: true + - close: true \ No newline at end of file diff --git a/Makefile b/Makefile index 697d2599..e400793f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := env VERSION=$(VERSION) $(SHELL) VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1)) -GOVERSION:=1.23 +GOVERSION:=1.24 APP_NAME?=aoc-cli SHELL := env APP_NAME=$(APP_NAME) $(SHELL) diff --git a/go.mod b/go.mod index 6dce7db8..5692a495 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,15 @@ module github.com/obalunenko/advent-of-code -go 1.23 +go 1.24 + +toolchain go1.24.0 require ( github.com/briandowns/spinner v1.23.2 github.com/manifoldco/promptui v0.9.0 github.com/obalunenko/getenv v1.14.0 github.com/obalunenko/logger v1.2.0 - github.com/obalunenko/version v1.2.0 + github.com/obalunenko/version v1.3.1 github.com/savioxavier/termlink v1.4.2 github.com/stretchr/testify v1.10.0 github.com/urfave/cli/v2 v2.27.5 diff --git a/go.sum b/go.sum index f0c663d8..3e9c244e 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,8 @@ github.com/obalunenko/getenv v1.14.0 h1:Q8ClxnNMr5a6N0xNg7nHbdhZI4UUfhZMCjabGruq github.com/obalunenko/getenv v1.14.0/go.mod h1:PsuPvyLaE71FF7ikdCvPGqILTAWuXq7/+dtlOhab5K4= github.com/obalunenko/logger v1.2.0 h1:MwsqJWtaxaHFQK7Cjkqk1NnlNPHH+tR1ergdnpST7Kg= github.com/obalunenko/logger v1.2.0/go.mod h1:XaU3GhUJWda3ow3hhRjlItpIVgQRKa2KDsEeprSzBvg= -github.com/obalunenko/version v1.2.0 h1:eUYme2w38fjzcvToInTGM85xAJycZHo65GvynbH8jCo= -github.com/obalunenko/version v1.2.0/go.mod h1:kXnCfV2LUe+UHRrzjwPC/5lpnPbypwmLZh7BJx7wG1A= +github.com/obalunenko/version v1.3.1 h1:NN+YSOrti8mEyJSnu+7//YSvGrOhLivh60hJXhIrNTI= +github.com/obalunenko/version v1.3.1/go.mod h1:56ydLXefFem3sEJ2iyguuZ7dwJ25VoIRTev/JfxFIa4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= diff --git a/scripts/build/app.sh b/scripts/build/app.sh index 4f62f78e..2d00d994 100755 --- a/scripts/build/app.sh +++ b/scripts/build/app.sh @@ -13,45 +13,17 @@ mkdir -p "${BIN_DIR}" echo "${SCRIPT_NAME} is running... " -checkInstalled 'goreleaser' - -goreleaser healthcheck - APP=${APP_NAME} echo "Building ${APP}..." -COMMIT="$(git rev-parse HEAD)" -SHORTCOMMIT="$(git rev-parse --short HEAD)" -DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" -VERSION="$(git tag | sort -V | tail -1)" -GOVERSION="$(go version | awk '{print $3;}')" - -if [ -z "${VERSION}" ] || [ "${VERSION}" = "${SHORTCOMMIT}" ]; then - VERSION="v0.0.0" -fi - -if [[ $(git diff --stat) != '' ]]; then - echo 'dirty' - - COMMIT="${COMMIT}-dirty" - SHORTCOMMIT="${SHORTCOMMIT}-dirty" - VERSION="${VERSION}-dirty" -fi - BIN_OUT="${BIN_DIR}/${APP}" -BUILDINFO_VARS_PKG=github.com/obalunenko/version -export GO_BUILD_LDFLAGS="-s -w \ --X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ --X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ --X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ --X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ --X ${BUILDINFO_VARS_PKG}.appname=${APP} \ --X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" + +GO_BUILD_PACKAGE="${REPO_ROOT}/cmd/${APP}" rm -rf "${BIN_OUT}" -goreleaser build --skip=validate --clean --single-target --output "${BIN_OUT}" +go build -trimpath -o "${BIN_OUT}" "${GO_BUILD_PACKAGE}" -echo "Binary compiled at ${BIN_OUT}" +echo "Build ${BIN_OUT} success" diff --git a/vendor/github.com/obalunenko/version/README.md b/vendor/github.com/obalunenko/version/README.md index 0c2d23fe..7dfdeb16 100644 --- a/vendor/github.com/obalunenko/version/README.md +++ b/vendor/github.com/obalunenko/version/README.md @@ -3,32 +3,22 @@ This package contains build information generated at build time and compiled into the binary. ```go -// Package version contains build information such as the git commit, app version, build date. +// Package version provides utilities for retrieving application build information +// such as version number, build date, commit hash, application name, and the Go +// language version used during the build process. // -// This info generated at build time and compiled into the binary. +// This package leverages the `runtime/debug` package to read build metadata +// embedded in the binary during the build process with Go modules. // -// Usage: -// At your build script add following lines: -// go install -ldflags '-X github.com/obalunenko/version.version APP_VERSION -X github.com/obalunenko/version.builddate BUILD_DATE -X github.com/obalunenko/version.commit COMMIT -X github.com/obalunenko/version.shortcommit SHORTCOMMIT -X github.com/obalunenko/version.appname APP_NAME' -// and then build your binary -// go build -// Please note that all future binaries will be compiled with the embedded information unless the version package is recompiled with new values. +// Build information can be accessed via the exposed methods: // -// Alternative is use ldflags on stage of compiling: -// GOVERSION=$(go version | awk '{print $3;}') -// APP=myapp -// BIN_OUT=bin/${APP} -// BUILDINFO_VARS_PKG=github.com/obalunenko/version -// GO_BUILD_LDFLAGS="-s -w \ -//-X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ -//-X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ -//-X ${BUILDINFO_VARS_PKG}.appname=${APP}" \ -//-X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" -// GO_BUILD_PACKAGE="" - -// rm -rf ${BIN_OUT} +// - GetGoVersion: Returns the Go version used to build the app. +// - GetVersion: Returns the application's version. +// - GetBuildDate: Returns the date the application was built. +// - GetCommit: Returns the full commit hash the application was built from. +// - GetShortCommit: Returns a shortened commit hash (7 characters). +// - GetAppName: Returns the application's module path. // -// go build -o ${BIN_OUT} -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}" +// When the application is built from sources with uncommitted changes, the +// commit information will be suffixed with "+CHANGES". ``` diff --git a/vendor/github.com/obalunenko/version/version.go b/vendor/github.com/obalunenko/version/version.go index 936ce913..c10928ce 100644 --- a/vendor/github.com/obalunenko/version/version.go +++ b/vendor/github.com/obalunenko/version/version.go @@ -1,34 +1,27 @@ -// Package version contains build information such as the git commit, app version, build date. +// Package version provides utilities for retrieving application build information +// such as version number, build date, commit hash, application name, and the Go +// language version used during the build process. // -// This info generated at build time and compiled into the binary. +// This package leverages the `runtime/debug` package to read build metadata +// embedded in the binary during the build process with Go modules. // -// Usage: -// At your build script add following lines: -// go install -ldflags '-X github.com/obalunenko/version.version APP_VERSION -X github.com/obalunenko/version.builddate BUILD_DATE -X github.com/obalunenko/version.commit COMMIT -X github.com/obalunenko/version.shortcommit SHORTCOMMIT -X github.com/obalunenko/version.appname APP_NAME' -// and then build your binary -// go build -// Please note that all future binaries will be compiled with the embedded information unless the version package is recompiled with new values. +// Build information can be accessed via the exposed methods: // -// Alternative is use ldflags on stage of compiling: -// GOVERSION=$(go version | awk '{print $3;}') -// APP=myapp -// BIN_OUT=bin/${APP} -// BUILDINFO_VARS_PKG=github.com/obalunenko/version -// GO_BUILD_LDFLAGS="-s -w \ -//-X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ -//-X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ -//-X ${BUILDINFO_VARS_PKG}.appname=${APP}" \ -//-X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" -// GO_BUILD_PACKAGE="" - -// rm -rf ${BIN_OUT} +// - GetGoVersion: Returns the Go version used to build the app. +// - GetVersion: Returns the application's version. +// - GetBuildDate: Returns the date the application was built. +// - GetCommit: Returns the full commit hash the application was built from. +// - GetShortCommit: Returns a shortened commit hash (7 characters). +// - GetAppName: Returns the application's module path. // -// go build -o ${BIN_OUT} -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}" - +// When the application is built from sources with uncommitted changes, the +// commit information will be suffixed with "+CHANGES". package version +import ( + "runtime/debug" +) + const unset = "unset" var ( // build info @@ -40,6 +33,42 @@ var ( // build info goversion = unset ) +func init() { + info, ok := debug.ReadBuildInfo() + if !ok { + return + } + + goversion = info.GoVersion + + var modified bool + + for _, setting := range info.Settings { + switch setting.Key { + case "vcs.revision": + commit = setting.Value + case "vcs.time": + builddate = setting.Value + case "vcs.modified": + modified = true + } + } + + if len(commit) < 7 { + shortcommit = commit + } else { + shortcommit = commit[:7] + } + + if modified { + commit += "+CHANGES" + shortcommit += "+CHANGES" + } + + appname = info.Path + version = info.Main.Version +} + // GetGoVersion returns the go version func GetGoVersion() string { return goversion diff --git a/vendor/modules.txt b/vendor/modules.txt index 071fbcbf..3886f11e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -32,8 +32,8 @@ github.com/obalunenko/getenv/option # github.com/obalunenko/logger v1.2.0 ## explicit; go 1.23 github.com/obalunenko/logger -# github.com/obalunenko/version v1.2.0 -## explicit; go 1.22 +# github.com/obalunenko/version v1.3.1 +## explicit; go 1.24 github.com/obalunenko/version # github.com/pmezard/go-difflib v1.0.0 ## explicit