-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (127 loc) · 3.96 KB
/
ci.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
name: CI
on:
push:
branches:
- master
pull_request:
types: [closed]
branches:
- master
jobs:
test-and-lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
mkdir static
pip install poetry
poetry install
- name: Run pytest
run: poetry run pytest
- name: Run flake8
run: poetry run flake8
- name: Extract requirements.txt
run: |
pip install --user poetry-plugin-export
poetry export -f requirements.txt --output requirements.txt --without dev
- name: Upload requirements.txt
uses: actions/upload-artifact@v4
with:
name: requirements.txt
path: ./server/requirements.txt
if-no-files-found: error
semver-action:
needs: test-and-lint
outputs:
version: ${{ steps.semver-action.outputs.version }}
release-notes: ${{ steps.semver-action.outputs.release-notes }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get last version and hash
id: last-version
run: |
LAST_TAG=$(git describe --tags --abbrev=0 --match "v*.*.*" 2>/dev/null || echo "") || true
LAST_VERSION=$(echo $LAST_TAG | tr -d -c 0-9. || echo 0.0.0) || true
COMMIT_HASH=$(git rev-list -n 1 $LAST_TAG 2>/dev/null || echo "") || true
echo "hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
echo "version=$LAST_VERSION" >> $GITHUB_OUTPUT
- name: Semver Action
id: semver-action
uses: builder555/simple-semver@master
with:
last-version: ${{ steps.last-version.outputs.version }}
last-hash: ${{ steps.last-version.outputs.hash }}
github-token: ${{ secrets.GITHUB_TOKEN }}
create-release:
needs: semver-action
runs-on: ubuntu-latest
if: needs.semver-action.outputs.version != ''
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Update pyproject.toml version
run: |
cd server
pip install poetry
poetry version ${{ needs.semver-action.outputs.version }}
- name: Commit version changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add server/pyproject.toml
git commit -m "chore: bump version to v${{ needs.semver-action.outputs.version }}"
git tag v${{ needs.semver-action.outputs.version }}
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
build-and-push:
needs: semver-action
if: needs.semver-action.outputs.version != ''
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Build npm
run: |
cd ui
npm install
npm run build
- name: Download requirements.txt
uses: actions/download-artifact@v4
with:
name: requirements.txt
path: ./server/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: builder555
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push multi-platform Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: builder555/hantek-station:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7
context: .
file: ./server/Dockerfile