-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (63 loc) · 1.83 KB
/
Copy pathgoBuildAPI.yml
File metadata and controls
78 lines (63 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Build DRLM API
on:
workflow_dispatch:
push:
branches:
- develop
- master
paths-ignore:
- '.github/workflows/**'
pull_request:
branches:
- develop
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
- name: Install dependencies
run: go mod tidy
- name: Get branch name
id: get_branch_name
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Get last tag
id: get_last_tag
run: |
LAST_TAG=$(git describe --tags --abbrev=0)
echo "LAST_TAG=$LAST_TAG" >> $GITHUB_ENV
- name: Get commit hash
id: get_commit_hash
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
- name: Build version name
id: build_version_name
run: |
if [ "$BRANCH_NAME" == "master" ]; then
VERSION_NAME="$LAST_TAG"
elif [ "$BRANCH_NAME" == "develop" ]; then
VERSION_NAME="$LAST_TAG-$COMMIT_HASH"
else
VERSION_NAME="$LAST_TAG-$BRANCH_NAME-$COMMIT_HASH"
fi
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
- name: Build the project
run: go build -ldflags "-X main.version=$VERSION_NAME" -o drlm-api .
- name: Verify build
run: |
if [ ! -f ./drlm-api ]; then
echo "Build failed: executable not found."
exit 1
fi
# - name: Test
# run: go test -v ./...
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: drlm-api
path: ./drlm-api