-
Notifications
You must be signed in to change notification settings - Fork 5
200 lines (155 loc) · 6.06 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
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
name: Build and Publish
on:
push:
branches:
- master
- dev
tags:
- '*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Fetch tags
run: git fetch --tags --force
- name: Metadata
run: echo "IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}" >> $GITHUB_ENV
- name: Environment
run: |
echo "VERSION=$(python build/print_version.py ${{ github.run_number }} ${{ env.IS_RELEASE }} false)" >> $GITHUB_ENV
echo "PYPI_VERSION=$(python build/print_version.py ${{ github.run_number }} ${{ env.IS_RELEASE }} pypi)" >> $GITHUB_ENV
echo "$(python build/print_solution.py)" >> $GITHUB_ENV
- name: Extract annotation tag
if: ${{ env.IS_RELEASE == 'true' }}
run: python build/create_tag_body.py
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Create Docker Output Folder
run: mkdir --parent artifacts/images
- name: Install
run: |
npm install -g pyright
python -m pip install frictionless==4.40.9 build wheel httpx pytest pytest-asyncio
npm install -g [email protected]
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
dotnet workload install --temp-dir tmp wasm-tools
- name: Docker Setup
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build
run: |
(cd src/Nexus.UI && libman restore)
dotnet publish -c Release -o app /p:GeneratePackage=true src/Nexus/Nexus.csproj
python -m build --wheel --outdir artifacts/packages --no-isolation src/clients/python-client
python -m build --wheel --outdir artifacts/packages --no-isolation src/extensibility/python-extensibility
- name: Test
run: |
dotnet test -c Release /p:BuildProjectReferences=false
pyright
pytest
- name: Docker Build
run: |
docker build -t malstroem-labs/nexus:v_next .
docker save --output artifacts/images/nexus_image.tar malstroem-labs/nexus:v_next
- name: CSS
run: |
npx tailwindcss -i src/Nexus.UI/Styles/app.css -o app_new.css
diff src/Nexus.UI/wwwroot/css/app.css app_new.css
- name: API
run: |
dotnet run --project src/Nexus.ClientGenerator/Nexus.ClientGenerator.csproj -- ./ openapi_new.json
diff --strip-trailing-cr openapi.json openapi_new.json
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
artifacts/*.txt
artifacts/packages/
artifacts/images/
- name: Prepare GitHub Pages
run: |
touch app/wwwroot/.nojekyll
sed -i 's/<base href="\/" \/>/<base href="\/nexus\/" \/>/g' app/wwwroot/index.html
if: github.ref == 'refs/heads/master'
- name: Deploy GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: app/wwwroot
if: github.ref == 'refs/heads/master'
outputs:
is_release: ${{ env.IS_RELEASE }}
version: ${{ env.VERSION }}
publish_dev:
needs: build
name: Publish (dev)
runs-on: ubuntu-latest
if: ${{ needs.build.outputs.is_release != 'true' }}
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: artifacts
- name: Docker Load Image
run: docker load --input artifacts/images/nexus_image.tar
- name: Nuget package (MyGet)
run: dotnet nuget push 'artifacts/packages/*.nupkg' --api-key ${MYGET_API_KEY} --source https://www.myget.org/F/apollo3zehn-dev/api/v3/index.json
env:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
- name: Python package (MyGet)
run: 'for filePath in artifacts/packages/*.whl; do curl -k -X POST https://www.myget.org/F/apollo3zehn-dev/python/upload -H "Authorization: Bearer ${MYGET_API_KEY}" -F "data=@$filePath"; done'
env:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
- name: Docker Login (Github Container Registry)
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Push
run: |
docker tag malstroem-labs/nexus:v_next ghcr.io/malstroem-labs/nexus:${{ needs.build.outputs.version }}
docker push ghcr.io/malstroem-labs/nexus:${{ needs.build.outputs.version }}
publish_release:
needs: build
name: Publish (release)
runs-on: ubuntu-latest
if: ${{ needs.build.outputs.is_release == 'true' }}
steps:
- name: Install
run: |
python -m pip install twine
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: artifacts
- name: Docker Load Image
run: docker load --input artifacts/images/nexus_image.tar
- name: GitHub Release Artifacts
uses: softprops/action-gh-release@v1
with:
body_path: artifacts/tag_body.txt
- name: Nuget package (Nuget)
run: dotnet nuget push 'artifacts/packages/*.nupkg' --api-key ${NUGET_API_KEY} --source https://api.nuget.org/v3/index.json
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
- name: Python Package (PyPI)
run: twine upload artifacts/packages/*.whl -u__token__ -p"${PYPI_API_KEY}"
env:
PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }}
- name: Docker Login (Docker Hub)
uses: docker/login-action@v1
with:
username: malstroemlabs
password: ${{ secrets.DOCKER_API_KEY }}
- name: Docker Push
run: |
docker tag malstroem-labs/nexus:v_next malstroemlabs/nexus:${{ needs.build.outputs.version }}
docker push malstroemlabs/nexus:${{ needs.build.outputs.version }}