-
Notifications
You must be signed in to change notification settings - Fork 9
175 lines (174 loc) · 9 KB
/
create-prerelease.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Build and Create Pre-Release
on:
workflow_dispatch:
inputs:
addCommit:
description: 'Dev build?'
required: false
type: boolean
deletePrevBuild:
description: 'Delete existing pre-releases?'
required: false
type: boolean
sendSlackMessage:
description: 'Send Slack Message?'
required: false
type: boolean
message:
description: "What changed (for slack message)"
required: true
jobs:
build-and-release:
runs-on: macos-13
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: "Install Homebrew"
run: /bin/bash -c "NONINTERACTIVE=1 $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: "Install Dependencies"
run: |
/usr/local/bin/brew install --overwrite python@3.11 || echo "I1.1"
/usr/local/bin/brew link --overwrite python@3.11 || echo "I1.2"
/usr/local/bin/brew install --overwrite dpkg zip make wget jq rpm || echo "I2"
/usr/local/bin/brew link --overwrite python@3.11 || echo "I1.3"
/usr/local/bin/brew install python-gdbm@3.11 || echo "I1.4"
/usr/local/bin/brew install python-tk@3.11 || echo "I1.5"
pushd ~/work/aerolab/aerolab/brew
/usr/local/bin/brew install ./upx.rb
popd
for i in dpkg upx zip make wget jq rpm python3.11; do command -v $i || exit 1; done
echo "Dependencies checked"
- name: "Install golang"
run: |
wget https://go.dev/dl/go1.22.6.darwin-amd64.pkg
sudo installer -store -pkg go1.22.6.darwin-amd64.pkg -target /
- name: "Install Packages.pkg for making macos PKG files"
run: |
wget http://s.sudre.free.fr/Software/files/Packages.dmg
hdiutil attach -mountpoint /Volumes/Packages Packages.dmg
cd /Volumes/Packages
sudo installer -pkg Install\ Packages.pkg -target /
- name: "Compile"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
buildcmd="build-prerelease"
[ "${ADDCOMMIT}" = "false" ] && buildcmd="build-official"
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin
cd ~/work/aerolab/aerolab/src && make cleanall && make ${buildcmd}
- name: "Create linux packages"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
buildcmd="build-prerelease"
[ "${ADDCOMMIT}" = "false" ] && buildcmd="build-official"
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin
cd ~/work/aerolab/aerolab/src && make pkg-linux
- name: "Create windows zips"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
buildcmd="build-prerelease"
[ "${ADDCOMMIT}" = "false" ] && buildcmd="build-official"
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin
cd ~/work/aerolab/aerolab/src && make pkg-windows-zip
- name: "Print aerolab version"
run: cd ~/work/aerolab/aerolab/src && ../bin/aerolab-macos-amd64 version
- name: "Prepare keychain for signing MacOS"
env:
keypw: ${{ secrets.APPLEPW }}
INSTALLERP12: ${{ secrets.INSTALLERP12 }}
APPLICATIONP12: ${{ secrets.APPLICATIONP12 }}
run: |
set -e
security create-keychain -p mysecretpassword build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p mysecretpassword build.keychain
security set-keychain-settings build.keychain
security unlock-keychain -p mysecretpassword build.keychain
echo "$APPLICATIONP12" | base64 -d > app.p12
echo "$INSTALLERP12" | base64 -d > install.p12
security import app.p12 -k build.keychain -P $keypw -A
security import install.p12 -k build.keychain -P $keypw -A
security set-key-partition-list -S apple-tool:,apple: -s -k mysecretpassword build.keychain
- name: "Sign and build MacOS"
env:
xaerolab_appleid: ${{ secrets.APPLEUSER }}
xaerolab_applepw: ${{ secrets.APPLEPW }}
xaerolab_signer: ${{ secrets.APPLESIGNER }}
xaerolab_installsigner: ${{ secrets.APPLEINSTALLSIGNER }}
xaerolab_teamid: ${{ secrets.APPLETEAMID }}
run: |
set -e
export aerolab_appleid="${xaerolab_appleid}"
export aerolab_applepw="${xaerolab_applepw}"
export aerolab_signer="${xaerolab_signer}"
export aerolab_installsigner="${xaerolab_installsigner}"
export aerolab_teamid="${xaerolab_teamid}"
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin && cd ~/work/aerolab/aerolab/src && make macos-build-all && make macos-notarize-all
- name: "Create a new pre-release"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
set -e
echo "${ADDCOMMIT}"
cd ~/work/aerolab/aerolab/bin/packages
COMMIT=$(git rev-parse --short HEAD)
VER=$(cat ../../VERSION.md)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
TAG=${VER}-${COMMIT}
[ "${ADDCOMMIT}" = "false" ] && TAG=${VER}
FULLCOMMIT=$(git rev-parse HEAD)
gh release create -R github.com/aerospike/aerolab --notes-file ../../RELEASE.md --prerelease --target ${FULLCOMMIT} --title "AeroLab - v${TAG}" ${TAG} aerolab-linux-amd64-${VER}.deb aerolab-linux-amd64-${VER}.rpm aerolab-linux-amd64-${VER}.zip aerolab-linux-arm64-${VER}.deb aerolab-linux-arm64-${VER}.rpm aerolab-linux-arm64-${VER}.zip aerolab-macos-${VER}.pkg aerolab-macos-amd64-${VER}.zip aerolab-macos-arm64-${VER}.zip aerolab-windows-amd64-${VER}.zip aerolab-windows-arm64-${VER}.zip
- name: "Delete previous pre-release"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DELPREV: ${{ inputs.deletePrevBuild }}
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
if [ "${DELPREV}" = "true" ]
then
set -e
cd ~/work/aerolab/aerolab/bin/packages
echo "${ADDCOMMIT}"
COMMIT=$(git rev-parse --short HEAD)
VER=$(cat ../../VERSION.md)
TAG=${VER}-${COMMIT}
[ "${ADDCOMMIT}" = "false" ] && TAG=${VER}
echo "Protected tag: ${TAG}"
gh release list -R github.com/aerospike/aerolab -L 100 |grep Pre-release |awk -F'\t' '{print $3}' |while read line
do
if [ "$line" != "${TAG}" ]
then
if [[ $line =~ ^${VER}- ]]
then
echo "Removing $line"
gh release delete $line -R github.com/aerospike/aerolab --yes --cleanup-tag
fi
fi
done
fi
- name: "Send slack notification"
env:
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
ADDCOMMIT: ${{ inputs.addCommit }}
MESSAGE: ${{ inputs.message }}
SENDSLACK: ${{ inputs.sendSlackMessage }}
run: |
if [ "${SENDSLACK}" = "true" ]
then
echo "${ADDCOMMIT}"
cd ~/work/aerolab/aerolab
COMMIT=$(git rev-parse --short HEAD)
VER=$(cat VERSION.md)
if [ "${ADDCOMMIT}" = "true" ]
then
TAG=${VER}-${COMMIT}
curl -d "text=A new dev build is available at https://github.com/aerospike/aerolab/releases/tag/${TAG} Changes: ${MESSAGE}" -d "channel=${SLACK_CHANNEL}" -H "Authorization: Bearer ${SLACK_TOKEN}" -X POST https://slack.com/api/chat.postMessage || exit 0
else
TAG=${VER}
curl -d "text=A new pre-release is available at https://github.com/aerospike/aerolab/releases/tag/${TAG} Changes: ${MESSAGE}" -d "channel=${SLACK_CHANNEL}" -H "Authorization: Bearer ${SLACK_TOKEN}" -X POST https://slack.com/api/chat.postMessage || exit 0
fi
fi