-
Notifications
You must be signed in to change notification settings - Fork 2
246 lines (226 loc) · 8.6 KB
/
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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: Release
# Create and upload release file.
on:
push:
# Build on a push of any tag named host-tools-*, a push to main, or a
# manual call via github CLI.
tags:
- '*'
branches:
- 'main'
jobs:
build_tools:
name: Build Host Tools
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set Up Python
uses: actions/setup-python@v2
with:
python-version: '>=3.8'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1
- name: Compile Tools
run: |
scripts/build_scripts/compile_p1_runner.bat
- name: Upload .exe Artifact
uses: actions/upload-artifact@v4
with:
name: p1-host-tools-exe
path: pyinstaller_dist\
package_release:
name: Package and Export Release
needs: [build_tools]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@v2
with:
# Disable shallow checkout so we get the whole history, including tags, rather than just a single shallow commit
# and no tag history. That way the `git describe` version query done by get_version.sh works.
fetch-depth: 0
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1
- name: Get Github Ref
run: |
echo "REF=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Get Version
run: |
export EXPORT_TO_GITHUB_ENV="true"
scripts/get_version.sh
- name: Create Release Directory
run: |
RELEASE_DIR="point-one-host-tools-${{ env.VERSION_NUMBER }}"
RELEASE_FILE="${RELEASE_DIR}.python.zip"
echo "Creating release directory ${RELEASE_DIR}."
if [[ -d "${RELEASE_DIR}" ]]; then
rm -rf "${RELEASE_DIR}"
fi
echo "RELEASE_FILE=$RELEASE_FILE" >> $GITHUB_ENV
echo "RELEASE_DIR=$RELEASE_DIR" >> $GITHUB_ENV
- name: Create Release Directory and Structure
run: |
mkdir -p ${{ env.RELEASE_DIR }}
mkdir -p ${{ env.RELEASE_DIR }}/bin
mkdir -p ${{ env.RELEASE_DIR }}/p1_runner
mkdir -p ${{ env.RELEASE_DIR }}/user_config_loaders
- name: Copy in p1_runner
run: |
echo "Copying in p1_runner application."
cp -r README.md ${{ env.RELEASE_DIR }}/
cp -r requirements.txt ${{ env.RELEASE_DIR }}/
cp -r setup.py ${{ env.RELEASE_DIR }}/
cp -r p1_runner/*.py ${{ env.RELEASE_DIR }}/p1_runner/
cp --parents `find user_config_loaders/ -name \*.py` ${{ env.RELEASE_DIR }}/user_config_loaders/
cp -r bin/*.py ${{ env.RELEASE_DIR }}/bin/
- name: Display List of Downloaded Structures
run: ls -R ${{ env.RELEASE_DIR }}
- name: Export Release to S3
run: |
ARTIFACT_BUCKET=pointone-build-artifacts
ARTIFACT_PATH=nautilus/p1-host-tools
# Create and upload the complete release package.
zip -r ${{ env.RELEASE_FILE }} ${{ env.RELEASE_DIR }}
RELEASE_AWS_PATH="s3://${ARTIFACT_BUCKET}/${ARTIFACT_PATH}/${{ env.VERSION_STR }}/${{ env.RELEASE_FILE }}"
aws s3 cp ${{ env.RELEASE_FILE }} ${RELEASE_AWS_PATH}
SLACK_MESSAGE=$(cat <<EOF
Results available at:
- ${RELEASE_AWS_PATH}
EOF
)
echo "SLACK_MESSAGE<<EOF" >> $GITHUB_ENV
echo "${SLACK_MESSAGE}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Upload .zip Artifact
uses: actions/upload-artifact@v4
with:
name: p1-host-tools-zip
path: ${{ env.RELEASE_FILE }}
- name: Create Windows Release Directory
run: |
WIN_RELEASE_DIR="point-one-host-tools-${{ env.VERSION_NUMBER }}"
WIN_RELEASE_FILE="${WIN_RELEASE_DIR}.windows.zip"
echo "Creating release directory ${WIN_RELEASE_DIR}."
if [[ -d "${WIN_RELEASE_DIR}" ]]; then
rm -rf "${WIN_RELEASE_DIR}"
fi
echo "WIN_RELEASE_FILE=$WIN_RELEASE_FILE" >> $GITHUB_ENV
echo "WIN_RELEASE_DIR=$WIN_RELEASE_DIR" >> $GITHUB_ENV
- name: Download .exe Artifacts
uses: actions/download-artifact@v4
with:
name: p1-host-tools-exe
path: ${{ env.WIN_RELEASE_DIR }}
- name: Copy in files
run: |
cp -r README.md ${{ env.WIN_RELEASE_DIR }}
- name: Display List of Release Files
run: |
ls -R ${{ env.WIN_RELEASE_DIR }}
- name: Export Release to S3
run: |
ARTIFACT_BUCKET=pointone-build-artifacts
ARTIFACT_PATH=nautilus/p1-host-tools
zip -r ${{ env.WIN_RELEASE_FILE }} ${{ env.WIN_RELEASE_DIR }}
WIN_RELEASE_AWS_PATH="s3://${ARTIFACT_BUCKET}/${ARTIFACT_PATH}/${{ env.VERSION_STR }}/${{ env.WIN_RELEASE_FILE }}"
aws s3 cp ${{ env.WIN_RELEASE_FILE }} ${WIN_RELEASE_AWS_PATH}
- name: Upload Zip of .exe Artifacts
uses: actions/upload-artifact@v4
with:
name: p1-host-tools-exe-zip
path: ${{ env.WIN_RELEASE_FILE }}
# # Note: We must manually call curl here so the message gets conveyed
# # properly with line breaks. We previously used slack-github-action, but
# # it does not support newlines in JSON strings.
# - name: Post Success Notification to Nautilus Slack Channel
# run: |
# curl --request POST \
# --header "Content-Type: application/json" \
# --data "{\"success\": \"successful\", \"reference\": \"${{ github.ref_name }}\", \"message\": \"${SLACK_MESSAGE}\"}" \
# "${{ secrets.SLACK_WEBHOOK_RELEASE_BUILD_COMPLETE }}"
# Create a release only on a tag (not on a branch push).
release:
name: Create Release
if: startsWith(github.ref, 'refs/tags/')
needs: [package_release]
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Get Zipped Source Artifact
uses: actions/download-artifact@v4
with:
name: p1-host-tools-zip
- name: Get Windows Build Artifact
uses: actions/download-artifact@v4
with:
name: p1-host-tools-exe-zip
- name: Get Artifact Paths
run: |
RELEASE_FILE="$(ls *.windows.zip)"
echo "WIN_RELEASE_FILE=$RELEASE_FILE" >> $GITHUB_ENV
RELEASE_FILE="$(ls *.python.zip)"
echo "RELEASE_FILE=$RELEASE_FILE" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Files
if: steps.create_release.conclusion == 'success'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.RELEASE_FILE }}
asset_name: ${{ env.RELEASE_FILE }}
asset_content_type: application/zip
- name: Upload Windows Release Files
if: steps.create_release.conclusion == 'success'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.WIN_RELEASE_FILE }}
asset_name: ${{ env.WIN_RELEASE_FILE }}
asset_content_type: application/zip
failure_notification:
name: Conditional Failure Notification
runs-on: ubuntu-latest
needs: [build_tools, package_release]
if: |
always() &&
(needs.build_tools.result == 'failure' ||
needs.package_release.result == 'failure')
steps:
- name: Post Failure Notification to Nautilus Slack Channel
uses: slackapi/[email protected]
with:
payload: |
{
"success": "failed",
"reference": "${{ github.ref_name }}",
"message": ""
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_RELEASE_BUILD_COMPLETE }}