-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (108 loc) · 4.37 KB
/
build_and_publish.yml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build and Publish Launch Releases
on:
push:
branches:
- master
paths:
- 'main.go'
- 'utils/**'
- 'go.mod'
- 'go.sum'
- '.github/workflows/build_and_publish.yml'
jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- { runner: macos-latest, goos: darwin, osname: macOS, arch: amd64, tags: netcgo }
- { runner: macos-latest, goos: darwin, osname: macOS, arch: arm64, tags: netcgo }
- { runner: ubuntu-latest, goos: linux, osname: linux, arch: amd64, env: CGO_ENABLED=0 }
- { runner: ubuntu-latest, goos: linux, osname: linux, arch: arm64, env: CGO_ENABLED=0 }
- { runner: ubuntu-latest, goos: windows, osname: windows, arch: amd64, env: CGO_ENABLED=0, extension: ".exe" }
# - { runner: ubuntu-latest, goos: windows, osname: windows, arch: arm64, env: CGO_ENABLED=0, extension: ".exe" }
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.5'
- name: Build Go app
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.arch }}
run: |
${{ matrix.env }} go build -tags="${{ matrix.tags }}" -o dkn-compute-launcher${{ matrix.extension }} .
- name: Download dkn-compute binaries
env:
FOLDER_NAME: dkn-compute-node
ZIP_NAME: dkn-compute-launcher-${{ matrix.osname }}-${{ matrix.arch }}
run: |
# download node binary
mkdir node_binary
cd node_binary
echo "Downloading dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}"
if curl -L -o dkn-compute-binary${{ matrix.extension }} https://github.com/firstbatchxyz/dkn-compute-node/releases/latest/download/dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}${{ matrix.extension }}; then
echo "Download completed."
ls
else
echo "Error: Failed to download the zip file."
exit 1
fi
- name: Prepare Launch Release Files
env:
FOLDER_NAME: dkn-compute-node
ZIP_NAME: dkn-compute-launcher-${{ matrix.osname }}-${{ matrix.arch }}
run: |
mkdir $FOLDER_NAME
# copy launcher binary
cp ./dkn-compute-launcher${{ matrix.extension }} $FOLDER_NAME/dkn-compute-launcher${{ matrix.extension }}
# download .env.example and save it as .env
curl -o $FOLDER_NAME/.env https://raw.githubusercontent.com/firstbatchxyz/dkn-compute-node/master/.env.example
# copy dkn-compute binary
cp ./node_binary/dkn-compute-binary${{ matrix.extension }} $FOLDER_NAME/dkn-compute${{ matrix.extension }}
zip -r $ZIP_NAME.zip $FOLDER_NAME
- name: Upload Launch Artifacts
uses: actions/upload-artifact@v4
with:
name: dkn-compute-launcher-${{ matrix.osname }}-${{ matrix.arch }}
path: dkn-compute-launcher-${{ matrix.osname }}-${{ matrix.arch }}.zip
release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Launch Artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: ./artifacts
- name: Get the latest tag
id: get_latest_tag
run: echo "latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
- name: Calculate new tag
id: calculate_tag
run: |
latest_tag=${{ env.latest_tag }}
if [ -z "$latest_tag" ]; then
new_tag="v0.0.1"
else
IFS='.' read -ra VERSION_PARTS <<< "${latest_tag#v}"
major=${VERSION_PARTS[0]}
minor=${VERSION_PARTS[1]}
patch=${VERSION_PARTS[2]}
new_patch=$((patch + 1))
new_tag="v${major}.${minor}.${new_patch}"
fi
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
- name: Create release with artifacts
uses: ncipollo/release-action@v1
with:
name: ${{ env.NEW_TAG }}
tag: ${{ env.NEW_TAG }}
artifacts: "artifacts/*"
artifactContentType: application/zip
draft: true