@@ -21,21 +21,49 @@ jobs:
21
21
22
22
steps :
23
23
- uses : actions/checkout@v4
24
+ with :
25
+ fetch-depth : 0
26
+ fetch-tags : true
24
27
- name : Setup Go
25
28
uses : actions/setup-go@v5
26
29
with :
27
30
go-version : ' 1.21.x'
28
31
29
32
- name : Prepare environment
30
33
run : |
31
- echo "BUILD_NUMBER=${{ github.repository }}-${{ github.workflow }}-${{ github.run_id }}-ghactions" >> $GITHUB_ENV
32
- echo "BUILD_COMMIT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
33
- echo "BUILD_BRANCH_SAFE=${{ github.ref }}" >> $GITHUB_ENV
34
- echo "BUILD_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
35
- echo "BUILD_BRANCH=${{ github.ref }}" >> $GITHUB_ENV
34
+ RELEASE_BUILD=false
35
+ if [[ "${GITHUB_REF}" == /refs/tags/* ]]; then RELEASE_BUILD=true; fi
36
36
37
- - name : Generate env file
38
- run : go run mage.go -v GenerateEnvFile
37
+ RC_BUILD=false
38
+ if [[ "${GITHUB_REF}" == /refs/tags/*-rc ]]; then RC_BUILD=true; fi
39
+
40
+ SNAPSHOT_BUILD=false
41
+ if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then SNAPSHOT_BUILD=true; fi
42
+
43
+ PR_BUILD=false
44
+ if [[ "${SNAPSHOT_BUILD}" == "false" && "${RELEASE_BUILD}" == "false" ]]; then PR_BUILD=true; fi
45
+
46
+ BUILD_NUMBER="${{ github.run_id }}"-ghactions
47
+
48
+ if [[ "${RELEASE_BUILD}" == "true" ]]; then
49
+ BUILD_VERSION="${GITHUB_REF#/refs/tags/}";
50
+ elif [[ "${SNAPSHOT_BUILD}" == "true" ]]; then
51
+ BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1snapshot-"$(date '+%Y%m%dT%H%M')"-"$(echo ${GITHUB_SHA} | cut -c1-8)";
52
+ elif [[ "${PR_BUILD}" == "true" ]]; then
53
+ BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1branch-"${GITHUB_REF_NAME}";
54
+ fi
55
+
56
+ cat <<EOT >> env.sh
57
+ export RELEASE_BUILD=$RELEASE_BUILD;
58
+ export RC_BUILD=$RC_BUILD;
59
+ export SNAPSHOT_BUILD=$SNAPSHOT_BUILD;
60
+ export BUILD_NUMBER=$BUILD_NUMBER;
61
+ export BUILD_VERSION=$BUILD_VERSION;
62
+ EOT
63
+
64
+
65
+ # - name: Generate env file
66
+ # run: go run mage.go -v GenerateEnvFile
39
67
40
68
# - name: Create bucket
41
69
# if: github.event_name == 'push'
44
72
- uses : actions/upload-artifact@v4
45
73
with :
46
74
name : env.sh
47
- path : build/ env.sh
75
+ path : env.sh
48
76
49
77
build-packages :
50
78
runs-on : ubuntu-latest
0 commit comments