diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10a0f0c0..7da45e03 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,11 @@ jobs: - name: Resolve version metadata id: version run: | - VERSION="$(git describe --tags)" + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + VERSION="${GITHUB_REF_NAME}" + else + VERSION="$(git describe --tags)" + fi echo "version=$VERSION" >> "$GITHUB_OUTPUT" if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then echo "is_prerelease=false" >> "$GITHUB_OUTPUT" @@ -164,10 +168,11 @@ jobs: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} ASSET_NAME: ${{ matrix.asset_name }} + VERSION: ${{ needs.prepare.outputs.version }} run: | go mod download mkdir -p ../dist - go build -trimpath -ldflags "-s -w" -o "../dist/$ASSET_NAME" ./cmd/agent + go build -trimpath -ldflags "-s -w -X 'atsflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent - name: Upload Agent Artifact uses: actions/upload-artifact@v4 diff --git a/atsf_agent/internal/config/version.go b/atsf_agent/internal/config/version.go index 720c68f1..83d1bbbf 100644 --- a/atsf_agent/internal/config/version.go +++ b/atsf_agent/internal/config/version.go @@ -1,3 +1,3 @@ package config -const AgentVersion = "0.3.0" +var AgentVersion = "0.3.0" diff --git a/atsf_server/common/constants.go b/atsf_server/common/constants.go index e10e3c16..9329d58a 100644 --- a/atsf_server/common/constants.go +++ b/atsf_server/common/constants.go @@ -8,7 +8,7 @@ import ( ) var StartTime = time.Now().Unix() // unit: second -var Version = "v0.2.0" // this hard coding will be replaced automatically when building, no need to manually change +var Version = "dev" // release builds inject the tag version via ldflags var SystemName = "ATSFlare" var ServerAddress = "http://localhost:3000" var Footer = ""