1- name : Test, Release
1+ name : Test, Build and Release
22
33on :
44 push :
1717 steps :
1818 - name : Checkout code
1919 uses : actions/checkout@v3
20+ with :
21+ fetch-depth : 0
2022
2123 - name : Set up Go
2224 uses : actions/setup-go@v4
2628 - name : Ensure go mod tidy has zero output
2729 run : go mod tidy -v && git diff --exit-code
2830
29- - name : Esure gofumpt has zero output
31+ - name : Ensure gofumpt has zero output
3032 run : |
3133 go install mvdan.cc/gofumpt@latest
3234 gofumpt -l -w .
3941 skip-pkg-cache : true
4042 args : --issues-exit-code=0
4143
44+ - name : Build with version info
45+ run : |
46+ TAG=$(git describe --tags --always)
47+ COMMIT=$(git rev-parse --short HEAD)
48+ DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
49+
50+ go build -ldflags="\
51+ -X github.com/apiqube/cli/cmd/qube.version=$TAG \
52+ -X github.com/apiqube/cli/cmd/qube.commit=$COMMIT \
53+ -X github.com/apiqube/cli/cmd/qube.date=$DATE" \
54+ -o qube ./cmd/qube
55+
56+ ./qube version # Проверка версии
57+ mkdir -p bin
58+ mv qube bin/
59+
60+ - name : Upload artifact
61+ uses : actions/upload-artifact@v3
62+ with :
63+ name : qube-binaries
64+ path : bin/qube
65+
4266 release :
4367 needs : build-and-test
4468 runs-on : ubuntu-latest
5175 steps :
5276 - name : Checkout code
5377 uses : actions/checkout@v3
78+ with :
79+ fetch-depth : 0
5480
5581 - name : Set up Go
5682 uses : actions/setup-go@v4
@@ -74,17 +100,19 @@ jobs:
74100 echo "tag=$TAG"
75101 echo "tag=$TAG" >> $GITHUB_OUTPUT
76102
77- - name : Create GitHub Release (if not exists)
78- env :
79- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80- VERSION : ${{ steps.get_tag.outputs.tag }}
103+ - name : Build release binaries
81104 run : |
82- if gh release view "$VERSION" >/dev/null 2>&1; then
83- echo "Release $VERSION already exists, skipping creation."
84- else
85- gh release create "$VERSION" --generate-notes
86- fi
87-
105+ TAG=$(git describe --tags --always)
106+ COMMIT=$(git rev-parse --short HEAD)
107+ DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
108+
109+ go build -ldflags="\
110+ -X github.com/apiqube/cli/cmd/qube.version=$TAG \
111+ -X github.com/apiqube/cli/cmd/qube.commit=$COMMIT \
112+ -X github.com/apiqube/cli/cmd/qube.date=$DATE" \
113+ -o qube ./cmd/qube
114+
115+ ./qube version
88116
89117 - name : Create GitHub Release (if not exists)
90118 env :
96124 gh release create "$VERSION" --generate-notes
97125 else
98126 echo "No new tag created, skipping release step."
99- fi
100-
101-
127+ fi
0 commit comments