-
-
Notifications
You must be signed in to change notification settings - Fork 69
146 lines (142 loc) · 4.79 KB
/
release.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
name: Releases
on:
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+
pull_request:
env:
PYTHON_VERSION: '3.11'
POETRY_VERSION: 1.8.2
jobs:
docker-images:
name: Build Docker Images
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: ${{ github.event_name == 'push' }}
matrix:
include:
- base: slim
suffix: ''
file: ./docker/Dockerfile
context: ./
- base: alpine
suffix: -alpine
file: ./docker/Dockerfile.alpine
context: ./
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}
flavor: |
suffix=${{ matrix.suffix }},onlatest=true
tags: |
type=edge,branch=main,suffix=${{ matrix.suffix }}
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
- uses: docker/login-action@v2
if: github.event_name == 'push'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
id: buildx
- uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
platforms: linux/arm64, linux/amd64, linux/arm/v7, linux/386, linux/arm/v6
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract Major and Minor Version
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Full Tag: $TAG_NAME"
MAJOR=$(echo $TAG_NAME | cut -d. -f1)
MINOR=$(echo $TAG_NAME | cut -d. -f1,2)
echo "FULL_VERSION=$TAG_NAME" >> $GITHUB_ENV
echo "MAJOR_VERSION=$MAJOR" >> $GITHUB_ENV
echo "MINOR_VERSION=$MINOR" >> $GITHUB_ENV
- uses: iamazeem/substitute-action@v1
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
with:
variables: |
FULL_VERSION
MAJOR_VERSION
MINOR_VERSION
input-files: |
./docker/DOCKER_README.md
- uses: peter-evans/dockerhub-description@v4
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}
short-description: ${{ github.event.repository.description }}
readme-filepath: ./docker/DOCKER_README.md
releases:
name: Build Release Files
runs-on: ${{ matrix.os }}
strategy:
fail-fast: ${{ github.event_name == 'push' }}
matrix:
include:
- os: ubuntu-latest
tag: linux
- os: windows-latest
tag: win
- os: macos-13
tag: macos
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-poetry-action
with:
poetry-version: ${{ env.POETRY_VERSION }}
python-version: ${{ env.PYTHON_VERSION }}
without: test
- name: Run PyInstaller (linux/macos)
if: matrix.tag == 'linux' || matrix.tag == 'macos'
run: |
poetry run pyinstaller scanner.spec
cp ./config.sample.ini ./dist/config.ini
cp ./README.md ./dist/README.md
cp ./LICENSE ./dist/LICENSE
./dist/scanner -v
- name: Run PyInstaller (win)
if: matrix.tag == 'win'
run: |
poetry run pyinstaller scanner_win.spec
cp ./config.sample.ini ./dist/scanner/config.ini
cp ./README.md ./dist/scanner/README.md
cp ./LICENSE ./dist/scanner/LICENSE
./dist/scanner/scanner -v
- name: Make filename for archive
id: filename
shell: bash
run: echo "FILENAME=scanner-${{ github.ref_name }}-${{ matrix.tag }}.zip" | sed -r 's,/,-,g' >> $GITHUB_OUTPUT
- name: Zip files (linux/macos)
if: matrix.tag == 'linux' || matrix.tag == 'macos'
run: zip -j ./${{ steps.filename.outputs.FILENAME }} ./dist/*
- name: Zip files (win)
if: matrix.tag == 'win'
run: Compress-Archive ./dist/scanner/* ./${{ steps.filename.outputs.FILENAME }}
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: releases-${{ matrix.tag }}-${{ github.sha }}
path: ./${{ steps.filename.outputs.FILENAME }}
- name: Add archive to release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
files: ./${{ steps.filename.outputs.FILENAME }}