-
Notifications
You must be signed in to change notification settings - Fork 1
189 lines (160 loc) · 5.08 KB
/
build_project.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
name: build-project
on:
push:
pull_request:
branches: main
release:
types: [published]
env:
REGISTRY_GITHUB: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
variables:
outputs:
ref_name: ${{ steps.var.outputs.ref_name}}
runs-on: "ubuntu-latest"
steps:
- name: Setting global variables
uses: actions/github-script@v6
id: var
with:
script: |
core.setOutput('ref_name', '${{ github.ref_name }}'.toLowerCase().replaceAll(/[/.]/g, '-').trim('-'));
build-ui:
runs-on: ubuntu-latest
needs: variables
env:
REF_NAME: ${{ needs.variables.outputs.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: Install dependencies
run: npm install
working-directory: ui
- name: Build
run: npm run build:core
working-directory: ui
- name: Save angular artifacts
uses: actions/upload-artifact@v3
with:
name: ui-artifacts-${{ env.REF_NAME }}
path: |
ui/dist/learninghouse
build-core:
runs-on: ubuntu-latest
needs: [variables, build-ui]
env:
REF_NAME: ${{ needs.variables.outputs.ref_name }}
permissions:
id-token: write
contents: write
strategy:
matrix:
python-version:
- '3.10'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download UI
uses: actions/download-artifact@v3
with:
name: ui-artifacts-${{ env.REF_NAME }}
path: core/learninghouse/ui
- name: Copy README.md LICENSE and THIRD-PARTY-NOTICES
run: |
cp README.md LICENSE THIRD-PARTY-NOTICES core/
- name: Install build package
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
working-directory: core
- name: Save python artifacts
uses: actions/upload-artifact@v3
with:
name: python-artifacts-${{ matrix.python-version }}-${{ env.REF_NAME }}
path: |
core/dist
- name: Publish package to pypi
if: ${{github.event_name == 'release' && matrix.python-version == '3.10'}}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: core/dist/
- name: Publish assets to github
if: ${{github.event_name == 'release'}}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ github.token }}
file: core/dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
build-docker:
runs-on: ubuntu-latest
needs: [variables, build-core]
env:
REF_NAME: ${{ needs.variables.outputs.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load learninghouse wheel
uses: actions/download-artifact@v3
with:
name: python-artifacts-3.10-${{ env.REF_NAME }}
path: docker/container
- name: Copy requirements.txt for core
run: cp core/requirements.txt docker/container/
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Log in to the Docker github container registry
if: ${{github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main')}}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY_GITHUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Docker container registry
if: ${{github.event_name == 'release'}}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker (No Release)
id: meta
if: ${{github.event_name != 'release'}}
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}
- name: Extract metadata (tags, labels) for Docker (Release)
id: meta_release
if: ${{github.event_name == 'release'}}
uses: docker/metadata-action@v4
with:
images: |
${{ env.IMAGE_NAME }}
${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: docker
push: ${{github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main')}}
tags: ${{github.event_name == 'release' && steps.meta_release.outputs.tags || steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}