-
Notifications
You must be signed in to change notification settings - Fork 2
197 lines (171 loc) · 6.73 KB
/
Copy pathbuild.yml
File metadata and controls
197 lines (171 loc) · 6.73 KB
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
190
191
192
193
194
195
196
197
name: Build and Test
on:
push:
branches: ['**']
tags: ['v[0-9]*.[0-9]*.[0-9]*']
paths-ignore:
- '**.md'
- '**.txt'
- 'LICENSE'
- '.gitignore'
- 'docs/**'
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows x86
os: windows-latest
artifact_platform: windows-x86
cmake_args: -A Win32
archive_ext: zip
- name: Windows x64
os: windows-latest
artifact_platform: windows-x64
cmake_args: -A x64
archive_ext: zip
- name: macOS Universal
os: macos-latest
artifact_platform: macos-universal
cmake_args: -DCMAKE_OSX_ARCHITECTURES=arm64\;x86_64
archive_ext: tar.gz
- name: Linux x86_64
os: ubuntu-latest
artifact_platform: linux-x86_64
cmake_args: ''
archive_ext: tar.gz
- name: Linux x86
os: ubuntu-latest
artifact_platform: linux-x86
cmake_args: >-
-DCMAKE_C_FLAGS=-m32
-DCMAKE_CXX_FLAGS=-m32
-DCMAKE_EXE_LINKER_FLAGS=-m32
extra_packages: gcc-multilib g++-multilib
archive_ext: tar.gz
- name: Linux arm64
os: ubuntu-22.04-arm
artifact_platform: linux-arm64
cmake_args: ''
archive_ext: tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install extra packages
if: matrix.extra_packages != ''
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.extra_packages }}
- name: Configure
run: cmake -B build -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_args }}
- name: Build
run: cmake --build build --config Release
- name: Test
run: ctest --test-dir build -C Release --output-on-failure
# ── Determine archive name (nightly vs. tagged release) ──────────────
- name: Set archive name
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
echo "ARCHIVE_NAME=vorlage-${GITHUB_REF_NAME}-${{ matrix.artifact_platform }}.${{ matrix.archive_ext }}" >> "$GITHUB_ENV"
else
echo "ARCHIVE_NAME=vorlage-nightly-${{ matrix.artifact_platform }}.${{ matrix.archive_ext }}" >> "$GITHUB_ENV"
fi
# ── Package (Unix) ────────────────────────────────────────────────────
- name: Package (Unix)
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && runner.os != 'Windows'
shell: bash
run: |
STAGE=$(mktemp -d)
cp build/Vorlage/vorlage "$STAGE/"
cp build/VPP/vpp "$STAGE/"
cp README.md LICENSE "$STAGE/"
cp Vorlage/history.txt "$STAGE/"
cp config/.*rc "$STAGE/"
cp config/*.vms "$STAGE/"
tar czf "$ARCHIVE_NAME" -C "$STAGE" .
# ── Package (Windows) ─────────────────────────────────────────────────
- name: Package (Windows)
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && runner.os == 'Windows'
shell: pwsh
run: |
$stage = New-Item -ItemType Directory -Path "$env:RUNNER_TEMP\stage"
Copy-Item "build\Vorlage\Release\vorlage.exe" $stage
Copy-Item "build\VPP\Release\vpp.exe" $stage
Copy-Item "README.md", "LICENSE" $stage
Copy-Item "Vorlage\history.txt" $stage
Copy-Item "config\*.cfg" $stage
Copy-Item "config\*.vms" $stage
Compress-Archive -Path "$stage\*" -DestinationPath "$env:ARCHIVE_NAME"
# ── Upload artifact ───────────────────────────────────────────────────
- name: Upload artifact
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_platform }}
path: ${{ env.ARCHIVE_NAME }}
retention-days: 14
# ── Update rolling nightly release (master only) ─────────────────────────
nightly:
name: Update Nightly Release
needs: build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Delete existing nightly release and tag
run: gh release delete nightly --yes --cleanup-tag || true
env:
GH_TOKEN: ${{ github.token }}
- name: Publish nightly release
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: Nightly Build
prerelease: true
make_latest: false
body: "Latest build from the master branch. Updated automatically on every push."
files: artifacts/**/*
# ── Create GitHub Release (tags only) ──────────────────────────────────────
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create source tarball
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
git archive \
--format=tar \
--prefix="vorlage-${VERSION}/" \
HEAD \
| bzip2 -9 > "vorlage-${VERSION}-source.tar.bz2"
echo "SOURCE_TARBALL=vorlage-${VERSION}-source.tar.bz2" >> "$GITHUB_ENV"
- name: Publish release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/**/*
${{ env.SOURCE_TARBALL }}