-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (112 loc) · 3.77 KB
/
build.yaml
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
name: Build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on: workflow_dispatch
jobs:
# phase 1
target:
name: Build target branch
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
target_branch: ${{ steps.build-target.outputs.target_branch }}
version: ${{ steps.build-target.outputs.version }}
docker_matrix: ${{ steps.build-target.outputs.docker_matrix }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
- name: Install Viash
uses: viash-io/viash-actions/setup@v6
- name: Determine variables
id: variables
run: |
VERSION="${{ github.event.inputs.version }}"
SOURCE_BRANCH=$(echo "$GITHUB_REF" | sed 's/refs\/heads\///')
if [[ -z $VERSION ]]; then
TARGET_BRANCH="build/$SOURCE_BRANCH"
VERSION=$(echo "$TARGET_BRANCH" | sed 's/[^a-zA-Z0-9_]/_/g')
else
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Version '$VERSION' does not match PEP440"
exit 1
fi
TARGET_BRANCH="release/${VERSION%.*}.x"
fi
echo "Set version of Viash package to '$VERSION'"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Set target branch to '$TARGET_BRANCH'"
echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT
- uses: viash-io/viash-actions/project/build-target@v6
id: build-target
with:
target_branch: ${{ steps.variables.outputs.target_branch }}
version: ${{ steps.variables.outputs.version }}
- name: Deploy to target branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: ${{ steps.variables.outputs.target_branch }}
publish_dir: .
# phase 2
docker:
name: Build and push Docker images
needs: target
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
component: ${{ fromJson(needs.target.outputs.docker_matrix) }}
steps:
# Remove unnecessary files to free up space. Otherwise, we get 'no space left on device.'
- uses: data-intuitive/reclaim-the-bytes@v2
- uses: actions/checkout@v4
with:
ref: ${{ needs.target.outputs.target_branch }}
- uses: viash-io/viash-actions/setup@v6
- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
run: |
${{matrix.component.executable}} ---engine docker ---setup build ---verbose
- name: Push image
run: |
${{matrix.component.executable}} ---engine docker ---setup push ---verbose
# phase 3
cleanup:
name: Clean up repository
needs: target
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
steps:
- uses: data-intuitive/reclaim-the-bytes@v2
- uses: actions/checkout@v4
with:
ref: ${{ needs.target.outputs.target_branch }}
# Add step to copy files to .
- name: Copy executables to root
run: |
echo "Copying directories to root"
# cp -r target/executable/common/* .
ls -l
# Add step to remove unnecessary files
- name: Clean up
run: |
echo "Cleaning up"
rm -rf target
rm -rf src
rm _viash.yaml