Skip to content

Commit 72d2fe9

Browse files
committed
Test env setup
1 parent 857ca78 commit 72d2fe9

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

.github/workflows/build-packages.yml

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,49 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
fetch-tags: true
2427
- name: Setup Go
2528
uses: actions/setup-go@v5
2629
with:
2730
go-version: '1.21.x'
2831

2932
- name: Prepare environment
3033
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
3636
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
3967

4068
# - name: Create bucket
4169
# if: github.event_name == 'push'
@@ -44,7 +72,7 @@ jobs:
4472
- uses: actions/upload-artifact@v4
4573
with:
4674
name: env.sh
47-
path: build/env.sh
75+
path: env.sh
4876

4977
build-packages:
5078
runs-on: ubuntu-latest

.github/workflows/tests-and-linters.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Tests
2-
# on:
2+
on:
33
# pull_request:
4+
workflow_call:
45

56
env:
67
GOFLAGS: "-count=1"

0 commit comments

Comments
 (0)