-
Notifications
You must be signed in to change notification settings - Fork 204
118 lines (102 loc) · 4.03 KB
/
create_release.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
name: Create release
on:
push:
branches:
- master
- rc/*
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest] # TODO add macos-latest when builds are possible on macs
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
- name: Set up Go 1.20.7
uses: actions/setup-go@v3
with:
go-version: 1.20.7
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set environment variables
run: |
APP_VER_SHORT=$(git describe --tags)
GOOS=$(go env GOOS)
GOARCH=$(go env GOARCH)
GOPATH=$(go env GOPATH)
ARCHIVE="multiversx_""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".tgz"
BUILD_DIR=${GITHUB_WORKSPACE}/build
WASM_VERSION=$(cat go.mod | grep mx-chain-vm-v | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')
WASMER_DIR=${GOPATH}/pkg/mod/github.com/multiversx/${WASM_VERSION}/wasmer
echo "GOOS=${GOOS}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV
echo "WASMER_DIR=${WASMER_DIR}" >> $GITHUB_ENV
- name: Build
run: |
mkdir -p ${BUILD_DIR}
cd ${GITHUB_WORKSPACE}/cmd/node && go build -o "${BUILD_DIR}/node" -a -ldflags="-X main.appVersion=${APP_VER}"
cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build -o "${BUILD_DIR}/keygenerator" -a -ldflags="-X main.appVersion=${APP_VER}"
cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build -o "${BUILD_DIR}/logviewer" -a -ldflags="-X main.appVersion=${APP_VER}"
cd ${GITHUB_WORKSPACE}/cmd/termui && go build -o "${BUILD_DIR}/termui" -a -ldflags="-X main.appVersion=${APP_VER}"
- name: Package
run: |
cd ${GITHUB_WORKSPACE}
if [[ "$GOOS" == linux && "$GOARCH" == amd64 ]]; then
cp -f ${WASMER_DIR}/libwasmer_linux_amd64.so ${BUILD_DIR};
fi
if [[ "$GOOS" == linux && "$GOARCH" == arm64 ]]; then
cp -f ${WASMER_DIR}/libwasmer_linux_arm64.so ${BUILD_DIR};
fi
if [[ "$GOOS" == darwin && "$GOARCH" == amd64 ]]; then
cp -f ${WASMER_DIR}/libwasmer_darwin_amd64.dylib ${BUILD_DIR};
fi
cd ${BUILD_DIR}
tar czvf "${GITHUB_WORKSPACE}/${ARCHIVE}" *
stat ${GITHUB_WORKSPACE}/${ARCHIVE}
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARCHIVE }}
path: ${{ github.workspace }}/${{ env.ARCHIVE }}
if-no-files-found: error
release:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
# https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
# A directory for each artifact is created using its name
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
with:
path: assets
- name: Display structure of downloaded files
run: ls -R
working-directory: assets
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create --draft --notes="Release draft from Github Actions" vNext
sleep 10
for i in $(find ./assets -name '*.tgz' -type f); do
gh release upload vNext ${i}
done