-
-
Notifications
You must be signed in to change notification settings - Fork 62
187 lines (162 loc) · 5.79 KB
/
build.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
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ published ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:16.1
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node_modules
with:
path: frontend/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('frontend/yarn.lock') }}
- name: Cache UI build
uses: actions/cache@v2
id: cache-ui
env:
cache-name: cache-ui
with:
path: frontend/build
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('frontend/yarn.lock', 'frontend/vite.config.js', 'frontend/src/**', 'graphql/**/*.graphql') }}
- name: Cache go build
uses: actions/cache@v2
env:
cache-name: cache-go-cache-2
with:
path: |
~/go/pkg/mod
.go-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.mod', '**/go.sum') }}
- name: Pre-install
run: make pre-ui
- name: Generate
# Make sure generate does not need to be run
run: |
make generate
git add --intent-to-add .
git diff --stat --exit-code
- name: Validate UI
# skip UI validation for pull requests if UI is unchanged
if: ${{ github.event_name != 'pull_request' || steps.cache-ui.outputs.cache-hit != 'true' }}
run: make ui-validate
- name: Build UI
# skip UI build for pull requests if UI is unchanged (UI was cached)
# this means that the build version/time may be incorrect if the UI is
# not changed in a pull request
if: ${{ github.event_name != 'pull_request' || steps.cache-ui.outputs.cache-hit != 'true' }}
run: make ui
- name: Run tests
env:
POSTGRES_DB: postgres:postgres@localhost/postgres?sslmode=disable
run: make it
- name: Set PR version
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/master'}}
run: echo "BUILD_TYPE=PR" >> $GITHUB_ENV
- name: Set Official version
if: ${{ github.event_name == 'release' && github.ref != 'refs/tags/latest-develop' }}
run: echo "BUILD_TYPE=OFFICIAL" >> $GITHUB_ENV
- name: Set Development version
if: ${{ github.event_name == 'push' }}
run: echo "BUILD_TYPE=DEVELOPMENT" >> $GITHUB_ENV
- name: Crosscompile binaries
run: make cross-compile
env:
BUILD_TYPE: "${{ env.BUILD_TYPE }}"
- name: Generate checksums
run: |
git describe --tags --exclude latest-develop | tee CHECKSUMS_SHA1
sha1sum dist/stash-box-* | sed 's/dist\/.*\///g' | tee -a CHECKSUMS_SHA1
echo "STASH_BOX_VERSION=$(git describe --tags --exclude latest-develop)" >> $GITHUB_ENV
- name: Upload Windows binary
# only upload binaries for pull requests
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/master'}}
uses: actions/upload-artifact@v2
with:
name: stash-box-win.exe
path: dist/stash-box-windows.exe
- name: Upload Linux binary
# only upload binaries for pull requests
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/master'}}
uses: actions/upload-artifact@v2
with:
name: stash-box-linux
path: dist/stash-box-linux
- name: Update latest-develop tag
if: ${{ github.event_name == 'push' }}
run : git tag -f latest-develop; git push -f --tags
- name: Development Release
if: ${{ github.event_name == 'push' }}
uses: marvinpinto/action-automatic-releases@v1.1.2
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
automatic_release_tag: latest-develop
title: "${{ env.STASH_BOX_VERSION }}: Latest development build"
files: |
dist/stash-box-windows.exe
dist/stash-box-linux
CHECKSUMS_SHA1
- name: Master release
if: ${{ github.event_name == 'release' && github.ref != 'refs/tags/latest-develop' }}
uses: WithoutPants/github-release@v2.0.4
with:
token: "${{ secrets.GITHUB_TOKEN }}"
allow_override: true
files: |
dist/stash-box-windows.exe
dist/stash-box-linux
CHECKSUMS_SHA1
gzip: false
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Development Docker
if: ${{ github.event_name == 'push' }}
run: |
docker build -t stashapp/stash-box:development -f ./docker/ci/x86_64/Dockerfile ./dist
docker push stashapp/stash-box:development
- name: Release Docker
if: ${{ github.event_name == 'release' && github.ref != 'refs/tags/latest-develop' }}
run: |
docker build -t stashapp/stash-box:latest -f ./docker/ci/x86_64/Dockerfile ./dist
docker push stashapp/stash-box:latest