Skip to content

Commit f9a7b7f

Browse files
committed
Chore: better cross building infra
1 parent 1959ea9 commit f9a7b7f

File tree

3 files changed

+33
-37
lines changed

3 files changed

+33
-37
lines changed

.github/workflows/go-build-check.yaml

+15-23
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ jobs:
3434
- name: Checkout Code
3535
uses: actions/checkout@v3
3636

37-
- name: Run Go Generate
38-
run: make generate
39-
4037
- name: Check boilerplate
4138
run: make checklicense
4239

@@ -45,9 +42,18 @@ jobs:
4542
with:
4643
version: ${{ env.GOLANGCI_VERSION }}
4744

45+
- name: Run Go Generate
46+
run: make generate
47+
4848
- name: Show Make Variables
4949
run: ./make-kt variables
5050

51+
- name: Get Version
52+
id: get_version
53+
run: |
54+
export VERSION=$(./make-kt version)
55+
echo ::set-output name=VERSION::${VERSION}
56+
5157
- name: Build Binaries for All Platforms
5258
env:
5359
DIRTY_BUILD: true
@@ -56,34 +62,20 @@ jobs:
5662
- name: Upload Artifacts (linux-amd64)
5763
uses: actions/upload-artifact@v3
5864
with:
59-
name: kube-trigger-${{ github.sha }}-linux-amd64
65+
name: kube-trigger-${{ steps.get_version.outputs.VERSION }}-linux-amd64
6066
retention-days: 7
61-
path: bin/kube-trigger-*-linux-amd64
62-
63-
- name: Upload Artifacts (linux-arm64)
64-
uses: actions/upload-artifact@v3
65-
with:
66-
name: kube-trigger-${{ github.sha }}-linux-arm64
67-
retention-days: 7
68-
path: bin/kube-trigger-*-linux-arm64
67+
path: bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/kube-trigger-*-linux-amd64
6968

7069
- name: Upload Artifacts (darwin-amd64)
7170
uses: actions/upload-artifact@v3
7271
with:
73-
name: kube-trigger-${{ github.sha }}-darwin-amd64
72+
name: kube-trigger-${{ steps.get_version.outputs.VERSION }}-darwin-amd64
7473
retention-days: 7
75-
path: bin/kube-trigger-*-darwin-amd64
74+
path: bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/kube-trigger-*-darwin-amd64
7675

7776
- name: Upload Artifacts (darwin-arm64)
7877
uses: actions/upload-artifact@v3
7978
with:
80-
name: kube-trigger-${{ github.sha }}-darwin-arm64
81-
retention-days: 7
82-
path: bin/kube-trigger-*-darwin-arm64
83-
84-
- name: Upload Artifacts (windows-amd64)
85-
uses: actions/upload-artifact@v3
86-
with:
87-
name: kube-trigger-${{ github.sha }}-windows-amd64
79+
name: kube-trigger-${{ steps.get_version.outputs.VERSION }}-darwin-arm64
8880
retention-days: 7
89-
path: bin/kube-trigger-*-windows-amd64.exe
81+
path: bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/kube-trigger-*-darwin-arm64

.github/workflows/release-binary.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ jobs:
3535
fail_on_unmatched_files: true
3636
prerelease: ${{ contains(steps.get_version.outputs.VERSION, 'alpha') || contains(steps.get_version.outputs.VERSION, 'beta') }}
3737
files: |
38-
bin/kube-trigger-*.zip
39-
bin/kube-trigger-*.tar.gz
40-
bin/*-checksums.txt
38+
bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/kube-trigger-*.zip
39+
bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/kube-trigger-*.tar.gz
40+
bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/*-checksums.txt

makefiles/common-targets.mk

+15-11
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
# limitations under the License.
1414

1515
# Binary basename
16-
_OUT := $(BIN)$(BIN_EXTENSION)
16+
BIN_BASENAME := $(BIN)$(BIN_EXTENSION)
1717
# Binary basename with version and target
18-
_VER_OUT := $(BIN)-$(VERSION)-$(OS)-$(ARCH)$(BIN_EXTENSION)
18+
BIN_VERBOSE_BASE := $(BIN)-$(VERSION)-$(OS)-$(ARCH)$(BIN_EXTENSION)
1919
# If the user set FULL_NAME, we will use the basename with version and target.
2020
# e.g. kube-trigger-v0.0.1-linux-amd64
21-
BIN_FULLNAME := $(if $(FULL_NAME),$(_VER_OUT),$(_OUT))
22-
PKG_FULLNAME := $(if $(FULL_NAME),$(_VER_OUT),$(_OUT)).tar.gz
21+
BIN_FULLNAME := $(if $(FULL_NAME),$(BIN_VERBOSE_BASE),$(BIN_BASENAME))
22+
PKG_FULLNAME := $(if $(FULL_NAME),$(BIN_VERBOSE_BASE),$(BIN_BASENAME)).tar.gz
2323
ifeq ($(OS), windows)
24-
PKG_FULLNAME := $(subst .exe,,$(if $(FULL_NAME),$(_VER_OUT),$(_OUT))).zip
24+
PKG_FULLNAME := $(subst .exe,,$(if $(FULL_NAME),$(BIN_VERBOSE_BASE),$(BIN_BASENAME))).zip
2525
endif
26+
27+
BIN_VERBOSE_DIR := bin/$(BIN)-$(VERSION)
2628
# Full output relative path
27-
OUTPUT := bin/$(BIN_FULLNAME)
29+
OUTPUT := $(if $(FULL_NAME),$(BIN_VERBOSE_DIR)/$(BIN_FULLNAME),bin/$(BIN_FULLNAME))
30+
2831

2932
all: build
3033

@@ -38,7 +41,7 @@ build-%:
3841

3942
all-build: # @HELP build and package binaries for all platforms
4043
all-build: $(addprefix build-, $(subst /,_, $(BIN_PLATFORMS)))
41-
cd bin && sha256sum *{.tar.gz,.zip} > "$(BIN)-$(VERSION)-checksums.txt"
44+
cd "$(BIN_VERBOSE_DIR)" && sha256sum *{.tar.gz,.zip} > "$(BIN)-$(VERSION)-checksums.txt"
4245

4346
build: # @HELP build binary locally
4447
build:
@@ -52,11 +55,12 @@ build:
5255

5356
package: build
5457
echo "# Compressing $(BIN_FULLNAME) to $(PKG_FULLNAME)"
55-
cp LICENSE bin/LICENSE
56-
cd bin && if [ "$(OS)" == "windows" ]; then \
57-
zip "$(PKG_FULLNAME)" "$(BIN_FULLNAME)" LICENSE; \
58+
cp LICENSE "$(BIN_VERBOSE_DIR)/LICENSE"
59+
cp "$(OUTPUT)" "$(BIN_VERBOSE_DIR)/$(BIN_BASENAME)"
60+
cd $(BIN_VERBOSE_DIR) && if [ "$(OS)" == "windows" ]; then \
61+
zip "$(PKG_FULLNAME)" "$(BIN_BASENAME)" LICENSE; \
5862
else \
59-
tar czf "$(PKG_FULLNAME)" "$(BIN_FULLNAME)" LICENSE; \
63+
tar czf "$(PKG_FULLNAME)" "$(BIN_BASENAME)" LICENSE; \
6064
fi
6165

6266
dirty-build: # @HELP same as build, but using build cache is allowed

0 commit comments

Comments
 (0)