-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (189 loc) · 6.95 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
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
name: Helios Release
on:
workflow_dispatch: # manual trigger
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
- name: Update Package Lists
run: sudo apt-get update
- name: Install Dependencies
run: sudo apt-get install valgrind g++ make --fix-missing
- name: Build HeliosCLI
run: make -j
working-directory: HeliosCLI
- name: Archive HeliosCLI artifacts
run: zip -r "helioscli.zip" .
working-directory: HeliosCLI
- name: Upload HeliosCLI Artifact
uses: actions/upload-artifact@v4
with:
name: helioscli-artifacts
path: HeliosCLI/helioscli.zip
tests:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
- name: Download HeliosCLI Artifact
uses: actions/download-artifact@v4
with:
name: helioscli-artifacts
path: ./HeliosCLI
- name: Set execute permissions for test script
run: chmod +x ./runtests.sh
working-directory: tests
- name: Run general tests
run: ./runtests.sh
working-directory: tests
embedded:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Dependencies
run: make install
working-directory: HeliosEmbedded
- name: Build Binary
run: make build
working-directory: HeliosEmbedded
- name: Archive HeliosEmbedded artifacts
run: zip -r "embedded-firmware.zip" .
working-directory: HeliosEmbedded
- name: Upload HeliosEmbedded Artifact
uses: actions/upload-artifact@v4
with:
name: embedded-firmware
path: HeliosEmbedded/embedded-firmware.zip
release:
needs: embedded
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for calculating version
- name: Get the latest tag
id: get_tag
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "none")
echo "tag=$latest_tag" >> $GITHUB_ENV
- name: Check for existing tags
id: check_tag
run: |
if [ "${{ env.tag }}" == "none" ]; then
echo "No tags found. Creating initial tag 1.0.0."
echo "new_tag=1.0.0" >> $GITHUB_ENV
fi
- name: Calculate new version
id: calc_version
run: |
if [ "${{ env.new_tag }}" == "" ]; then
latest_tag=${{ env.tag }}
commits_since_tag=$(git rev-list $latest_tag..HEAD --count)
IFS='.' read -ra ADDR <<< "$latest_tag"
patch=$((ADDR[2] + commits_since_tag))
new_version="${ADDR[0]}.${ADDR[1]}.$patch"
echo "new_version=$new_version" >> $GITHUB_ENV
echo "new_tag=$new_version" >> $GITHUB_ENV
else
echo "new_version=${{ env.new_tag }}" >> $GITHUB_ENV
fi
- name: Check if new tag exists
run: |
if git rev-parse "refs/tags/${{ env.new_tag }}" >/dev/null 2>&1; then
echo "Tag ${{ env.new_tag }} already exists. Skipping tag creation."
echo "tag_exists=true" >> $GITHUB_ENV
else
echo "tag_exists=false" >> $GITHUB_ENV
fi
- name: Create a new tag
if: env.tag_exists == 'false'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git tag ${{ env.new_tag }}
git push origin ${{ env.new_tag }}
- name: Download HeliosCLI Artifact
uses: actions/download-artifact@v4
with:
name: helioscli-artifacts
path: ./artifact/helioscli
- name: Download HeliosEmbedded Artifact
uses: actions/download-artifact@v4
with:
name: embedded-firmware
path: ./artifact/embedded
- name: Create directories for unzipping
run: mkdir -p ./artifact/unzipped/helioscli ./artifact/unzipped/embedded
- name: Unzip HeliosCLI Artifact
run: unzip ./artifact/helioscli/helioscli.zip -d ./artifact/unzipped/helioscli
- name: Unzip HeliosEmbedded Artifact
run: unzip ./artifact/embedded/embedded-firmware.zip -d ./artifact/unzipped/embedded
- name: Create GitHub Release
id: create_release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.new_tag }}
name: Helios Vortex ${{ env.new_version }}
body: |
Release of Helios Vortex version ${{ env.new_version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets (helios.bin)
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.bin
asset_name: helios.bin
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets (helios.elf)
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.elf
asset_name: helios.elf
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets (helios.map)
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.map
asset_name: helios.map
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets (helios.hex)
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/embedded/helios.hex
asset_name: helios.hex
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets (Helios CLI)
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/unzipped/helioscli/helios
asset_name: helios
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}