-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (226 loc) · 9.05 KB
/
release.yml
File metadata and controls
272 lines (226 loc) · 9.05 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Release
on:
release:
types: [created]
jobs:
discover-architectures:
name: Discover Architectures
runs-on: ubuntu-latest
permissions:
contents: read
container:
image: chocotechnologies/dmod:1.0.4
outputs:
architectures: ${{ steps.list-archs.outputs.architectures }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Fetch dmod to discover architectures
run: |
mkdir -p build_discovery
cd build_discovery
cmake .. -DDMOD_MODE=DMOD_MODULE
- name: List available architectures
id: list-archs
run: |
DMOD_SRC_DIR=$(find build_discovery -path "*/_deps/dmod-src" -type d | head -1)
# create JSON array
ARCHS=$(find ${DMOD_SRC_DIR}/configs/arch -name "tools-cfg.cmake" | \
sed "s|${DMOD_SRC_DIR}/configs/arch/||g" | \
sed 's|/tools-cfg.cmake||g' | \
jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "Found architectures: $ARCHS"
echo "architectures=$ARCHS" >> $GITHUB_OUTPUT
build-release:
name: Build Release for ${{ matrix.arch_name }}
needs: discover-architectures
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
arch_name: ${{ fromJson(needs.discover-architectures.outputs.architectures) }}
container:
image: chocotechnologies/dmod:1.0.4
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from tag
id: get_version
run: |
# Extract version from tag (e.g., v1.2 -> 1.2)
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}" # Remove 'v' prefix if present
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Build dmdevfs for ${{ matrix.arch_name }}
run: |
set -e
ARCH_DIR_NAME=$(echo "${{ matrix.arch_name }}" | sed 's|/|-|')
echo "ARCH_DIR_NAME=$ARCH_DIR_NAME" >> $GITHUB_ENV
echo "ARTIFACT_NAME=release-$ARCH_DIR_NAME" >> $GITHUB_ENV
mkdir -p build_$ARCH_DIR_NAME
cd build_$ARCH_DIR_NAME
# First run cmake to fetch dependencies with version from tag
cmake .. -DDMOD_TOOLS_NAME=arch/${{ matrix.arch_name }} -DDMOD_MODULE_VERSION="${{ steps.get_version.outputs.version }}"
# Build the modules
cmake --build .
echo "Build completed for ${{ matrix.arch_name }}"
ls -la dmf/
ls -la dmfc/
- name: Prepare release package
run: |
set -e
mkdir -p release_package
BUILD_DIR=build_$ARCH_DIR_NAME
DMF_DIR="$BUILD_DIR/dmf"
DMFC_DIR="$BUILD_DIR/dmfc"
cp $DMF_DIR/dmdevfs.dmf release_package/
cp $DMF_DIR/dmdevfs_version.txt release_package/
cp $DMFC_DIR/dmdevfs.dmfc release_package/
# Copy .dmd file if it exists
if [ -f $DMF_DIR/dmdevfs.dmd ]; then
cp $DMF_DIR/dmdevfs.dmd release_package/
fi
# Copy documentation and license
cp README.md release_package/
cp LICENSE release_package/
# Create release notes file from GitHub release
echo "${{ github.event.release.body }}" > release_package/RELEASE_NOTES.txt
echo "Package contents:"
ls -la release_package/
- name: Create release archive
run: |
cd release_package
zip -r ../dmdevfs-${{ github.event.release.tag_name }}-$ARCH_DIR_NAME.zip .
cd ..
echo "Created archive:"
ls -lh dmdevfs-*.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: dmdevfs-${{ github.event.release.tag_name }}-*.zip
retention-days: 1
generate-versions-manifest:
name: Generate versions.dmm
needs: discover-architectures
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history to get all tags
- name: Generate versions.dmm
run: |
set -e
echo "# List of available versions for dmdevfs modules" > versions.dmm
echo "# Generated automatically by CI" >> versions.dmm
echo "" >> versions.dmm
# Get all version tags (starting with 'v') and extract version numbers
VERSIONS=$(git tag -l 'v*' | sed 's/^v//' | sort -V | tr '\n' ' ' | sed 's/ $//')
# Remove vlatest from the list if present
VERSIONS=$(echo $VERSIONS | sed 's/\blatest\b//g' | xargs)
if [ -z "$VERSIONS" ]; then
echo "Warning: No version tags found"
VERSIONS="${{ github.event.release.tag_name }}"
VERSIONS="${VERSIONS#v}"
fi
echo "Found versions: $VERSIONS"
# Add $version-available directive for dmdevfs module
echo "\$version-available dmdevfs $VERSIONS" >> versions.dmm
echo "Generated versions.dmm:"
cat versions.dmm
- name: Upload versions.dmm as artifact
uses: actions/upload-artifact@v4
with:
name: versions-manifest
path: versions.dmm
retention-days: 1
upload-release-assets:
name: Upload Release Assets
needs: [build-release, generate-versions-manifest]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display artifact structure
run: |
echo "Downloaded artifacts:"
ls -lR artifacts/
- name: Upload release assets to versioned tag
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
# Upload all release archives to the GitHub release
shopt -s nullglob
zip_files=(artifacts/release-*/*.zip)
if [ ${#zip_files[@]} -eq 0 ]; then
echo "Error: No artifacts found to upload"
exit 1
fi
for zip_file in "${zip_files[@]}"; do
echo "Uploading $zip_file to ${{ github.event.release.tag_name }}..."
gh release upload ${{ github.event.release.tag_name }} \
"$zip_file" \
--repo ${{ github.repository }} \
--clobber
done
# Upload versions.dmm to the versioned release
if [ -f artifacts/versions-manifest/versions.dmm ]; then
echo "Uploading versions.dmm to ${{ github.event.release.tag_name }}..."
gh release upload ${{ github.event.release.tag_name }} \
artifacts/versions-manifest/versions.dmm \
--repo ${{ github.repository }} \
--clobber
fi
echo "Successfully uploaded ${#zip_files[@]} artifact(s) to ${{ github.event.release.tag_name }}"
- name: Create or update latest release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
# Check if vlatest release exists
if gh release view vlatest --repo ${{ github.repository }} >/dev/null 2>&1; then
echo "Release vlatest exists, deleting it..."
gh release delete vlatest --repo ${{ github.repository }} --yes
fi
# Create new vlatest release
echo "Creating vlatest release..."
gh release create vlatest \
--repo ${{ github.repository }} \
--title "Latest Release (based on ${{ github.event.release.tag_name }})" \
--notes "This release always points to the latest stable version. Currently based on ${{ github.event.release.tag_name }}."
- name: Upload release assets to latest tag
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
shopt -s nullglob
zip_files=(artifacts/release-*/*.zip)
for zip_file in "${zip_files[@]}"; do
echo "Uploading $zip_file to vlatest..."
gh release upload vlatest \
"$zip_file" \
--repo ${{ github.repository }} \
--clobber
done
# Upload versions.dmm to the latest release
if [ -f artifacts/versions-manifest/versions.dmm ]; then
echo "Uploading versions.dmm to vlatest..."
gh release upload vlatest \
artifacts/versions-manifest/versions.dmm \
--repo ${{ github.repository }} \
--clobber
fi
echo "Successfully uploaded ${#zip_files[@]} artifact(s) to vlatest"